Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 1 | /** |
| 2 | * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org) |
| 3 | */ |
| 4 | |
| 5 | package org.onosproject.xran.asn1lib.api; |
| 6 | |
| 7 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 8 | import com.fasterxml.jackson.annotation.JsonValue; |
| 9 | import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream; |
| 10 | import org.onosproject.xran.asn1lib.ber.BerLength; |
| 11 | import org.onosproject.xran.asn1lib.ber.BerTag; |
| 12 | import org.onosproject.xran.asn1lib.ber.types.BerInteger; |
| 13 | |
| 14 | import java.io.IOException; |
| 15 | import java.io.InputStream; |
| 16 | import java.io.Serializable; |
| 17 | import java.util.ArrayList; |
| 18 | import java.util.Iterator; |
| 19 | import java.util.List; |
| 20 | |
| 21 | |
| 22 | public class PRBUsage implements Serializable { |
| 23 | |
| 24 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 25 | private static final long serialVersionUID = 1L; |
| 26 | @JsonIgnore |
| 27 | public byte[] code = null; |
| 28 | private PrbUsageDl prbUsageDl = null; |
| 29 | private PrbUsageUl prbUsageUl = null; |
| 30 | public PRBUsage() { |
| 31 | } |
| 32 | public PRBUsage(byte[] code) { |
| 33 | this.code = code; |
| 34 | } |
| 35 | |
| 36 | public PrbUsageDl getPrbUsageDl() { |
| 37 | return prbUsageDl; |
| 38 | } |
| 39 | |
| 40 | public void setPrbUsageDl(PrbUsageDl prbUsageDl) { |
| 41 | this.prbUsageDl = prbUsageDl; |
| 42 | } |
| 43 | |
| 44 | public PrbUsageUl getPrbUsageUl() { |
| 45 | return prbUsageUl; |
| 46 | } |
| 47 | |
| 48 | public void setPrbUsageUl(PrbUsageUl prbUsageUl) { |
| 49 | this.prbUsageUl = prbUsageUl; |
| 50 | } |
| 51 | |
| 52 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 53 | return encode(os, true); |
| 54 | } |
| 55 | |
| 56 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 57 | |
| 58 | if (code != null) { |
| 59 | for (int i = code.length - 1; i >= 0; i--) { |
| 60 | os.write(code[i]); |
| 61 | } |
| 62 | if (withTag) { |
| 63 | return tag.encode(os) + code.length; |
| 64 | } |
| 65 | return code.length; |
| 66 | } |
| 67 | |
| 68 | int codeLength = 0; |
| 69 | codeLength += prbUsageUl.encode(os, false); |
| 70 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 71 | os.write(0xA1); |
| 72 | codeLength += 1; |
| 73 | |
| 74 | codeLength += prbUsageDl.encode(os, false); |
| 75 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 76 | os.write(0xA0); |
| 77 | codeLength += 1; |
| 78 | |
| 79 | codeLength += BerLength.encodeLength(os, codeLength); |
| 80 | |
| 81 | if (withTag) { |
| 82 | codeLength += tag.encode(os); |
| 83 | } |
| 84 | |
| 85 | return codeLength; |
| 86 | |
| 87 | } |
| 88 | |
| 89 | public int decode(InputStream is) throws IOException { |
| 90 | return decode(is, true); |
| 91 | } |
| 92 | |
| 93 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 94 | int codeLength = 0; |
| 95 | int subCodeLength = 0; |
| 96 | BerTag berTag = new BerTag(); |
| 97 | |
| 98 | if (withTag) { |
| 99 | codeLength += tag.decodeAndCheck(is); |
| 100 | } |
| 101 | |
| 102 | BerLength length = new BerLength(); |
| 103 | codeLength += length.decode(is); |
| 104 | |
| 105 | int totalLength = length.val; |
| 106 | codeLength += totalLength; |
| 107 | |
| 108 | subCodeLength += berTag.decode(is); |
| 109 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 110 | prbUsageDl = new PrbUsageDl(); |
| 111 | subCodeLength += prbUsageDl.decode(is, false); |
| 112 | subCodeLength += berTag.decode(is); |
| 113 | } else { |
| 114 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 115 | } |
| 116 | |
| 117 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 118 | prbUsageUl = new PrbUsageUl(); |
| 119 | subCodeLength += prbUsageUl.decode(is, false); |
| 120 | if (subCodeLength == totalLength) { |
| 121 | return codeLength; |
| 122 | } |
| 123 | } |
| 124 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 125 | |
| 126 | |
| 127 | } |
| 128 | |
| 129 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 130 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 131 | encode(os, false); |
| 132 | code = os.getArray(); |
| 133 | } |
| 134 | |
| 135 | public String toString() { |
| 136 | StringBuilder sb = new StringBuilder(); |
| 137 | appendAsString(sb, 0); |
| 138 | return sb.toString(); |
| 139 | } |
| 140 | |
| 141 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 142 | |
| 143 | sb.append("{"); |
| 144 | sb.append("\n"); |
| 145 | for (int i = 0; i < indentLevel + 1; i++) { |
| 146 | sb.append("\t"); |
| 147 | } |
| 148 | if (prbUsageDl != null) { |
| 149 | sb.append("prbUsageDl: "); |
| 150 | prbUsageDl.appendAsString(sb, indentLevel + 1); |
| 151 | } else { |
| 152 | sb.append("prbUsageDl: <empty-required-field>"); |
| 153 | } |
| 154 | |
| 155 | sb.append(",\n"); |
| 156 | for (int i = 0; i < indentLevel + 1; i++) { |
| 157 | sb.append("\t"); |
| 158 | } |
| 159 | if (prbUsageUl != null) { |
| 160 | sb.append("prbUsageUl: "); |
| 161 | prbUsageUl.appendAsString(sb, indentLevel + 1); |
| 162 | } else { |
| 163 | sb.append("prbUsageUl: <empty-required-field>"); |
| 164 | } |
| 165 | |
| 166 | sb.append("\n"); |
| 167 | for (int i = 0; i < indentLevel; i++) { |
| 168 | sb.append("\t"); |
| 169 | } |
| 170 | sb.append("}"); |
| 171 | } |
| 172 | |
| 173 | public static class PrbUsageDl implements Serializable { |
| 174 | |
| 175 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 176 | private static final long serialVersionUID = 1L; |
| 177 | @JsonIgnore |
| 178 | public byte[] code = null; |
| 179 | private List<BerInteger> seqOf = null; |
| 180 | |
| 181 | public PrbUsageDl() { |
| 182 | seqOf = new ArrayList<BerInteger>(); |
| 183 | } |
| 184 | |
| 185 | public PrbUsageDl(byte[] code) { |
| 186 | this.code = code; |
| 187 | } |
| 188 | |
| 189 | @JsonValue |
| 190 | public List<BerInteger> getBerInteger() { |
| 191 | if (seqOf == null) { |
| 192 | seqOf = new ArrayList<BerInteger>(); |
| 193 | } |
| 194 | return seqOf; |
| 195 | } |
| 196 | |
| 197 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 198 | return encode(os, true); |
| 199 | } |
| 200 | |
| 201 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 202 | |
| 203 | if (code != null) { |
| 204 | for (int i = code.length - 1; i >= 0; i--) { |
| 205 | os.write(code[i]); |
| 206 | } |
| 207 | if (withTag) { |
| 208 | return tag.encode(os) + code.length; |
| 209 | } |
| 210 | return code.length; |
| 211 | } |
| 212 | |
| 213 | int codeLength = 0; |
| 214 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 215 | codeLength += seqOf.get(i).encode(os, true); |
| 216 | } |
| 217 | |
| 218 | codeLength += BerLength.encodeLength(os, codeLength); |
| 219 | |
| 220 | if (withTag) { |
| 221 | codeLength += tag.encode(os); |
| 222 | } |
| 223 | |
| 224 | return codeLength; |
| 225 | } |
| 226 | |
| 227 | public int decode(InputStream is) throws IOException { |
| 228 | return decode(is, true); |
| 229 | } |
| 230 | |
| 231 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 232 | int codeLength = 0; |
| 233 | int subCodeLength = 0; |
| 234 | if (withTag) { |
| 235 | codeLength += tag.decodeAndCheck(is); |
| 236 | } |
| 237 | |
| 238 | BerLength length = new BerLength(); |
| 239 | codeLength += length.decode(is); |
| 240 | int totalLength = length.val; |
| 241 | |
| 242 | while (subCodeLength < totalLength) { |
| 243 | BerInteger element = new BerInteger(); |
| 244 | subCodeLength += element.decode(is, true); |
| 245 | seqOf.add(element); |
| 246 | } |
| 247 | if (subCodeLength != totalLength) { |
| 248 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 249 | |
| 250 | } |
| 251 | codeLength += subCodeLength; |
| 252 | |
| 253 | return codeLength; |
| 254 | } |
| 255 | |
| 256 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 257 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 258 | encode(os, false); |
| 259 | code = os.getArray(); |
| 260 | } |
| 261 | |
| 262 | public String toString() { |
| 263 | StringBuilder sb = new StringBuilder(); |
| 264 | appendAsString(sb, 0); |
| 265 | return sb.toString(); |
| 266 | } |
| 267 | |
| 268 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 269 | |
| 270 | sb.append("{\n"); |
| 271 | for (int i = 0; i < indentLevel + 1; i++) { |
| 272 | sb.append("\t"); |
| 273 | } |
| 274 | if (seqOf == null) { |
| 275 | sb.append("null"); |
| 276 | } else { |
| 277 | Iterator<BerInteger> it = seqOf.iterator(); |
| 278 | if (it.hasNext()) { |
| 279 | sb.append(it.next()); |
| 280 | while (it.hasNext()) { |
| 281 | sb.append(",\n"); |
| 282 | for (int i = 0; i < indentLevel + 1; i++) { |
| 283 | sb.append("\t"); |
| 284 | } |
| 285 | sb.append(it.next()); |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | sb.append("\n"); |
| 291 | for (int i = 0; i < indentLevel; i++) { |
| 292 | sb.append("\t"); |
| 293 | } |
| 294 | sb.append("}"); |
| 295 | } |
| 296 | |
| 297 | } |
| 298 | |
| 299 | public static class PrbUsageUl implements Serializable { |
| 300 | |
| 301 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 302 | private static final long serialVersionUID = 1L; |
| 303 | @JsonIgnore |
| 304 | public byte[] code = null; |
| 305 | private List<BerInteger> seqOf = null; |
| 306 | |
| 307 | public PrbUsageUl() { |
| 308 | seqOf = new ArrayList<BerInteger>(); |
| 309 | } |
| 310 | |
| 311 | public PrbUsageUl(byte[] code) { |
| 312 | this.code = code; |
| 313 | } |
| 314 | |
| 315 | @JsonValue |
| 316 | public List<BerInteger> getBerInteger() { |
| 317 | if (seqOf == null) { |
| 318 | seqOf = new ArrayList<BerInteger>(); |
| 319 | } |
| 320 | return seqOf; |
| 321 | } |
| 322 | |
| 323 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 324 | return encode(os, true); |
| 325 | } |
| 326 | |
| 327 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 328 | |
| 329 | if (code != null) { |
| 330 | for (int i = code.length - 1; i >= 0; i--) { |
| 331 | os.write(code[i]); |
| 332 | } |
| 333 | if (withTag) { |
| 334 | return tag.encode(os) + code.length; |
| 335 | } |
| 336 | return code.length; |
| 337 | } |
| 338 | |
| 339 | int codeLength = 0; |
| 340 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 341 | codeLength += seqOf.get(i).encode(os, true); |
| 342 | } |
| 343 | |
| 344 | codeLength += BerLength.encodeLength(os, codeLength); |
| 345 | |
| 346 | if (withTag) { |
| 347 | codeLength += tag.encode(os); |
| 348 | } |
| 349 | |
| 350 | return codeLength; |
| 351 | } |
| 352 | |
| 353 | public int decode(InputStream is) throws IOException { |
| 354 | return decode(is, true); |
| 355 | } |
| 356 | |
| 357 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 358 | int codeLength = 0; |
| 359 | int subCodeLength = 0; |
| 360 | if (withTag) { |
| 361 | codeLength += tag.decodeAndCheck(is); |
| 362 | } |
| 363 | |
| 364 | BerLength length = new BerLength(); |
| 365 | codeLength += length.decode(is); |
| 366 | int totalLength = length.val; |
| 367 | |
| 368 | while (subCodeLength < totalLength) { |
| 369 | BerInteger element = new BerInteger(); |
| 370 | subCodeLength += element.decode(is, true); |
| 371 | seqOf.add(element); |
| 372 | } |
| 373 | if (subCodeLength != totalLength) { |
| 374 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 375 | |
| 376 | } |
| 377 | codeLength += subCodeLength; |
| 378 | |
| 379 | return codeLength; |
| 380 | } |
| 381 | |
| 382 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 383 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 384 | encode(os, false); |
| 385 | code = os.getArray(); |
| 386 | } |
| 387 | |
| 388 | public String toString() { |
| 389 | StringBuilder sb = new StringBuilder(); |
| 390 | appendAsString(sb, 0); |
| 391 | return sb.toString(); |
| 392 | } |
| 393 | |
| 394 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 395 | |
| 396 | sb.append("{\n"); |
| 397 | for (int i = 0; i < indentLevel + 1; i++) { |
| 398 | sb.append("\t"); |
| 399 | } |
| 400 | if (seqOf == null) { |
| 401 | sb.append("null"); |
| 402 | } else { |
| 403 | Iterator<BerInteger> it = seqOf.iterator(); |
| 404 | if (it.hasNext()) { |
| 405 | sb.append(it.next()); |
| 406 | while (it.hasNext()) { |
| 407 | sb.append(",\n"); |
| 408 | for (int i = 0; i < indentLevel + 1; i++) { |
| 409 | sb.append("\t"); |
| 410 | } |
| 411 | sb.append(it.next()); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | sb.append("\n"); |
| 417 | for (int i = 0; i < indentLevel; i++) { |
| 418 | sb.append("\t"); |
| 419 | } |
| 420 | sb.append("}"); |
| 421 | } |
| 422 | |
| 423 | } |
| 424 | |
| 425 | } |
| 426 | |