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.CRNTI; |
| 8 | import org.onosproject.xran.codecs.api.ECGI; |
| 9 | import org.onosproject.xran.codecs.api.RadioRepPerServCell; |
| 10 | import org.openmuc.jasn1.ber.BerByteArrayOutputStream; |
| 11 | import org.openmuc.jasn1.ber.BerLength; |
| 12 | import org.openmuc.jasn1.ber.BerTag; |
| 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 | public class RadioMeasReportPerUE implements Serializable { |
| 22 | |
| 23 | private static final long serialVersionUID = 1L; |
| 24 | |
| 25 | public static class RadioReportServCells 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<RadioRepPerServCell> seqOf = null; |
| 32 | |
| 33 | public RadioReportServCells() { |
| 34 | seqOf = new ArrayList<RadioRepPerServCell>(); |
| 35 | } |
| 36 | |
| 37 | public RadioReportServCells(byte[] code) { |
| 38 | this.code = code; |
| 39 | } |
| 40 | |
| 41 | public List<RadioRepPerServCell> getRadioRepPerServCell() { |
| 42 | if (seqOf == null) { |
| 43 | seqOf = new ArrayList<RadioRepPerServCell>(); |
| 44 | } |
| 45 | return seqOf; |
| 46 | } |
| 47 | |
| 48 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 49 | return encode(os, true); |
| 50 | } |
| 51 | |
| 52 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 53 | |
| 54 | if (code != null) { |
| 55 | for (int i = code.length - 1; i >= 0; i--) { |
| 56 | os.write(code[i]); |
| 57 | } |
| 58 | if (withTag) { |
| 59 | return tag.encode(os) + code.length; |
| 60 | } |
| 61 | return code.length; |
| 62 | } |
| 63 | |
| 64 | int codeLength = 0; |
| 65 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 66 | codeLength += seqOf.get(i).encode(os, true); |
| 67 | } |
| 68 | |
| 69 | codeLength += BerLength.encodeLength(os, codeLength); |
| 70 | |
| 71 | if (withTag) { |
| 72 | codeLength += tag.encode(os); |
| 73 | } |
| 74 | |
| 75 | return codeLength; |
| 76 | } |
| 77 | |
| 78 | public int decode(InputStream is) throws IOException { |
| 79 | return decode(is, true); |
| 80 | } |
| 81 | |
| 82 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 83 | int codeLength = 0; |
| 84 | int subCodeLength = 0; |
| 85 | if (withTag) { |
| 86 | codeLength += tag.decodeAndCheck(is); |
| 87 | } |
| 88 | |
| 89 | BerLength length = new BerLength(); |
| 90 | codeLength += length.decode(is); |
| 91 | int totalLength = length.val; |
| 92 | |
| 93 | while (subCodeLength < totalLength) { |
| 94 | RadioRepPerServCell element = new RadioRepPerServCell(); |
| 95 | subCodeLength += element.decode(is, true); |
| 96 | seqOf.add(element); |
| 97 | } |
| 98 | if (subCodeLength != totalLength) { |
| 99 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 100 | |
| 101 | } |
| 102 | codeLength += subCodeLength; |
| 103 | |
| 104 | return codeLength; |
| 105 | } |
| 106 | |
| 107 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 108 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 109 | encode(os, false); |
| 110 | code = os.getArray(); |
| 111 | } |
| 112 | |
| 113 | public String toString() { |
| 114 | StringBuilder sb = new StringBuilder(); |
| 115 | appendAsString(sb, 0); |
| 116 | return sb.toString(); |
| 117 | } |
| 118 | |
| 119 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 120 | |
| 121 | sb.append("[\n"); |
| 122 | for (int i = 0; i < indentLevel + 1; i++) { |
| 123 | sb.append("\t"); |
| 124 | } |
| 125 | if (seqOf == null) { |
| 126 | // sb.append("null"); |
| 127 | } |
| 128 | else { |
| 129 | Iterator<RadioRepPerServCell> it = seqOf.iterator(); |
| 130 | if (it.hasNext()) { |
| 131 | it.next().appendAsString(sb, indentLevel + 1); |
| 132 | while (it.hasNext()) { |
| 133 | sb.append(",\n"); |
| 134 | for (int i = 0; i < indentLevel + 1; i++) { |
| 135 | sb.append("\t"); |
| 136 | } |
| 137 | it.next().appendAsString(sb, indentLevel + 1); |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | sb.append("\n"); |
| 143 | for (int i = 0; i < indentLevel; i++) { |
| 144 | sb.append("\t"); |
| 145 | } |
| 146 | sb.append("]"); |
| 147 | } |
| 148 | |
| 149 | public void setRadioRepPerServCell(RadioRepPerServCell radioRepPerServCell) { |
| 150 | seqOf.add(radioRepPerServCell); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 155 | |
| 156 | public byte[] code = null; |
| 157 | private ECGI ecgi = null; |
| 158 | private CRNTI crnti = null; |
| 159 | private RadioReportServCells radioReportServCells = null; |
| 160 | |
| 161 | public RadioMeasReportPerUE() { |
| 162 | } |
| 163 | |
| 164 | public RadioMeasReportPerUE(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 setRadioReportServCells(RadioReportServCells radioReportServCells) { |
| 185 | this.radioReportServCells = radioReportServCells; |
| 186 | } |
| 187 | |
| 188 | public RadioReportServCells getRadioReportServCells() { |
| 189 | return radioReportServCells; |
| 190 | } |
| 191 | |
| 192 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 193 | return encode(os, true); |
| 194 | } |
| 195 | |
| 196 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 197 | |
| 198 | if (code != null) { |
| 199 | for (int i = code.length - 1; i >= 0; i--) { |
| 200 | os.write(code[i]); |
| 201 | } |
| 202 | if (withTag) { |
| 203 | return tag.encode(os) + code.length; |
| 204 | } |
| 205 | return code.length; |
| 206 | } |
| 207 | |
| 208 | int codeLength = 0; |
| 209 | codeLength += radioReportServCells.encode(os, false); |
| 210 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 211 | os.write(0xA2); |
| 212 | codeLength += 1; |
| 213 | |
| 214 | codeLength += crnti.encode(os, false); |
| 215 | // write tag: CONTEXT_CLASS, PRIMITIVE, 1 |
| 216 | os.write(0x81); |
| 217 | codeLength += 1; |
| 218 | |
| 219 | codeLength += ecgi.encode(os, false); |
| 220 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 221 | os.write(0xA0); |
| 222 | codeLength += 1; |
| 223 | |
| 224 | codeLength += BerLength.encodeLength(os, codeLength); |
| 225 | |
| 226 | if (withTag) { |
| 227 | codeLength += tag.encode(os); |
| 228 | } |
| 229 | |
| 230 | return codeLength; |
| 231 | |
| 232 | } |
| 233 | |
| 234 | public int decode(InputStream is) throws IOException { |
| 235 | return decode(is, true); |
| 236 | } |
| 237 | |
| 238 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 239 | int codeLength = 0; |
| 240 | int subCodeLength = 0; |
| 241 | BerTag berTag = new BerTag(); |
| 242 | |
| 243 | if (withTag) { |
| 244 | codeLength += tag.decodeAndCheck(is); |
| 245 | } |
| 246 | |
| 247 | BerLength length = new BerLength(); |
| 248 | codeLength += length.decode(is); |
| 249 | |
| 250 | int totalLength = length.val; |
| 251 | codeLength += totalLength; |
| 252 | |
| 253 | subCodeLength += berTag.decode(is); |
| 254 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 255 | ecgi = new ECGI(); |
| 256 | subCodeLength += ecgi.decode(is, false); |
| 257 | subCodeLength += berTag.decode(is); |
| 258 | } |
| 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.PRIMITIVE, 1)) { |
| 264 | crnti = new CRNTI(); |
| 265 | subCodeLength += crnti.decode(is, false); |
| 266 | subCodeLength += berTag.decode(is); |
| 267 | } |
| 268 | else { |
| 269 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 270 | } |
| 271 | |
| 272 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 273 | radioReportServCells = new RadioReportServCells(); |
| 274 | subCodeLength += radioReportServCells.decode(is, false); |
| 275 | if (subCodeLength == totalLength) { |
| 276 | return codeLength; |
| 277 | } |
| 278 | } |
| 279 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 280 | |
| 281 | |
| 282 | } |
| 283 | |
| 284 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 285 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 286 | encode(os, false); |
| 287 | code = os.getArray(); |
| 288 | } |
| 289 | |
| 290 | public String toString() { |
| 291 | StringBuilder sb = new StringBuilder(); |
| 292 | appendAsString(sb, 0); |
| 293 | return sb.toString(); |
| 294 | } |
| 295 | |
| 296 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 297 | |
| 298 | sb.append("{"); |
| 299 | sb.append("\n"); |
| 300 | for (int i = 0; i < indentLevel + 1; i++) { |
| 301 | sb.append("\t"); |
| 302 | } |
| 303 | if (ecgi != null) { |
| 304 | sb.append("\"ecgi\": "); |
| 305 | ecgi.appendAsString(sb, indentLevel + 1); |
| 306 | } |
| 307 | |
| 308 | sb.append(",\n"); |
| 309 | for (int i = 0; i < indentLevel + 1; i++) { |
| 310 | sb.append("\t"); |
| 311 | } |
| 312 | if (crnti != null) { |
| 313 | sb.append("\"crnti\": ").append(crnti); |
| 314 | } |
| 315 | |
| 316 | sb.append(",\n"); |
| 317 | for (int i = 0; i < indentLevel + 1; i++) { |
| 318 | sb.append("\t"); |
| 319 | } |
| 320 | if (radioReportServCells != null) { |
| 321 | sb.append("\"radioReportServCells\": "); |
| 322 | radioReportServCells.appendAsString(sb, indentLevel + 1); |
| 323 | } |
| 324 | |
| 325 | sb.append("\n"); |
| 326 | for (int i = 0; i < indentLevel; i++) { |
| 327 | sb.append("\t"); |
| 328 | } |
| 329 | sb.append("}"); |
| 330 | } |
| 331 | |
| 332 | } |
| 333 | |