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