blob: b842ec43038dcd2f39b499a4d730be5077138631 [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.CACap;
9import org.onosproject.xran.asn1lib.api.CRNTI;
10import org.onosproject.xran.asn1lib.api.DCCap;
11import org.onosproject.xran.asn1lib.api.ECGI;
12import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
13import org.onosproject.xran.asn1lib.ber.BerLength;
14import org.onosproject.xran.asn1lib.ber.BerTag;
15
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
19
20public class UECapabilityInfo 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 CACap caCap = null;
29 private DCCap dcCap = null;
30
31 public UECapabilityInfo() {
32 }
33
34 public UECapabilityInfo(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 CACap getCaCap() {
55 return caCap;
56 }
57
58 public void setCaCap(CACap caCap) {
59 this.caCap = caCap;
60 }
61
62 public DCCap getDcCap() {
63 return dcCap;
64 }
65
66 public void setDcCap(DCCap dcCap) {
67 this.dcCap = dcCap;
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 if (dcCap != null) {
88 codeLength += dcCap.encode(os, false);
89 // write tag: CONTEXT_CLASS, CONSTRUCTED, 3
90 os.write(0xA3);
91 codeLength += 1;
92 }
93
94 if (caCap != null) {
95 codeLength += caCap.encode(os, false);
96 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
97 os.write(0xA2);
98 codeLength += 1;
99 }
100
101 codeLength += ecgi.encode(os, false);
102 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
103 os.write(0xA1);
104 codeLength += 1;
105
106 codeLength += crnti.encode(os, false);
107 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
108 os.write(0x80);
109 codeLength += 1;
110
111 codeLength += BerLength.encodeLength(os, codeLength);
112
113 if (withTag) {
114 codeLength += tag.encode(os);
115 }
116
117 return codeLength;
118
119 }
120
121 public int decode(InputStream is) throws IOException {
122 return decode(is, true);
123 }
124
125 public int decode(InputStream is, boolean withTag) throws IOException {
126 int codeLength = 0;
127 int subCodeLength = 0;
128 BerTag berTag = new BerTag();
129
130 if (withTag) {
131 codeLength += tag.decodeAndCheck(is);
132 }
133
134 BerLength length = new BerLength();
135 codeLength += length.decode(is);
136
137 int totalLength = length.val;
138 codeLength += totalLength;
139
140 subCodeLength += berTag.decode(is);
141 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
142 crnti = new CRNTI();
143 subCodeLength += crnti.decode(is, false);
144 subCodeLength += berTag.decode(is);
145 } else {
146 throw new IOException("Tag does not match the mandatory sequence element tag.");
147 }
148
149 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
150 ecgi = new ECGI();
151 subCodeLength += ecgi.decode(is, false);
152 if (subCodeLength == totalLength) {
153 return codeLength;
154 }
155 subCodeLength += berTag.decode(is);
156 } else {
157 throw new IOException("Tag does not match the mandatory sequence element tag.");
158 }
159
160 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
161 caCap = new CACap();
162 subCodeLength += caCap.decode(is, false);
163 if (subCodeLength == totalLength) {
164 return codeLength;
165 }
166 subCodeLength += berTag.decode(is);
167 }
168
169 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
170 dcCap = new DCCap();
171 subCodeLength += dcCap.decode(is, false);
172 if (subCodeLength == totalLength) {
173 return codeLength;
174 }
175 }
176 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
177
178
179 }
180
181 public void encodeAndSave(int encodingSizeGuess) throws IOException {
182 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
183 encode(os, false);
184 code = os.getArray();
185 }
186
187 public String toString() {
188 StringBuilder sb = new StringBuilder();
189 appendAsString(sb, 0);
190 return sb.toString();
191 }
192
193 public void appendAsString(StringBuilder sb, int indentLevel) {
194
195 sb.append("{");
196 sb.append("\n");
197 for (int i = 0; i < indentLevel + 1; i++) {
198 sb.append("\t");
199 }
200 if (crnti != null) {
201 sb.append("crnti: ").append(crnti);
202 } else {
203 sb.append("crnti: <empty-required-field>");
204 }
205
206 sb.append(",\n");
207 for (int i = 0; i < indentLevel + 1; i++) {
208 sb.append("\t");
209 }
210 if (ecgi != null) {
211 sb.append("ecgi: ");
212 ecgi.appendAsString(sb, indentLevel + 1);
213 } else {
214 sb.append("ecgi: <empty-required-field>");
215 }
216
217 if (caCap != null) {
218 sb.append(",\n");
219 for (int i = 0; i < indentLevel + 1; i++) {
220 sb.append("\t");
221 }
222 sb.append("caCap: ");
223 caCap.appendAsString(sb, indentLevel + 1);
224 }
225
226 if (dcCap != null) {
227 sb.append(",\n");
228 for (int i = 0; i < indentLevel + 1; i++) {
229 sb.append("\t");
230 }
231 sb.append("dcCap: ");
232 dcCap.appendAsString(sb, indentLevel + 1);
233 }
234
235 sb.append("\n");
236 for (int i = 0; i < indentLevel; i++) {
237 sb.append("\t");
238 }
239 sb.append("}");
240 }
241
242}
243