blob: aa5fdeabe45d6882a89ef80eb658400a2ced022b [file] [log] [blame]
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08001/**
2 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
3 */
4
5package org.onosproject.xran.asn1lib.pdu;
6
7import com.fasterxml.jackson.annotation.JsonIgnore;
8import org.onosproject.xran.asn1lib.api.CRNTI;
9import org.onosproject.xran.asn1lib.api.ECGI;
10import org.onosproject.xran.asn1lib.api.ERABResponse;
11import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
12import org.onosproject.xran.asn1lib.ber.BerLength;
13import org.onosproject.xran.asn1lib.ber.BerTag;
14import org.onosproject.xran.asn1lib.ber.types.BerInteger;
15
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
19
20public class BearerAdmissionStatus implements Serializable {
21
22 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
23 private static final long serialVersionUID = 1L;
24 @JsonIgnore
25 public byte[] code = null;
26 private CRNTI crnti = null;
27 private ECGI ecgi = null;
28 private BerInteger numErabs = null;
29 private ERABResponse erabStatus = null;
30
31 public BearerAdmissionStatus() {
32 }
33
34 public BearerAdmissionStatus(byte[] code) {
35 this.code = code;
36 }
37
38 public CRNTI getCrnti() {
39 return crnti;
40 }
41
42 public void setCrnti(CRNTI crnti) {
43 this.crnti = crnti;
44 }
45
46 public ECGI getEcgi() {
47 return ecgi;
48 }
49
50 public void setEcgi(ECGI ecgi) {
51 this.ecgi = ecgi;
52 }
53
54 public BerInteger getNumErabs() {
55 return numErabs;
56 }
57
58 public void setNumErabs(BerInteger numErabs) {
59 this.numErabs = numErabs;
60 }
61
62 public ERABResponse getErabStatus() {
63 return erabStatus;
64 }
65
66 public void setErabStatus(ERABResponse erabStatus) {
67 this.erabStatus = erabStatus;
68 }
69
70 public int encode(BerByteArrayOutputStream os) throws IOException {
71 return encode(os, true);
72 }
73
74 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
75
76 if (code != null) {
77 for (int i = code.length - 1; i >= 0; i--) {
78 os.write(code[i]);
79 }
80 if (withTag) {
81 return tag.encode(os) + code.length;
82 }
83 return code.length;
84 }
85
86 int codeLength = 0;
87 codeLength += erabStatus.encode(os, false);
88 // write tag: CONTEXT_CLASS, CONSTRUCTED, 3
89 os.write(0xA3);
90 codeLength += 1;
91
92 codeLength += numErabs.encode(os, false);
93 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
94 os.write(0x82);
95 codeLength += 1;
96
97 codeLength += ecgi.encode(os, false);
98 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
99 os.write(0xA1);
100 codeLength += 1;
101
102 codeLength += crnti.encode(os, false);
103 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
104 os.write(0x80);
105 codeLength += 1;
106
107 codeLength += BerLength.encodeLength(os, codeLength);
108
109 if (withTag) {
110 codeLength += tag.encode(os);
111 }
112
113 return codeLength;
114
115 }
116
117 public int decode(InputStream is) throws IOException {
118 return decode(is, true);
119 }
120
121 public int decode(InputStream is, boolean withTag) throws IOException {
122 int codeLength = 0;
123 int subCodeLength = 0;
124 BerTag berTag = new BerTag();
125
126 if (withTag) {
127 codeLength += tag.decodeAndCheck(is);
128 }
129
130 BerLength length = new BerLength();
131 codeLength += length.decode(is);
132
133 int totalLength = length.val;
134 codeLength += totalLength;
135
136 subCodeLength += berTag.decode(is);
137 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
138 crnti = new CRNTI();
139 subCodeLength += crnti.decode(is, false);
140 subCodeLength += berTag.decode(is);
141 } else {
142 throw new IOException("Tag does not match the mandatory sequence element tag.");
143 }
144
145 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
146 ecgi = new ECGI();
147 subCodeLength += ecgi.decode(is, false);
148 subCodeLength += berTag.decode(is);
149 } else {
150 throw new IOException("Tag does not match the mandatory sequence element tag.");
151 }
152
153 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
154 numErabs = new BerInteger();
155 subCodeLength += numErabs.decode(is, false);
156 subCodeLength += berTag.decode(is);
157 } else {
158 throw new IOException("Tag does not match the mandatory sequence element tag.");
159 }
160
161 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
162 erabStatus = new ERABResponse();
163 subCodeLength += erabStatus.decode(is, false);
164 if (subCodeLength == totalLength) {
165 return codeLength;
166 }
167 }
168 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
169
170
171 }
172
173 public void encodeAndSave(int encodingSizeGuess) throws IOException {
174 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
175 encode(os, false);
176 code = os.getArray();
177 }
178
179 public String toString() {
180 StringBuilder sb = new StringBuilder();
181 appendAsString(sb, 0);
182 return sb.toString();
183 }
184
185 public void appendAsString(StringBuilder sb, int indentLevel) {
186
187 sb.append("{");
188 sb.append("\n");
189 for (int i = 0; i < indentLevel + 1; i++) {
190 sb.append("\t");
191 }
192 if (crnti != null) {
193 sb.append("crnti: ").append(crnti);
194 } else {
195 sb.append("crnti: <empty-required-field>");
196 }
197
198 sb.append(",\n");
199 for (int i = 0; i < indentLevel + 1; i++) {
200 sb.append("\t");
201 }
202 if (ecgi != null) {
203 sb.append("ecgi: ");
204 ecgi.appendAsString(sb, indentLevel + 1);
205 } else {
206 sb.append("ecgi: <empty-required-field>");
207 }
208
209 sb.append(",\n");
210 for (int i = 0; i < indentLevel + 1; i++) {
211 sb.append("\t");
212 }
213 if (numErabs != null) {
214 sb.append("numErabs: ").append(numErabs);
215 } else {
216 sb.append("numErabs: <empty-required-field>");
217 }
218
219 sb.append(",\n");
220 for (int i = 0; i < indentLevel + 1; i++) {
221 sb.append("\t");
222 }
223 if (erabStatus != null) {
224 sb.append("erabStatus: ");
225 erabStatus.appendAsString(sb, indentLevel + 1);
226 } else {
227 sb.append("erabStatus: <empty-required-field>");
228 }
229
230 sb.append("\n");
231 for (int i = 0; i < indentLevel; i++) {
232 sb.append("\t");
233 }
234 sb.append("}");
235 }
236
237}
238