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 RadioRepPerServCell 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 CqiHist cqiHist = null; |
| 30 | private RiHist riHist = null; |
| 31 | private PuschSinrHist puschSinrHist = null; |
| 32 | private PucchSinrHist pucchSinrHist = null; |
| 33 | public RadioRepPerServCell() { |
| 34 | } |
| 35 | public RadioRepPerServCell(byte[] code) { |
| 36 | this.code = code; |
| 37 | } |
| 38 | |
| 39 | public ECGI getEcgi() { |
| 40 | return ecgi; |
| 41 | } |
| 42 | |
| 43 | public void setEcgi(ECGI ecgi) { |
| 44 | this.ecgi = ecgi; |
| 45 | } |
| 46 | |
| 47 | public CqiHist getCqiHist() { |
| 48 | return cqiHist; |
| 49 | } |
| 50 | |
| 51 | public void setCqiHist(CqiHist cqiHist) { |
| 52 | this.cqiHist = cqiHist; |
| 53 | } |
| 54 | |
| 55 | public RiHist getRiHist() { |
| 56 | return riHist; |
| 57 | } |
| 58 | |
| 59 | public void setRiHist(RiHist riHist) { |
| 60 | this.riHist = riHist; |
| 61 | } |
| 62 | |
| 63 | public PuschSinrHist getPuschSinrHist() { |
| 64 | return puschSinrHist; |
| 65 | } |
| 66 | |
| 67 | public void setPuschSinrHist(PuschSinrHist puschSinrHist) { |
| 68 | this.puschSinrHist = puschSinrHist; |
| 69 | } |
| 70 | |
| 71 | public PucchSinrHist getPucchSinrHist() { |
| 72 | return pucchSinrHist; |
| 73 | } |
| 74 | |
| 75 | public void setPucchSinrHist(PucchSinrHist pucchSinrHist) { |
| 76 | this.pucchSinrHist = pucchSinrHist; |
| 77 | } |
| 78 | |
| 79 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 80 | return encode(os, true); |
| 81 | } |
| 82 | |
| 83 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 84 | |
| 85 | if (code != null) { |
| 86 | for (int i = code.length - 1; i >= 0; i--) { |
| 87 | os.write(code[i]); |
| 88 | } |
| 89 | if (withTag) { |
| 90 | return tag.encode(os) + code.length; |
| 91 | } |
| 92 | return code.length; |
| 93 | } |
| 94 | |
| 95 | int codeLength = 0; |
| 96 | codeLength += pucchSinrHist.encode(os, false); |
| 97 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 4 |
| 98 | os.write(0xA4); |
| 99 | codeLength += 1; |
| 100 | |
| 101 | codeLength += puschSinrHist.encode(os, false); |
| 102 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 3 |
| 103 | os.write(0xA3); |
| 104 | codeLength += 1; |
| 105 | |
| 106 | codeLength += riHist.encode(os, false); |
| 107 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 108 | os.write(0xA2); |
| 109 | codeLength += 1; |
| 110 | |
| 111 | codeLength += cqiHist.encode(os, false); |
| 112 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 113 | os.write(0xA1); |
| 114 | codeLength += 1; |
| 115 | |
| 116 | codeLength += ecgi.encode(os, false); |
| 117 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 118 | os.write(0xA0); |
| 119 | codeLength += 1; |
| 120 | |
| 121 | codeLength += BerLength.encodeLength(os, codeLength); |
| 122 | |
| 123 | if (withTag) { |
| 124 | codeLength += tag.encode(os); |
| 125 | } |
| 126 | |
| 127 | return codeLength; |
| 128 | |
| 129 | } |
| 130 | |
| 131 | public int decode(InputStream is) throws IOException { |
| 132 | return decode(is, true); |
| 133 | } |
| 134 | |
| 135 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 136 | int codeLength = 0; |
| 137 | int subCodeLength = 0; |
| 138 | BerTag berTag = new BerTag(); |
| 139 | |
| 140 | if (withTag) { |
| 141 | codeLength += tag.decodeAndCheck(is); |
| 142 | } |
| 143 | |
| 144 | BerLength length = new BerLength(); |
| 145 | codeLength += length.decode(is); |
| 146 | |
| 147 | int totalLength = length.val; |
| 148 | codeLength += totalLength; |
| 149 | |
| 150 | subCodeLength += berTag.decode(is); |
| 151 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 152 | ecgi = new ECGI(); |
| 153 | subCodeLength += ecgi.decode(is, false); |
| 154 | subCodeLength += berTag.decode(is); |
| 155 | } else { |
| 156 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 157 | } |
| 158 | |
| 159 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 160 | cqiHist = new CqiHist(); |
| 161 | subCodeLength += cqiHist.decode(is, false); |
| 162 | subCodeLength += berTag.decode(is); |
| 163 | } else { |
| 164 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 165 | } |
| 166 | |
| 167 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 168 | riHist = new RiHist(); |
| 169 | subCodeLength += riHist.decode(is, false); |
| 170 | subCodeLength += berTag.decode(is); |
| 171 | } else { |
| 172 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 173 | } |
| 174 | |
| 175 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) { |
| 176 | puschSinrHist = new PuschSinrHist(); |
| 177 | subCodeLength += puschSinrHist.decode(is, false); |
| 178 | subCodeLength += berTag.decode(is); |
| 179 | } else { |
| 180 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 181 | } |
| 182 | |
| 183 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { |
| 184 | pucchSinrHist = new PucchSinrHist(); |
| 185 | subCodeLength += pucchSinrHist.decode(is, false); |
| 186 | if (subCodeLength == totalLength) { |
| 187 | return codeLength; |
| 188 | } |
| 189 | } |
| 190 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 191 | |
| 192 | |
| 193 | } |
| 194 | |
| 195 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 196 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 197 | encode(os, false); |
| 198 | code = os.getArray(); |
| 199 | } |
| 200 | |
| 201 | public String toString() { |
| 202 | StringBuilder sb = new StringBuilder(); |
| 203 | appendAsString(sb, 0); |
| 204 | return sb.toString(); |
| 205 | } |
| 206 | |
| 207 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 208 | |
| 209 | sb.append("{"); |
| 210 | sb.append("\n"); |
| 211 | for (int i = 0; i < indentLevel + 1; i++) { |
| 212 | sb.append("\t"); |
| 213 | } |
| 214 | if (ecgi != null) { |
| 215 | sb.append("ecgi: "); |
| 216 | ecgi.appendAsString(sb, indentLevel + 1); |
| 217 | } else { |
| 218 | sb.append("ecgi: <empty-required-field>"); |
| 219 | } |
| 220 | |
| 221 | sb.append(",\n"); |
| 222 | for (int i = 0; i < indentLevel + 1; i++) { |
| 223 | sb.append("\t"); |
| 224 | } |
| 225 | if (cqiHist != null) { |
| 226 | sb.append("cqiHist: "); |
| 227 | cqiHist.appendAsString(sb, indentLevel + 1); |
| 228 | } else { |
| 229 | sb.append("cqiHist: <empty-required-field>"); |
| 230 | } |
| 231 | |
| 232 | sb.append(",\n"); |
| 233 | for (int i = 0; i < indentLevel + 1; i++) { |
| 234 | sb.append("\t"); |
| 235 | } |
| 236 | if (riHist != null) { |
| 237 | sb.append("riHist: "); |
| 238 | riHist.appendAsString(sb, indentLevel + 1); |
| 239 | } else { |
| 240 | sb.append("riHist: <empty-required-field>"); |
| 241 | } |
| 242 | |
| 243 | sb.append(",\n"); |
| 244 | for (int i = 0; i < indentLevel + 1; i++) { |
| 245 | sb.append("\t"); |
| 246 | } |
| 247 | if (puschSinrHist != null) { |
| 248 | sb.append("puschSinrHist: "); |
| 249 | puschSinrHist.appendAsString(sb, indentLevel + 1); |
| 250 | } else { |
| 251 | sb.append("puschSinrHist: <empty-required-field>"); |
| 252 | } |
| 253 | |
| 254 | sb.append(",\n"); |
| 255 | for (int i = 0; i < indentLevel + 1; i++) { |
| 256 | sb.append("\t"); |
| 257 | } |
| 258 | if (pucchSinrHist != null) { |
| 259 | sb.append("pucchSinrHist: "); |
| 260 | pucchSinrHist.appendAsString(sb, indentLevel + 1); |
| 261 | } else { |
| 262 | sb.append("pucchSinrHist: <empty-required-field>"); |
| 263 | } |
| 264 | |
| 265 | sb.append("\n"); |
| 266 | for (int i = 0; i < indentLevel; i++) { |
| 267 | sb.append("\t"); |
| 268 | } |
| 269 | sb.append("}"); |
| 270 | } |
| 271 | |
| 272 | public static class CqiHist implements Serializable { |
| 273 | |
| 274 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 275 | private static final long serialVersionUID = 1L; |
| 276 | @JsonIgnore |
| 277 | public byte[] code = null; |
| 278 | private List<BerInteger> seqOf = null; |
| 279 | |
| 280 | public CqiHist() { |
| 281 | seqOf = new ArrayList<BerInteger>(); |
| 282 | } |
| 283 | |
| 284 | public CqiHist(byte[] code) { |
| 285 | this.code = code; |
| 286 | } |
| 287 | |
| 288 | @JsonValue |
| 289 | public List<BerInteger> getBerInteger() { |
| 290 | if (seqOf == null) { |
| 291 | seqOf = new ArrayList<BerInteger>(); |
| 292 | } |
| 293 | return seqOf; |
| 294 | } |
| 295 | |
| 296 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 297 | return encode(os, true); |
| 298 | } |
| 299 | |
| 300 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 301 | |
| 302 | if (code != null) { |
| 303 | for (int i = code.length - 1; i >= 0; i--) { |
| 304 | os.write(code[i]); |
| 305 | } |
| 306 | if (withTag) { |
| 307 | return tag.encode(os) + code.length; |
| 308 | } |
| 309 | return code.length; |
| 310 | } |
| 311 | |
| 312 | int codeLength = 0; |
| 313 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 314 | codeLength += seqOf.get(i).encode(os, true); |
| 315 | } |
| 316 | |
| 317 | codeLength += BerLength.encodeLength(os, codeLength); |
| 318 | |
| 319 | if (withTag) { |
| 320 | codeLength += tag.encode(os); |
| 321 | } |
| 322 | |
| 323 | return codeLength; |
| 324 | } |
| 325 | |
| 326 | public int decode(InputStream is) throws IOException { |
| 327 | return decode(is, true); |
| 328 | } |
| 329 | |
| 330 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 331 | int codeLength = 0; |
| 332 | int subCodeLength = 0; |
| 333 | if (withTag) { |
| 334 | codeLength += tag.decodeAndCheck(is); |
| 335 | } |
| 336 | |
| 337 | BerLength length = new BerLength(); |
| 338 | codeLength += length.decode(is); |
| 339 | int totalLength = length.val; |
| 340 | |
| 341 | while (subCodeLength < totalLength) { |
| 342 | BerInteger element = new BerInteger(); |
| 343 | subCodeLength += element.decode(is, true); |
| 344 | seqOf.add(element); |
| 345 | } |
| 346 | if (subCodeLength != totalLength) { |
| 347 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 348 | |
| 349 | } |
| 350 | codeLength += subCodeLength; |
| 351 | |
| 352 | return codeLength; |
| 353 | } |
| 354 | |
| 355 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 356 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 357 | encode(os, false); |
| 358 | code = os.getArray(); |
| 359 | } |
| 360 | |
| 361 | public String toString() { |
| 362 | StringBuilder sb = new StringBuilder(); |
| 363 | appendAsString(sb, 0); |
| 364 | return sb.toString(); |
| 365 | } |
| 366 | |
| 367 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 368 | |
| 369 | sb.append("{\n"); |
| 370 | for (int i = 0; i < indentLevel + 1; i++) { |
| 371 | sb.append("\t"); |
| 372 | } |
| 373 | if (seqOf == null) { |
| 374 | sb.append("null"); |
| 375 | } else { |
| 376 | Iterator<BerInteger> it = seqOf.iterator(); |
| 377 | if (it.hasNext()) { |
| 378 | sb.append(it.next()); |
| 379 | while (it.hasNext()) { |
| 380 | sb.append(",\n"); |
| 381 | for (int i = 0; i < indentLevel + 1; i++) { |
| 382 | sb.append("\t"); |
| 383 | } |
| 384 | sb.append(it.next()); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | sb.append("\n"); |
| 390 | for (int i = 0; i < indentLevel; i++) { |
| 391 | sb.append("\t"); |
| 392 | } |
| 393 | sb.append("}"); |
| 394 | } |
| 395 | |
| 396 | } |
| 397 | |
| 398 | public static class RiHist implements Serializable { |
| 399 | |
| 400 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 401 | private static final long serialVersionUID = 1L; |
| 402 | @JsonIgnore |
| 403 | public byte[] code = null; |
| 404 | private List<BerInteger> seqOf = null; |
| 405 | |
| 406 | public RiHist() { |
| 407 | seqOf = new ArrayList<BerInteger>(); |
| 408 | } |
| 409 | |
| 410 | public RiHist(byte[] code) { |
| 411 | this.code = code; |
| 412 | } |
| 413 | |
| 414 | @JsonValue |
| 415 | public List<BerInteger> getBerInteger() { |
| 416 | if (seqOf == null) { |
| 417 | seqOf = new ArrayList<BerInteger>(); |
| 418 | } |
| 419 | return seqOf; |
| 420 | } |
| 421 | |
| 422 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 423 | return encode(os, true); |
| 424 | } |
| 425 | |
| 426 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 427 | |
| 428 | if (code != null) { |
| 429 | for (int i = code.length - 1; i >= 0; i--) { |
| 430 | os.write(code[i]); |
| 431 | } |
| 432 | if (withTag) { |
| 433 | return tag.encode(os) + code.length; |
| 434 | } |
| 435 | return code.length; |
| 436 | } |
| 437 | |
| 438 | int codeLength = 0; |
| 439 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 440 | codeLength += seqOf.get(i).encode(os, true); |
| 441 | } |
| 442 | |
| 443 | codeLength += BerLength.encodeLength(os, codeLength); |
| 444 | |
| 445 | if (withTag) { |
| 446 | codeLength += tag.encode(os); |
| 447 | } |
| 448 | |
| 449 | return codeLength; |
| 450 | } |
| 451 | |
| 452 | public int decode(InputStream is) throws IOException { |
| 453 | return decode(is, true); |
| 454 | } |
| 455 | |
| 456 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 457 | int codeLength = 0; |
| 458 | int subCodeLength = 0; |
| 459 | if (withTag) { |
| 460 | codeLength += tag.decodeAndCheck(is); |
| 461 | } |
| 462 | |
| 463 | BerLength length = new BerLength(); |
| 464 | codeLength += length.decode(is); |
| 465 | int totalLength = length.val; |
| 466 | |
| 467 | while (subCodeLength < totalLength) { |
| 468 | BerInteger element = new BerInteger(); |
| 469 | subCodeLength += element.decode(is, true); |
| 470 | seqOf.add(element); |
| 471 | } |
| 472 | if (subCodeLength != totalLength) { |
| 473 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 474 | |
| 475 | } |
| 476 | codeLength += subCodeLength; |
| 477 | |
| 478 | return codeLength; |
| 479 | } |
| 480 | |
| 481 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 482 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 483 | encode(os, false); |
| 484 | code = os.getArray(); |
| 485 | } |
| 486 | |
| 487 | public String toString() { |
| 488 | StringBuilder sb = new StringBuilder(); |
| 489 | appendAsString(sb, 0); |
| 490 | return sb.toString(); |
| 491 | } |
| 492 | |
| 493 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 494 | |
| 495 | sb.append("{\n"); |
| 496 | for (int i = 0; i < indentLevel + 1; i++) { |
| 497 | sb.append("\t"); |
| 498 | } |
| 499 | if (seqOf == null) { |
| 500 | sb.append("null"); |
| 501 | } else { |
| 502 | Iterator<BerInteger> it = seqOf.iterator(); |
| 503 | if (it.hasNext()) { |
| 504 | sb.append(it.next()); |
| 505 | while (it.hasNext()) { |
| 506 | sb.append(",\n"); |
| 507 | for (int i = 0; i < indentLevel + 1; i++) { |
| 508 | sb.append("\t"); |
| 509 | } |
| 510 | sb.append(it.next()); |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | sb.append("\n"); |
| 516 | for (int i = 0; i < indentLevel; i++) { |
| 517 | sb.append("\t"); |
| 518 | } |
| 519 | sb.append("}"); |
| 520 | } |
| 521 | |
| 522 | } |
| 523 | |
| 524 | public static class PuschSinrHist implements Serializable { |
| 525 | |
| 526 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 527 | private static final long serialVersionUID = 1L; |
| 528 | @JsonIgnore |
| 529 | public byte[] code = null; |
| 530 | private List<BerInteger> seqOf = null; |
| 531 | |
| 532 | public PuschSinrHist() { |
| 533 | seqOf = new ArrayList<BerInteger>(); |
| 534 | } |
| 535 | |
| 536 | public PuschSinrHist(byte[] code) { |
| 537 | this.code = code; |
| 538 | } |
| 539 | |
| 540 | @JsonValue |
| 541 | public List<BerInteger> getBerInteger() { |
| 542 | if (seqOf == null) { |
| 543 | seqOf = new ArrayList<BerInteger>(); |
| 544 | } |
| 545 | return seqOf; |
| 546 | } |
| 547 | |
| 548 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 549 | return encode(os, true); |
| 550 | } |
| 551 | |
| 552 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 553 | |
| 554 | if (code != null) { |
| 555 | for (int i = code.length - 1; i >= 0; i--) { |
| 556 | os.write(code[i]); |
| 557 | } |
| 558 | if (withTag) { |
| 559 | return tag.encode(os) + code.length; |
| 560 | } |
| 561 | return code.length; |
| 562 | } |
| 563 | |
| 564 | int codeLength = 0; |
| 565 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 566 | codeLength += seqOf.get(i).encode(os, true); |
| 567 | } |
| 568 | |
| 569 | codeLength += BerLength.encodeLength(os, codeLength); |
| 570 | |
| 571 | if (withTag) { |
| 572 | codeLength += tag.encode(os); |
| 573 | } |
| 574 | |
| 575 | return codeLength; |
| 576 | } |
| 577 | |
| 578 | public int decode(InputStream is) throws IOException { |
| 579 | return decode(is, true); |
| 580 | } |
| 581 | |
| 582 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 583 | int codeLength = 0; |
| 584 | int subCodeLength = 0; |
| 585 | if (withTag) { |
| 586 | codeLength += tag.decodeAndCheck(is); |
| 587 | } |
| 588 | |
| 589 | BerLength length = new BerLength(); |
| 590 | codeLength += length.decode(is); |
| 591 | int totalLength = length.val; |
| 592 | |
| 593 | while (subCodeLength < totalLength) { |
| 594 | BerInteger element = new BerInteger(); |
| 595 | subCodeLength += element.decode(is, true); |
| 596 | seqOf.add(element); |
| 597 | } |
| 598 | if (subCodeLength != totalLength) { |
| 599 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 600 | |
| 601 | } |
| 602 | codeLength += subCodeLength; |
| 603 | |
| 604 | return codeLength; |
| 605 | } |
| 606 | |
| 607 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 608 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 609 | encode(os, false); |
| 610 | code = os.getArray(); |
| 611 | } |
| 612 | |
| 613 | public String toString() { |
| 614 | StringBuilder sb = new StringBuilder(); |
| 615 | appendAsString(sb, 0); |
| 616 | return sb.toString(); |
| 617 | } |
| 618 | |
| 619 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 620 | |
| 621 | sb.append("{\n"); |
| 622 | for (int i = 0; i < indentLevel + 1; i++) { |
| 623 | sb.append("\t"); |
| 624 | } |
| 625 | if (seqOf == null) { |
| 626 | sb.append("null"); |
| 627 | } else { |
| 628 | Iterator<BerInteger> it = seqOf.iterator(); |
| 629 | if (it.hasNext()) { |
| 630 | sb.append(it.next()); |
| 631 | while (it.hasNext()) { |
| 632 | sb.append(",\n"); |
| 633 | for (int i = 0; i < indentLevel + 1; i++) { |
| 634 | sb.append("\t"); |
| 635 | } |
| 636 | sb.append(it.next()); |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | sb.append("\n"); |
| 642 | for (int i = 0; i < indentLevel; i++) { |
| 643 | sb.append("\t"); |
| 644 | } |
| 645 | sb.append("}"); |
| 646 | } |
| 647 | |
| 648 | } |
| 649 | |
| 650 | public static class PucchSinrHist implements Serializable { |
| 651 | |
| 652 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 653 | private static final long serialVersionUID = 1L; |
| 654 | @JsonIgnore |
| 655 | public byte[] code = null; |
| 656 | private List<BerInteger> seqOf = null; |
| 657 | |
| 658 | public PucchSinrHist() { |
| 659 | seqOf = new ArrayList<BerInteger>(); |
| 660 | } |
| 661 | |
| 662 | public PucchSinrHist(byte[] code) { |
| 663 | this.code = code; |
| 664 | } |
| 665 | |
| 666 | @JsonValue |
| 667 | public List<BerInteger> getBerInteger() { |
| 668 | if (seqOf == null) { |
| 669 | seqOf = new ArrayList<BerInteger>(); |
| 670 | } |
| 671 | return seqOf; |
| 672 | } |
| 673 | |
| 674 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 675 | return encode(os, true); |
| 676 | } |
| 677 | |
| 678 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 679 | |
| 680 | if (code != null) { |
| 681 | for (int i = code.length - 1; i >= 0; i--) { |
| 682 | os.write(code[i]); |
| 683 | } |
| 684 | if (withTag) { |
| 685 | return tag.encode(os) + code.length; |
| 686 | } |
| 687 | return code.length; |
| 688 | } |
| 689 | |
| 690 | int codeLength = 0; |
| 691 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 692 | codeLength += seqOf.get(i).encode(os, true); |
| 693 | } |
| 694 | |
| 695 | codeLength += BerLength.encodeLength(os, codeLength); |
| 696 | |
| 697 | if (withTag) { |
| 698 | codeLength += tag.encode(os); |
| 699 | } |
| 700 | |
| 701 | return codeLength; |
| 702 | } |
| 703 | |
| 704 | public int decode(InputStream is) throws IOException { |
| 705 | return decode(is, true); |
| 706 | } |
| 707 | |
| 708 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 709 | int codeLength = 0; |
| 710 | int subCodeLength = 0; |
| 711 | if (withTag) { |
| 712 | codeLength += tag.decodeAndCheck(is); |
| 713 | } |
| 714 | |
| 715 | BerLength length = new BerLength(); |
| 716 | codeLength += length.decode(is); |
| 717 | int totalLength = length.val; |
| 718 | |
| 719 | while (subCodeLength < totalLength) { |
| 720 | BerInteger element = new BerInteger(); |
| 721 | subCodeLength += element.decode(is, true); |
| 722 | seqOf.add(element); |
| 723 | } |
| 724 | if (subCodeLength != totalLength) { |
| 725 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 726 | |
| 727 | } |
| 728 | codeLength += subCodeLength; |
| 729 | |
| 730 | return codeLength; |
| 731 | } |
| 732 | |
| 733 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 734 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 735 | encode(os, false); |
| 736 | code = os.getArray(); |
| 737 | } |
| 738 | |
| 739 | public String toString() { |
| 740 | StringBuilder sb = new StringBuilder(); |
| 741 | appendAsString(sb, 0); |
| 742 | return sb.toString(); |
| 743 | } |
| 744 | |
| 745 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 746 | |
| 747 | sb.append("{\n"); |
| 748 | for (int i = 0; i < indentLevel + 1; i++) { |
| 749 | sb.append("\t"); |
| 750 | } |
| 751 | if (seqOf == null) { |
| 752 | sb.append("null"); |
| 753 | } else { |
| 754 | Iterator<BerInteger> it = seqOf.iterator(); |
| 755 | if (it.hasNext()) { |
| 756 | sb.append(it.next()); |
| 757 | while (it.hasNext()) { |
| 758 | sb.append(",\n"); |
| 759 | for (int i = 0; i < indentLevel + 1; i++) { |
| 760 | sb.append("\t"); |
| 761 | } |
| 762 | sb.append(it.next()); |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | sb.append("\n"); |
| 768 | for (int i = 0; i < indentLevel; i++) { |
| 769 | sb.append("\t"); |
| 770 | } |
| 771 | sb.append("}"); |
| 772 | } |
| 773 | |
| 774 | } |
| 775 | |
| 776 | } |
| 777 | |