blob: a2c017eae7db25d83656151f519c62c9a60d090e [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 */
4package org.onosproject.xran.codecs.pdu;
5
6import org.onosproject.xran.codecs.api.CACap;
7import org.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.DCCap;
9import org.onosproject.xran.codecs.api.ECGI;
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;
17
18
19public class UECapabilityInfo implements Serializable {
20
21 private static final long serialVersionUID = 1L;
22
23 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
24
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 void setCrnti(CRNTI crnti) {
39 this.crnti = crnti;
40 }
41
42 public CRNTI getCrnti() {
43 return crnti;
44 }
45
46 public void setEcgi(ECGI ecgi) {
47 this.ecgi = ecgi;
48 }
49
50 public ECGI getEcgi() {
51 return ecgi;
52 }
53
54 public void setCaCap(CACap caCap) {
55 this.caCap = caCap;
56 }
57
58 public CACap getCaCap() {
59 return caCap;
60 }
61
62 public void setDcCap(DCCap dcCap) {
63 this.dcCap = dcCap;
64 }
65
66 public DCCap getDcCap() {
67 return 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 }
146 else {
147 throw new IOException("Tag does not match the mandatory sequence element tag.");
148 }
149
150 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
151 ecgi = new ECGI();
152 subCodeLength += ecgi.decode(is, false);
153 if (subCodeLength == totalLength) {
154 return codeLength;
155 }
156 subCodeLength += berTag.decode(is);
157 }
158 else {
159 throw new IOException("Tag does not match the mandatory sequence element tag.");
160 }
161
162 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
163 caCap = new CACap();
164 subCodeLength += caCap.decode(is, false);
165 if (subCodeLength == totalLength) {
166 return codeLength;
167 }
168 subCodeLength += berTag.decode(is);
169 }
170
171 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
172 dcCap = new DCCap();
173 subCodeLength += dcCap.decode(is, false);
174 if (subCodeLength == totalLength) {
175 return codeLength;
176 }
177 }
178 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
179
180
181 }
182
183 public void encodeAndSave(int encodingSizeGuess) throws IOException {
184 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
185 encode(os, false);
186 code = os.getArray();
187 }
188
189 public String toString() {
190 StringBuilder sb = new StringBuilder();
191 appendAsString(sb, 0);
192 return sb.toString();
193 }
194
195 public void appendAsString(StringBuilder sb, int indentLevel) {
196
197 sb.append("{");
198 sb.append("\n");
199 for (int i = 0; i < indentLevel + 1; i++) {
200 sb.append("\t");
201 }
202 if (crnti != null) {
203 sb.append("\"crnti\": ").append(crnti);
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 }
214
215 if (caCap != null) {
216 sb.append(",\n");
217 for (int i = 0; i < indentLevel + 1; i++) {
218 sb.append("\t");
219 }
220 sb.append("\"caCap\": ");
221 caCap.appendAsString(sb, indentLevel + 1);
222 }
223
224 if (dcCap != null) {
225 sb.append(",\n");
226 for (int i = 0; i < indentLevel + 1; i++) {
227 sb.append("\t");
228 }
229 sb.append("\"dcCap\": ");
230 dcCap.appendAsString(sb, indentLevel + 1);
231 }
232
233 sb.append("\n");
234 for (int i = 0; i < indentLevel; i++) {
235 sb.append("\t");
236 }
237 sb.append("}");
238 }
239
240}
241