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