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 SchedMeasRepPerServCell 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 ECGI ecgi = null; |
| 29 | private QciVals qciVals = null; |
| 30 | private PRBUsage prbUsage = null; |
| 31 | private McsDl mcsDl = null; |
| 32 | private NumSchedTtisDl numSchedTtisDl = null; |
| 33 | private McsUl mcsUl = null; |
| 34 | private NumSchedTtisUl numSchedTtisUl = null; |
| 35 | private RankDl1 rankDl1 = null; |
| 36 | private RankDl2 rankDl2 = null; |
| 37 | public SchedMeasRepPerServCell() { |
| 38 | } |
| 39 | public SchedMeasRepPerServCell(byte[] code) { |
| 40 | this.code = code; |
| 41 | } |
| 42 | |
| 43 | public ECGI getEcgi() { |
| 44 | return ecgi; |
| 45 | } |
| 46 | |
| 47 | public void setEcgi(ECGI ecgi) { |
| 48 | this.ecgi = ecgi; |
| 49 | } |
| 50 | |
| 51 | public QciVals getQciVals() { |
| 52 | return qciVals; |
| 53 | } |
| 54 | |
| 55 | public void setQciVals(QciVals qciVals) { |
| 56 | this.qciVals = qciVals; |
| 57 | } |
| 58 | |
| 59 | public PRBUsage getPrbUsage() { |
| 60 | return prbUsage; |
| 61 | } |
| 62 | |
| 63 | public void setPrbUsage(PRBUsage prbUsage) { |
| 64 | this.prbUsage = prbUsage; |
| 65 | } |
| 66 | |
| 67 | public McsDl getMcsDl() { |
| 68 | return mcsDl; |
| 69 | } |
| 70 | |
| 71 | public void setMcsDl(McsDl mcsDl) { |
| 72 | this.mcsDl = mcsDl; |
| 73 | } |
| 74 | |
| 75 | public NumSchedTtisDl getNumSchedTtisDl() { |
| 76 | return numSchedTtisDl; |
| 77 | } |
| 78 | |
| 79 | public void setNumSchedTtisDl(NumSchedTtisDl numSchedTtisDl) { |
| 80 | this.numSchedTtisDl = numSchedTtisDl; |
| 81 | } |
| 82 | |
| 83 | public McsUl getMcsUl() { |
| 84 | return mcsUl; |
| 85 | } |
| 86 | |
| 87 | public void setMcsUl(McsUl mcsUl) { |
| 88 | this.mcsUl = mcsUl; |
| 89 | } |
| 90 | |
| 91 | public NumSchedTtisUl getNumSchedTtisUl() { |
| 92 | return numSchedTtisUl; |
| 93 | } |
| 94 | |
| 95 | public void setNumSchedTtisUl(NumSchedTtisUl numSchedTtisUl) { |
| 96 | this.numSchedTtisUl = numSchedTtisUl; |
| 97 | } |
| 98 | |
| 99 | public RankDl1 getRankDl1() { |
| 100 | return rankDl1; |
| 101 | } |
| 102 | |
| 103 | public void setRankDl1(RankDl1 rankDl1) { |
| 104 | this.rankDl1 = rankDl1; |
| 105 | } |
| 106 | |
| 107 | public RankDl2 getRankDl2() { |
| 108 | return rankDl2; |
| 109 | } |
| 110 | |
| 111 | public void setRankDl2(RankDl2 rankDl2) { |
| 112 | this.rankDl2 = rankDl2; |
| 113 | } |
| 114 | |
| 115 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 116 | return encode(os, true); |
| 117 | } |
| 118 | |
| 119 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 120 | |
| 121 | if (code != null) { |
| 122 | for (int i = code.length - 1; i >= 0; i--) { |
| 123 | os.write(code[i]); |
| 124 | } |
| 125 | if (withTag) { |
| 126 | return tag.encode(os) + code.length; |
| 127 | } |
| 128 | return code.length; |
| 129 | } |
| 130 | |
| 131 | int codeLength = 0; |
| 132 | codeLength += rankDl2.encode(os, false); |
| 133 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 8 |
| 134 | os.write(0xA8); |
| 135 | codeLength += 1; |
| 136 | |
| 137 | codeLength += rankDl1.encode(os, false); |
| 138 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 7 |
| 139 | os.write(0xA7); |
| 140 | codeLength += 1; |
| 141 | |
| 142 | codeLength += numSchedTtisUl.encode(os, false); |
| 143 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 6 |
| 144 | os.write(0xA6); |
| 145 | codeLength += 1; |
| 146 | |
| 147 | codeLength += mcsUl.encode(os, false); |
| 148 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 5 |
| 149 | os.write(0xA5); |
| 150 | codeLength += 1; |
| 151 | |
| 152 | codeLength += numSchedTtisDl.encode(os, false); |
| 153 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 4 |
| 154 | os.write(0xA4); |
| 155 | codeLength += 1; |
| 156 | |
| 157 | codeLength += mcsDl.encode(os, false); |
| 158 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 3 |
| 159 | os.write(0xA3); |
| 160 | codeLength += 1; |
| 161 | |
| 162 | codeLength += prbUsage.encode(os, false); |
| 163 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 164 | os.write(0xA2); |
| 165 | codeLength += 1; |
| 166 | |
| 167 | codeLength += qciVals.encode(os, false); |
| 168 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 169 | os.write(0xA1); |
| 170 | codeLength += 1; |
| 171 | |
| 172 | codeLength += ecgi.encode(os, false); |
| 173 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 174 | os.write(0xA0); |
| 175 | codeLength += 1; |
| 176 | |
| 177 | codeLength += BerLength.encodeLength(os, codeLength); |
| 178 | |
| 179 | if (withTag) { |
| 180 | codeLength += tag.encode(os); |
| 181 | } |
| 182 | |
| 183 | return codeLength; |
| 184 | |
| 185 | } |
| 186 | |
| 187 | public int decode(InputStream is) throws IOException { |
| 188 | return decode(is, true); |
| 189 | } |
| 190 | |
| 191 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 192 | int codeLength = 0; |
| 193 | int subCodeLength = 0; |
| 194 | BerTag berTag = new BerTag(); |
| 195 | |
| 196 | if (withTag) { |
| 197 | codeLength += tag.decodeAndCheck(is); |
| 198 | } |
| 199 | |
| 200 | BerLength length = new BerLength(); |
| 201 | codeLength += length.decode(is); |
| 202 | |
| 203 | int totalLength = length.val; |
| 204 | codeLength += totalLength; |
| 205 | |
| 206 | subCodeLength += berTag.decode(is); |
| 207 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 208 | ecgi = new ECGI(); |
| 209 | subCodeLength += ecgi.decode(is, false); |
| 210 | subCodeLength += berTag.decode(is); |
| 211 | } else { |
| 212 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 213 | } |
| 214 | |
| 215 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 216 | qciVals = new QciVals(); |
| 217 | subCodeLength += qciVals.decode(is, false); |
| 218 | subCodeLength += berTag.decode(is); |
| 219 | } else { |
| 220 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 221 | } |
| 222 | |
| 223 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 224 | prbUsage = new PRBUsage(); |
| 225 | subCodeLength += prbUsage.decode(is, false); |
| 226 | subCodeLength += berTag.decode(is); |
| 227 | } else { |
| 228 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 229 | } |
| 230 | |
| 231 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) { |
| 232 | mcsDl = new McsDl(); |
| 233 | subCodeLength += mcsDl.decode(is, false); |
| 234 | subCodeLength += berTag.decode(is); |
| 235 | } else { |
| 236 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 237 | } |
| 238 | |
| 239 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { |
| 240 | numSchedTtisDl = new NumSchedTtisDl(); |
| 241 | subCodeLength += numSchedTtisDl.decode(is, false); |
| 242 | subCodeLength += berTag.decode(is); |
| 243 | } else { |
| 244 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 245 | } |
| 246 | |
| 247 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { |
| 248 | mcsUl = new McsUl(); |
| 249 | subCodeLength += mcsUl.decode(is, false); |
| 250 | subCodeLength += berTag.decode(is); |
| 251 | } else { |
| 252 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 253 | } |
| 254 | |
| 255 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { |
| 256 | numSchedTtisUl = new NumSchedTtisUl(); |
| 257 | subCodeLength += numSchedTtisUl.decode(is, false); |
| 258 | subCodeLength += berTag.decode(is); |
| 259 | } else { |
| 260 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 261 | } |
| 262 | |
| 263 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) { |
| 264 | rankDl1 = new RankDl1(); |
| 265 | subCodeLength += rankDl1.decode(is, false); |
| 266 | subCodeLength += berTag.decode(is); |
| 267 | } else { |
| 268 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 269 | } |
| 270 | |
| 271 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) { |
| 272 | rankDl2 = new RankDl2(); |
| 273 | subCodeLength += rankDl2.decode(is, false); |
| 274 | if (subCodeLength == totalLength) { |
| 275 | return codeLength; |
| 276 | } |
| 277 | } |
| 278 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 279 | |
| 280 | |
| 281 | } |
| 282 | |
| 283 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 284 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 285 | encode(os, false); |
| 286 | code = os.getArray(); |
| 287 | } |
| 288 | |
| 289 | public String toString() { |
| 290 | StringBuilder sb = new StringBuilder(); |
| 291 | appendAsString(sb, 0); |
| 292 | return sb.toString(); |
| 293 | } |
| 294 | |
| 295 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 296 | |
| 297 | sb.append("{"); |
| 298 | sb.append("\n"); |
| 299 | for (int i = 0; i < indentLevel + 1; i++) { |
| 300 | sb.append("\t"); |
| 301 | } |
| 302 | if (ecgi != null) { |
| 303 | sb.append("ecgi: "); |
| 304 | ecgi.appendAsString(sb, indentLevel + 1); |
| 305 | } else { |
| 306 | sb.append("ecgi: <empty-required-field>"); |
| 307 | } |
| 308 | |
| 309 | sb.append(",\n"); |
| 310 | for (int i = 0; i < indentLevel + 1; i++) { |
| 311 | sb.append("\t"); |
| 312 | } |
| 313 | if (qciVals != null) { |
| 314 | sb.append("qciVals: "); |
| 315 | qciVals.appendAsString(sb, indentLevel + 1); |
| 316 | } else { |
| 317 | sb.append("qciVals: <empty-required-field>"); |
| 318 | } |
| 319 | |
| 320 | sb.append(",\n"); |
| 321 | for (int i = 0; i < indentLevel + 1; i++) { |
| 322 | sb.append("\t"); |
| 323 | } |
| 324 | if (prbUsage != null) { |
| 325 | sb.append("prbUsage: "); |
| 326 | prbUsage.appendAsString(sb, indentLevel + 1); |
| 327 | } else { |
| 328 | sb.append("prbUsage: <empty-required-field>"); |
| 329 | } |
| 330 | |
| 331 | sb.append(",\n"); |
| 332 | for (int i = 0; i < indentLevel + 1; i++) { |
| 333 | sb.append("\t"); |
| 334 | } |
| 335 | if (mcsDl != null) { |
| 336 | sb.append("mcsDl: "); |
| 337 | mcsDl.appendAsString(sb, indentLevel + 1); |
| 338 | } else { |
| 339 | sb.append("mcsDl: <empty-required-field>"); |
| 340 | } |
| 341 | |
| 342 | sb.append(",\n"); |
| 343 | for (int i = 0; i < indentLevel + 1; i++) { |
| 344 | sb.append("\t"); |
| 345 | } |
| 346 | if (numSchedTtisDl != null) { |
| 347 | sb.append("numSchedTtisDl: "); |
| 348 | numSchedTtisDl.appendAsString(sb, indentLevel + 1); |
| 349 | } else { |
| 350 | sb.append("numSchedTtisDl: <empty-required-field>"); |
| 351 | } |
| 352 | |
| 353 | sb.append(",\n"); |
| 354 | for (int i = 0; i < indentLevel + 1; i++) { |
| 355 | sb.append("\t"); |
| 356 | } |
| 357 | if (mcsUl != null) { |
| 358 | sb.append("mcsUl: "); |
| 359 | mcsUl.appendAsString(sb, indentLevel + 1); |
| 360 | } else { |
| 361 | sb.append("mcsUl: <empty-required-field>"); |
| 362 | } |
| 363 | |
| 364 | sb.append(",\n"); |
| 365 | for (int i = 0; i < indentLevel + 1; i++) { |
| 366 | sb.append("\t"); |
| 367 | } |
| 368 | if (numSchedTtisUl != null) { |
| 369 | sb.append("numSchedTtisUl: "); |
| 370 | numSchedTtisUl.appendAsString(sb, indentLevel + 1); |
| 371 | } else { |
| 372 | sb.append("numSchedTtisUl: <empty-required-field>"); |
| 373 | } |
| 374 | |
| 375 | sb.append(",\n"); |
| 376 | for (int i = 0; i < indentLevel + 1; i++) { |
| 377 | sb.append("\t"); |
| 378 | } |
| 379 | if (rankDl1 != null) { |
| 380 | sb.append("rankDl1: "); |
| 381 | rankDl1.appendAsString(sb, indentLevel + 1); |
| 382 | } else { |
| 383 | sb.append("rankDl1: <empty-required-field>"); |
| 384 | } |
| 385 | |
| 386 | sb.append(",\n"); |
| 387 | for (int i = 0; i < indentLevel + 1; i++) { |
| 388 | sb.append("\t"); |
| 389 | } |
| 390 | if (rankDl2 != null) { |
| 391 | sb.append("rankDl2: "); |
| 392 | rankDl2.appendAsString(sb, indentLevel + 1); |
| 393 | } else { |
| 394 | sb.append("rankDl2: <empty-required-field>"); |
| 395 | } |
| 396 | |
| 397 | sb.append("\n"); |
| 398 | for (int i = 0; i < indentLevel; i++) { |
| 399 | sb.append("\t"); |
| 400 | } |
| 401 | sb.append("}"); |
| 402 | } |
| 403 | |
| 404 | public static class QciVals implements Serializable { |
| 405 | |
| 406 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 407 | private static final long serialVersionUID = 1L; |
| 408 | @JsonIgnore |
| 409 | public byte[] code = null; |
| 410 | private List<QCI> seqOf = null; |
| 411 | |
| 412 | public QciVals() { |
| 413 | seqOf = new ArrayList<QCI>(); |
| 414 | } |
| 415 | |
| 416 | public QciVals(byte[] code) { |
| 417 | this.code = code; |
| 418 | } |
| 419 | |
| 420 | @JsonValue |
| 421 | public List<QCI> getQCI() { |
| 422 | if (seqOf == null) { |
| 423 | seqOf = new ArrayList<QCI>(); |
| 424 | } |
| 425 | return seqOf; |
| 426 | } |
| 427 | |
| 428 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 429 | return encode(os, true); |
| 430 | } |
| 431 | |
| 432 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 433 | |
| 434 | if (code != null) { |
| 435 | for (int i = code.length - 1; i >= 0; i--) { |
| 436 | os.write(code[i]); |
| 437 | } |
| 438 | if (withTag) { |
| 439 | return tag.encode(os) + code.length; |
| 440 | } |
| 441 | return code.length; |
| 442 | } |
| 443 | |
| 444 | int codeLength = 0; |
| 445 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 446 | codeLength += seqOf.get(i).encode(os, true); |
| 447 | } |
| 448 | |
| 449 | codeLength += BerLength.encodeLength(os, codeLength); |
| 450 | |
| 451 | if (withTag) { |
| 452 | codeLength += tag.encode(os); |
| 453 | } |
| 454 | |
| 455 | return codeLength; |
| 456 | } |
| 457 | |
| 458 | public int decode(InputStream is) throws IOException { |
| 459 | return decode(is, true); |
| 460 | } |
| 461 | |
| 462 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 463 | int codeLength = 0; |
| 464 | int subCodeLength = 0; |
| 465 | if (withTag) { |
| 466 | codeLength += tag.decodeAndCheck(is); |
| 467 | } |
| 468 | |
| 469 | BerLength length = new BerLength(); |
| 470 | codeLength += length.decode(is); |
| 471 | int totalLength = length.val; |
| 472 | |
| 473 | while (subCodeLength < totalLength) { |
| 474 | QCI element = new QCI(); |
| 475 | subCodeLength += element.decode(is, true); |
| 476 | seqOf.add(element); |
| 477 | } |
| 478 | if (subCodeLength != totalLength) { |
| 479 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 480 | |
| 481 | } |
| 482 | codeLength += subCodeLength; |
| 483 | |
| 484 | return codeLength; |
| 485 | } |
| 486 | |
| 487 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 488 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 489 | encode(os, false); |
| 490 | code = os.getArray(); |
| 491 | } |
| 492 | |
| 493 | public String toString() { |
| 494 | StringBuilder sb = new StringBuilder(); |
| 495 | appendAsString(sb, 0); |
| 496 | return sb.toString(); |
| 497 | } |
| 498 | |
| 499 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 500 | |
| 501 | sb.append("{\n"); |
| 502 | for (int i = 0; i < indentLevel + 1; i++) { |
| 503 | sb.append("\t"); |
| 504 | } |
| 505 | if (seqOf == null) { |
| 506 | sb.append("null"); |
| 507 | } else { |
| 508 | Iterator<QCI> it = seqOf.iterator(); |
| 509 | if (it.hasNext()) { |
| 510 | sb.append(it.next()); |
| 511 | while (it.hasNext()) { |
| 512 | sb.append(",\n"); |
| 513 | for (int i = 0; i < indentLevel + 1; i++) { |
| 514 | sb.append("\t"); |
| 515 | } |
| 516 | sb.append(it.next()); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | sb.append("\n"); |
| 522 | for (int i = 0; i < indentLevel; i++) { |
| 523 | sb.append("\t"); |
| 524 | } |
| 525 | sb.append("}"); |
| 526 | } |
| 527 | |
| 528 | } |
| 529 | |
| 530 | public static class McsDl implements Serializable { |
| 531 | |
| 532 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 533 | private static final long serialVersionUID = 1L; |
| 534 | @JsonIgnore |
| 535 | public byte[] code = null; |
| 536 | private List<BerInteger> seqOf = null; |
| 537 | |
| 538 | public McsDl() { |
| 539 | seqOf = new ArrayList<BerInteger>(); |
| 540 | } |
| 541 | |
| 542 | public McsDl(byte[] code) { |
| 543 | this.code = code; |
| 544 | } |
| 545 | |
| 546 | @JsonValue |
| 547 | public List<BerInteger> getBerInteger() { |
| 548 | if (seqOf == null) { |
| 549 | seqOf = new ArrayList<BerInteger>(); |
| 550 | } |
| 551 | return seqOf; |
| 552 | } |
| 553 | |
| 554 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 555 | return encode(os, true); |
| 556 | } |
| 557 | |
| 558 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 559 | |
| 560 | if (code != null) { |
| 561 | for (int i = code.length - 1; i >= 0; i--) { |
| 562 | os.write(code[i]); |
| 563 | } |
| 564 | if (withTag) { |
| 565 | return tag.encode(os) + code.length; |
| 566 | } |
| 567 | return code.length; |
| 568 | } |
| 569 | |
| 570 | int codeLength = 0; |
| 571 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 572 | codeLength += seqOf.get(i).encode(os, true); |
| 573 | } |
| 574 | |
| 575 | codeLength += BerLength.encodeLength(os, codeLength); |
| 576 | |
| 577 | if (withTag) { |
| 578 | codeLength += tag.encode(os); |
| 579 | } |
| 580 | |
| 581 | return codeLength; |
| 582 | } |
| 583 | |
| 584 | public int decode(InputStream is) throws IOException { |
| 585 | return decode(is, true); |
| 586 | } |
| 587 | |
| 588 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 589 | int codeLength = 0; |
| 590 | int subCodeLength = 0; |
| 591 | if (withTag) { |
| 592 | codeLength += tag.decodeAndCheck(is); |
| 593 | } |
| 594 | |
| 595 | BerLength length = new BerLength(); |
| 596 | codeLength += length.decode(is); |
| 597 | int totalLength = length.val; |
| 598 | |
| 599 | while (subCodeLength < totalLength) { |
| 600 | BerInteger element = new BerInteger(); |
| 601 | subCodeLength += element.decode(is, true); |
| 602 | seqOf.add(element); |
| 603 | } |
| 604 | if (subCodeLength != totalLength) { |
| 605 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 606 | |
| 607 | } |
| 608 | codeLength += subCodeLength; |
| 609 | |
| 610 | return codeLength; |
| 611 | } |
| 612 | |
| 613 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 614 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 615 | encode(os, false); |
| 616 | code = os.getArray(); |
| 617 | } |
| 618 | |
| 619 | public String toString() { |
| 620 | StringBuilder sb = new StringBuilder(); |
| 621 | appendAsString(sb, 0); |
| 622 | return sb.toString(); |
| 623 | } |
| 624 | |
| 625 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 626 | |
| 627 | sb.append("{\n"); |
| 628 | for (int i = 0; i < indentLevel + 1; i++) { |
| 629 | sb.append("\t"); |
| 630 | } |
| 631 | if (seqOf == null) { |
| 632 | sb.append("null"); |
| 633 | } else { |
| 634 | Iterator<BerInteger> it = seqOf.iterator(); |
| 635 | if (it.hasNext()) { |
| 636 | sb.append(it.next()); |
| 637 | while (it.hasNext()) { |
| 638 | sb.append(",\n"); |
| 639 | for (int i = 0; i < indentLevel + 1; i++) { |
| 640 | sb.append("\t"); |
| 641 | } |
| 642 | sb.append(it.next()); |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | sb.append("\n"); |
| 648 | for (int i = 0; i < indentLevel; i++) { |
| 649 | sb.append("\t"); |
| 650 | } |
| 651 | sb.append("}"); |
| 652 | } |
| 653 | |
| 654 | } |
| 655 | |
| 656 | public static class NumSchedTtisDl implements Serializable { |
| 657 | |
| 658 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 659 | private static final long serialVersionUID = 1L; |
| 660 | @JsonIgnore |
| 661 | public byte[] code = null; |
| 662 | private List<BerInteger> seqOf = null; |
| 663 | |
| 664 | public NumSchedTtisDl() { |
| 665 | seqOf = new ArrayList<BerInteger>(); |
| 666 | } |
| 667 | |
| 668 | public NumSchedTtisDl(byte[] code) { |
| 669 | this.code = code; |
| 670 | } |
| 671 | |
| 672 | @JsonValue |
| 673 | public List<BerInteger> getBerInteger() { |
| 674 | if (seqOf == null) { |
| 675 | seqOf = new ArrayList<BerInteger>(); |
| 676 | } |
| 677 | return seqOf; |
| 678 | } |
| 679 | |
| 680 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 681 | return encode(os, true); |
| 682 | } |
| 683 | |
| 684 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 685 | |
| 686 | if (code != null) { |
| 687 | for (int i = code.length - 1; i >= 0; i--) { |
| 688 | os.write(code[i]); |
| 689 | } |
| 690 | if (withTag) { |
| 691 | return tag.encode(os) + code.length; |
| 692 | } |
| 693 | return code.length; |
| 694 | } |
| 695 | |
| 696 | int codeLength = 0; |
| 697 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 698 | codeLength += seqOf.get(i).encode(os, true); |
| 699 | } |
| 700 | |
| 701 | codeLength += BerLength.encodeLength(os, codeLength); |
| 702 | |
| 703 | if (withTag) { |
| 704 | codeLength += tag.encode(os); |
| 705 | } |
| 706 | |
| 707 | return codeLength; |
| 708 | } |
| 709 | |
| 710 | public int decode(InputStream is) throws IOException { |
| 711 | return decode(is, true); |
| 712 | } |
| 713 | |
| 714 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 715 | int codeLength = 0; |
| 716 | int subCodeLength = 0; |
| 717 | if (withTag) { |
| 718 | codeLength += tag.decodeAndCheck(is); |
| 719 | } |
| 720 | |
| 721 | BerLength length = new BerLength(); |
| 722 | codeLength += length.decode(is); |
| 723 | int totalLength = length.val; |
| 724 | |
| 725 | while (subCodeLength < totalLength) { |
| 726 | BerInteger element = new BerInteger(); |
| 727 | subCodeLength += element.decode(is, true); |
| 728 | seqOf.add(element); |
| 729 | } |
| 730 | if (subCodeLength != totalLength) { |
| 731 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 732 | |
| 733 | } |
| 734 | codeLength += subCodeLength; |
| 735 | |
| 736 | return codeLength; |
| 737 | } |
| 738 | |
| 739 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 740 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 741 | encode(os, false); |
| 742 | code = os.getArray(); |
| 743 | } |
| 744 | |
| 745 | public String toString() { |
| 746 | StringBuilder sb = new StringBuilder(); |
| 747 | appendAsString(sb, 0); |
| 748 | return sb.toString(); |
| 749 | } |
| 750 | |
| 751 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 752 | |
| 753 | sb.append("{\n"); |
| 754 | for (int i = 0; i < indentLevel + 1; i++) { |
| 755 | sb.append("\t"); |
| 756 | } |
| 757 | if (seqOf == null) { |
| 758 | sb.append("null"); |
| 759 | } else { |
| 760 | Iterator<BerInteger> it = seqOf.iterator(); |
| 761 | if (it.hasNext()) { |
| 762 | sb.append(it.next()); |
| 763 | while (it.hasNext()) { |
| 764 | sb.append(",\n"); |
| 765 | for (int i = 0; i < indentLevel + 1; i++) { |
| 766 | sb.append("\t"); |
| 767 | } |
| 768 | sb.append(it.next()); |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | sb.append("\n"); |
| 774 | for (int i = 0; i < indentLevel; i++) { |
| 775 | sb.append("\t"); |
| 776 | } |
| 777 | sb.append("}"); |
| 778 | } |
| 779 | |
| 780 | } |
| 781 | |
| 782 | public static class McsUl implements Serializable { |
| 783 | |
| 784 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 785 | private static final long serialVersionUID = 1L; |
| 786 | @JsonIgnore |
| 787 | public byte[] code = null; |
| 788 | private List<BerInteger> seqOf = null; |
| 789 | |
| 790 | public McsUl() { |
| 791 | seqOf = new ArrayList<BerInteger>(); |
| 792 | } |
| 793 | |
| 794 | public McsUl(byte[] code) { |
| 795 | this.code = code; |
| 796 | } |
| 797 | |
| 798 | @JsonValue |
| 799 | public List<BerInteger> getBerInteger() { |
| 800 | if (seqOf == null) { |
| 801 | seqOf = new ArrayList<BerInteger>(); |
| 802 | } |
| 803 | return seqOf; |
| 804 | } |
| 805 | |
| 806 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 807 | return encode(os, true); |
| 808 | } |
| 809 | |
| 810 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 811 | |
| 812 | if (code != null) { |
| 813 | for (int i = code.length - 1; i >= 0; i--) { |
| 814 | os.write(code[i]); |
| 815 | } |
| 816 | if (withTag) { |
| 817 | return tag.encode(os) + code.length; |
| 818 | } |
| 819 | return code.length; |
| 820 | } |
| 821 | |
| 822 | int codeLength = 0; |
| 823 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 824 | codeLength += seqOf.get(i).encode(os, true); |
| 825 | } |
| 826 | |
| 827 | codeLength += BerLength.encodeLength(os, codeLength); |
| 828 | |
| 829 | if (withTag) { |
| 830 | codeLength += tag.encode(os); |
| 831 | } |
| 832 | |
| 833 | return codeLength; |
| 834 | } |
| 835 | |
| 836 | public int decode(InputStream is) throws IOException { |
| 837 | return decode(is, true); |
| 838 | } |
| 839 | |
| 840 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 841 | int codeLength = 0; |
| 842 | int subCodeLength = 0; |
| 843 | if (withTag) { |
| 844 | codeLength += tag.decodeAndCheck(is); |
| 845 | } |
| 846 | |
| 847 | BerLength length = new BerLength(); |
| 848 | codeLength += length.decode(is); |
| 849 | int totalLength = length.val; |
| 850 | |
| 851 | while (subCodeLength < totalLength) { |
| 852 | BerInteger element = new BerInteger(); |
| 853 | subCodeLength += element.decode(is, true); |
| 854 | seqOf.add(element); |
| 855 | } |
| 856 | if (subCodeLength != totalLength) { |
| 857 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 858 | |
| 859 | } |
| 860 | codeLength += subCodeLength; |
| 861 | |
| 862 | return codeLength; |
| 863 | } |
| 864 | |
| 865 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 866 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 867 | encode(os, false); |
| 868 | code = os.getArray(); |
| 869 | } |
| 870 | |
| 871 | public String toString() { |
| 872 | StringBuilder sb = new StringBuilder(); |
| 873 | appendAsString(sb, 0); |
| 874 | return sb.toString(); |
| 875 | } |
| 876 | |
| 877 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 878 | |
| 879 | sb.append("{\n"); |
| 880 | for (int i = 0; i < indentLevel + 1; i++) { |
| 881 | sb.append("\t"); |
| 882 | } |
| 883 | if (seqOf == null) { |
| 884 | sb.append("null"); |
| 885 | } else { |
| 886 | Iterator<BerInteger> it = seqOf.iterator(); |
| 887 | if (it.hasNext()) { |
| 888 | sb.append(it.next()); |
| 889 | while (it.hasNext()) { |
| 890 | sb.append(",\n"); |
| 891 | for (int i = 0; i < indentLevel + 1; i++) { |
| 892 | sb.append("\t"); |
| 893 | } |
| 894 | sb.append(it.next()); |
| 895 | } |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | sb.append("\n"); |
| 900 | for (int i = 0; i < indentLevel; i++) { |
| 901 | sb.append("\t"); |
| 902 | } |
| 903 | sb.append("}"); |
| 904 | } |
| 905 | |
| 906 | } |
| 907 | |
| 908 | public static class NumSchedTtisUl implements Serializable { |
| 909 | |
| 910 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 911 | private static final long serialVersionUID = 1L; |
| 912 | @JsonIgnore |
| 913 | public byte[] code = null; |
| 914 | private List<BerInteger> seqOf = null; |
| 915 | |
| 916 | public NumSchedTtisUl() { |
| 917 | seqOf = new ArrayList<BerInteger>(); |
| 918 | } |
| 919 | |
| 920 | public NumSchedTtisUl(byte[] code) { |
| 921 | this.code = code; |
| 922 | } |
| 923 | |
| 924 | @JsonValue |
| 925 | public List<BerInteger> getBerInteger() { |
| 926 | if (seqOf == null) { |
| 927 | seqOf = new ArrayList<BerInteger>(); |
| 928 | } |
| 929 | return seqOf; |
| 930 | } |
| 931 | |
| 932 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 933 | return encode(os, true); |
| 934 | } |
| 935 | |
| 936 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 937 | |
| 938 | if (code != null) { |
| 939 | for (int i = code.length - 1; i >= 0; i--) { |
| 940 | os.write(code[i]); |
| 941 | } |
| 942 | if (withTag) { |
| 943 | return tag.encode(os) + code.length; |
| 944 | } |
| 945 | return code.length; |
| 946 | } |
| 947 | |
| 948 | int codeLength = 0; |
| 949 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 950 | codeLength += seqOf.get(i).encode(os, true); |
| 951 | } |
| 952 | |
| 953 | codeLength += BerLength.encodeLength(os, codeLength); |
| 954 | |
| 955 | if (withTag) { |
| 956 | codeLength += tag.encode(os); |
| 957 | } |
| 958 | |
| 959 | return codeLength; |
| 960 | } |
| 961 | |
| 962 | public int decode(InputStream is) throws IOException { |
| 963 | return decode(is, true); |
| 964 | } |
| 965 | |
| 966 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 967 | int codeLength = 0; |
| 968 | int subCodeLength = 0; |
| 969 | if (withTag) { |
| 970 | codeLength += tag.decodeAndCheck(is); |
| 971 | } |
| 972 | |
| 973 | BerLength length = new BerLength(); |
| 974 | codeLength += length.decode(is); |
| 975 | int totalLength = length.val; |
| 976 | |
| 977 | while (subCodeLength < totalLength) { |
| 978 | BerInteger element = new BerInteger(); |
| 979 | subCodeLength += element.decode(is, true); |
| 980 | seqOf.add(element); |
| 981 | } |
| 982 | if (subCodeLength != totalLength) { |
| 983 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 984 | |
| 985 | } |
| 986 | codeLength += subCodeLength; |
| 987 | |
| 988 | return codeLength; |
| 989 | } |
| 990 | |
| 991 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 992 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 993 | encode(os, false); |
| 994 | code = os.getArray(); |
| 995 | } |
| 996 | |
| 997 | public String toString() { |
| 998 | StringBuilder sb = new StringBuilder(); |
| 999 | appendAsString(sb, 0); |
| 1000 | return sb.toString(); |
| 1001 | } |
| 1002 | |
| 1003 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 1004 | |
| 1005 | sb.append("{\n"); |
| 1006 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1007 | sb.append("\t"); |
| 1008 | } |
| 1009 | if (seqOf == null) { |
| 1010 | sb.append("null"); |
| 1011 | } else { |
| 1012 | Iterator<BerInteger> it = seqOf.iterator(); |
| 1013 | if (it.hasNext()) { |
| 1014 | sb.append(it.next()); |
| 1015 | while (it.hasNext()) { |
| 1016 | sb.append(",\n"); |
| 1017 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1018 | sb.append("\t"); |
| 1019 | } |
| 1020 | sb.append(it.next()); |
| 1021 | } |
| 1022 | } |
| 1023 | } |
| 1024 | |
| 1025 | sb.append("\n"); |
| 1026 | for (int i = 0; i < indentLevel; i++) { |
| 1027 | sb.append("\t"); |
| 1028 | } |
| 1029 | sb.append("}"); |
| 1030 | } |
| 1031 | |
| 1032 | } |
| 1033 | |
| 1034 | public static class RankDl1 implements Serializable { |
| 1035 | |
| 1036 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 1037 | private static final long serialVersionUID = 1L; |
| 1038 | @JsonIgnore |
| 1039 | public byte[] code = null; |
| 1040 | private List<BerInteger> seqOf = null; |
| 1041 | |
| 1042 | public RankDl1() { |
| 1043 | seqOf = new ArrayList<BerInteger>(); |
| 1044 | } |
| 1045 | |
| 1046 | public RankDl1(byte[] code) { |
| 1047 | this.code = code; |
| 1048 | } |
| 1049 | |
| 1050 | @JsonValue |
| 1051 | public List<BerInteger> getBerInteger() { |
| 1052 | if (seqOf == null) { |
| 1053 | seqOf = new ArrayList<BerInteger>(); |
| 1054 | } |
| 1055 | return seqOf; |
| 1056 | } |
| 1057 | |
| 1058 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1059 | return encode(os, true); |
| 1060 | } |
| 1061 | |
| 1062 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 1063 | |
| 1064 | if (code != null) { |
| 1065 | for (int i = code.length - 1; i >= 0; i--) { |
| 1066 | os.write(code[i]); |
| 1067 | } |
| 1068 | if (withTag) { |
| 1069 | return tag.encode(os) + code.length; |
| 1070 | } |
| 1071 | return code.length; |
| 1072 | } |
| 1073 | |
| 1074 | int codeLength = 0; |
| 1075 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1076 | codeLength += seqOf.get(i).encode(os, true); |
| 1077 | } |
| 1078 | |
| 1079 | codeLength += BerLength.encodeLength(os, codeLength); |
| 1080 | |
| 1081 | if (withTag) { |
| 1082 | codeLength += tag.encode(os); |
| 1083 | } |
| 1084 | |
| 1085 | return codeLength; |
| 1086 | } |
| 1087 | |
| 1088 | public int decode(InputStream is) throws IOException { |
| 1089 | return decode(is, true); |
| 1090 | } |
| 1091 | |
| 1092 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1093 | int codeLength = 0; |
| 1094 | int subCodeLength = 0; |
| 1095 | if (withTag) { |
| 1096 | codeLength += tag.decodeAndCheck(is); |
| 1097 | } |
| 1098 | |
| 1099 | BerLength length = new BerLength(); |
| 1100 | codeLength += length.decode(is); |
| 1101 | int totalLength = length.val; |
| 1102 | |
| 1103 | while (subCodeLength < totalLength) { |
| 1104 | BerInteger element = new BerInteger(); |
| 1105 | subCodeLength += element.decode(is, true); |
| 1106 | seqOf.add(element); |
| 1107 | } |
| 1108 | if (subCodeLength != totalLength) { |
| 1109 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 1110 | |
| 1111 | } |
| 1112 | codeLength += subCodeLength; |
| 1113 | |
| 1114 | return codeLength; |
| 1115 | } |
| 1116 | |
| 1117 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1118 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1119 | encode(os, false); |
| 1120 | code = os.getArray(); |
| 1121 | } |
| 1122 | |
| 1123 | public String toString() { |
| 1124 | StringBuilder sb = new StringBuilder(); |
| 1125 | appendAsString(sb, 0); |
| 1126 | return sb.toString(); |
| 1127 | } |
| 1128 | |
| 1129 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 1130 | |
| 1131 | sb.append("{\n"); |
| 1132 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1133 | sb.append("\t"); |
| 1134 | } |
| 1135 | if (seqOf == null) { |
| 1136 | sb.append("null"); |
| 1137 | } else { |
| 1138 | Iterator<BerInteger> it = seqOf.iterator(); |
| 1139 | if (it.hasNext()) { |
| 1140 | sb.append(it.next()); |
| 1141 | while (it.hasNext()) { |
| 1142 | sb.append(",\n"); |
| 1143 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1144 | sb.append("\t"); |
| 1145 | } |
| 1146 | sb.append(it.next()); |
| 1147 | } |
| 1148 | } |
| 1149 | } |
| 1150 | |
| 1151 | sb.append("\n"); |
| 1152 | for (int i = 0; i < indentLevel; i++) { |
| 1153 | sb.append("\t"); |
| 1154 | } |
| 1155 | sb.append("}"); |
| 1156 | } |
| 1157 | |
| 1158 | } |
| 1159 | |
| 1160 | public static class RankDl2 implements Serializable { |
| 1161 | |
| 1162 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 1163 | private static final long serialVersionUID = 1L; |
| 1164 | @JsonIgnore |
| 1165 | public byte[] code = null; |
| 1166 | private List<BerInteger> seqOf = null; |
| 1167 | |
| 1168 | public RankDl2() { |
| 1169 | seqOf = new ArrayList<BerInteger>(); |
| 1170 | } |
| 1171 | |
| 1172 | public RankDl2(byte[] code) { |
| 1173 | this.code = code; |
| 1174 | } |
| 1175 | |
| 1176 | @JsonValue |
| 1177 | public List<BerInteger> getBerInteger() { |
| 1178 | if (seqOf == null) { |
| 1179 | seqOf = new ArrayList<BerInteger>(); |
| 1180 | } |
| 1181 | return seqOf; |
| 1182 | } |
| 1183 | |
| 1184 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1185 | return encode(os, true); |
| 1186 | } |
| 1187 | |
| 1188 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 1189 | |
| 1190 | if (code != null) { |
| 1191 | for (int i = code.length - 1; i >= 0; i--) { |
| 1192 | os.write(code[i]); |
| 1193 | } |
| 1194 | if (withTag) { |
| 1195 | return tag.encode(os) + code.length; |
| 1196 | } |
| 1197 | return code.length; |
| 1198 | } |
| 1199 | |
| 1200 | int codeLength = 0; |
| 1201 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1202 | codeLength += seqOf.get(i).encode(os, true); |
| 1203 | } |
| 1204 | |
| 1205 | codeLength += BerLength.encodeLength(os, codeLength); |
| 1206 | |
| 1207 | if (withTag) { |
| 1208 | codeLength += tag.encode(os); |
| 1209 | } |
| 1210 | |
| 1211 | return codeLength; |
| 1212 | } |
| 1213 | |
| 1214 | public int decode(InputStream is) throws IOException { |
| 1215 | return decode(is, true); |
| 1216 | } |
| 1217 | |
| 1218 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1219 | int codeLength = 0; |
| 1220 | int subCodeLength = 0; |
| 1221 | if (withTag) { |
| 1222 | codeLength += tag.decodeAndCheck(is); |
| 1223 | } |
| 1224 | |
| 1225 | BerLength length = new BerLength(); |
| 1226 | codeLength += length.decode(is); |
| 1227 | int totalLength = length.val; |
| 1228 | |
| 1229 | while (subCodeLength < totalLength) { |
| 1230 | BerInteger element = new BerInteger(); |
| 1231 | subCodeLength += element.decode(is, true); |
| 1232 | seqOf.add(element); |
| 1233 | } |
| 1234 | if (subCodeLength != totalLength) { |
| 1235 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 1236 | |
| 1237 | } |
| 1238 | codeLength += subCodeLength; |
| 1239 | |
| 1240 | return codeLength; |
| 1241 | } |
| 1242 | |
| 1243 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1244 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1245 | encode(os, false); |
| 1246 | code = os.getArray(); |
| 1247 | } |
| 1248 | |
| 1249 | public String toString() { |
| 1250 | StringBuilder sb = new StringBuilder(); |
| 1251 | appendAsString(sb, 0); |
| 1252 | return sb.toString(); |
| 1253 | } |
| 1254 | |
| 1255 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 1256 | |
| 1257 | sb.append("{\n"); |
| 1258 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1259 | sb.append("\t"); |
| 1260 | } |
| 1261 | if (seqOf == null) { |
| 1262 | sb.append("null"); |
| 1263 | } else { |
| 1264 | Iterator<BerInteger> it = seqOf.iterator(); |
| 1265 | if (it.hasNext()) { |
| 1266 | sb.append(it.next()); |
| 1267 | while (it.hasNext()) { |
| 1268 | sb.append(",\n"); |
| 1269 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1270 | sb.append("\t"); |
| 1271 | } |
| 1272 | sb.append(it.next()); |
| 1273 | } |
| 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | sb.append("\n"); |
| 1278 | for (int i = 0; i < indentLevel; i++) { |
| 1279 | sb.append("\t"); |
| 1280 | } |
| 1281 | sb.append("}"); |
| 1282 | } |
| 1283 | |
| 1284 | } |
| 1285 | |
| 1286 | } |
| 1287 | |