blob: a1d6c8f34658ca42c57c741f02c842236e75a3a0 [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.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.ECGI;
9import org.onosproject.xran.codecs.api.PropScell;
10import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
11import org.openmuc.jasn1.ber.BerLength;
12import org.openmuc.jasn1.ber.BerTag;
13
14import java.io.IOException;
15import java.io.InputStream;
16import java.io.Serializable;
17import java.util.ArrayList;
18import java.util.Iterator;
19import java.util.List;
20
21public class ScellAdd implements Serializable {
22
23 private static final long serialVersionUID = 1L;
24
25 public static class ScellsProp 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<PropScell> seqOf = null;
32
33 public ScellsProp() {
34 seqOf = new ArrayList<PropScell>();
35 }
36
37 public ScellsProp(byte[] code) {
38 this.code = code;
39 }
40
41 public List<PropScell> getPropScell() {
42 if (seqOf == null) {
43 seqOf = new ArrayList<PropScell>();
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 PropScell element = new PropScell();
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<PropScell> 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 }
150
151 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
152
153 public byte[] code = null;
154 private CRNTI crnti = null;
155 private ECGI ecgi = null;
156 private ScellsProp scellsProp = null;
157
158 public ScellAdd() {
159 }
160
161 public ScellAdd(byte[] code) {
162 this.code = code;
163 }
164
165 public void setCrnti(CRNTI crnti) {
166 this.crnti = crnti;
167 }
168
169 public CRNTI getCrnti() {
170 return crnti;
171 }
172
173 public void setEcgi(ECGI ecgi) {
174 this.ecgi = ecgi;
175 }
176
177 public ECGI getEcgi() {
178 return ecgi;
179 }
180
181 public void setScellsProp(ScellsProp scellsProp) {
182 this.scellsProp = scellsProp;
183 }
184
185 public ScellsProp getScellsProp() {
186 return scellsProp;
187 }
188
189 public int encode(BerByteArrayOutputStream os) throws IOException {
190 return encode(os, true);
191 }
192
193 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
194
195 if (code != null) {
196 for (int i = code.length - 1; i >= 0; i--) {
197 os.write(code[i]);
198 }
199 if (withTag) {
200 return tag.encode(os) + code.length;
201 }
202 return code.length;
203 }
204
205 int codeLength = 0;
206 codeLength += scellsProp.encode(os, false);
207 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
208 os.write(0xA2);
209 codeLength += 1;
210
211 codeLength += ecgi.encode(os, false);
212 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
213 os.write(0xA1);
214 codeLength += 1;
215
216 codeLength += crnti.encode(os, false);
217 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
218 os.write(0x80);
219 codeLength += 1;
220
221 codeLength += BerLength.encodeLength(os, codeLength);
222
223 if (withTag) {
224 codeLength += tag.encode(os);
225 }
226
227 return codeLength;
228
229 }
230
231 public int decode(InputStream is) throws IOException {
232 return decode(is, true);
233 }
234
235 public int decode(InputStream is, boolean withTag) throws IOException {
236 int codeLength = 0;
237 int subCodeLength = 0;
238 BerTag berTag = new BerTag();
239
240 if (withTag) {
241 codeLength += tag.decodeAndCheck(is);
242 }
243
244 BerLength length = new BerLength();
245 codeLength += length.decode(is);
246
247 int totalLength = length.val;
248 codeLength += totalLength;
249
250 subCodeLength += berTag.decode(is);
251 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
252 crnti = new CRNTI();
253 subCodeLength += crnti.decode(is, false);
254 subCodeLength += berTag.decode(is);
255 }
256 else {
257 throw new IOException("Tag does not match the mandatory sequence element tag.");
258 }
259
260 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
261 ecgi = new ECGI();
262 subCodeLength += ecgi.decode(is, false);
263 subCodeLength += berTag.decode(is);
264 }
265 else {
266 throw new IOException("Tag does not match the mandatory sequence element tag.");
267 }
268
269 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
270 scellsProp = new ScellsProp();
271 subCodeLength += scellsProp.decode(is, false);
272 if (subCodeLength == totalLength) {
273 return codeLength;
274 }
275 }
276 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
277
278
279 }
280
281 public void encodeAndSave(int encodingSizeGuess) throws IOException {
282 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
283 encode(os, false);
284 code = os.getArray();
285 }
286
287 public String toString() {
288 StringBuilder sb = new StringBuilder();
289 appendAsString(sb, 0);
290 return sb.toString();
291 }
292
293 public void appendAsString(StringBuilder sb, int indentLevel) {
294
295 sb.append("{");
296 sb.append("\n");
297 for (int i = 0; i < indentLevel + 1; i++) {
298 sb.append("\t");
299 }
300 if (crnti != null) {
301 sb.append("\"crnti\": ").append(crnti);
302 }
303
304 sb.append(",\n");
305 for (int i = 0; i < indentLevel + 1; i++) {
306 sb.append("\t");
307 }
308 if (ecgi != null) {
309 sb.append("\"ecgi\": ");
310 ecgi.appendAsString(sb, indentLevel + 1);
311 }
312
313 sb.append(",\n");
314 for (int i = 0; i < indentLevel + 1; i++) {
315 sb.append("\t");
316 }
317 if (scellsProp != null) {
318 sb.append("\"scellsProp\": ");
319 scellsProp.appendAsString(sb, indentLevel + 1);
320 }
321
322 sb.append("\n");
323 for (int i = 0; i < indentLevel; i++) {
324 sb.append("\t");
325 }
326 sb.append("}");
327 }
328
329}
330