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