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