blob: ebdc917b2b090195ce26988f19d67ec0a18745b9 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/**
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08002 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
slowr13fa5b02017-08-08 16:32:31 -07003 */
4
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08005package org.onosproject.xran.asn1lib.pdu;
slowr13fa5b02017-08-08 16:32:31 -07006
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
8import com.fasterxml.jackson.annotation.JsonValue;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08009import org.onosproject.xran.asn1lib.api.CRNTI;
10import org.onosproject.xran.asn1lib.api.ECGI;
11import org.onosproject.xran.asn1lib.api.TrafficSplitPercentage;
12import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
13import org.onosproject.xran.asn1lib.ber.BerLength;
14import org.onosproject.xran.asn1lib.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070015
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
19import java.util.ArrayList;
20import java.util.Iterator;
21import java.util.List;
22
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080023public class TrafficSplitConfig implements Serializable {
slowr13fa5b02017-08-08 16:32:31 -070024
slowr89c2ac12017-08-15 16:20:06 -070025 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
26 private static final long serialVersionUID = 1L;
slowr60d4d102017-08-16 18:33:58 -070027 @JsonIgnore
slowr89c2ac12017-08-15 16:20:06 -070028 public byte[] code = null;
29 private CRNTI crnti = null;
30 private ECGI ecgi = null;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080031 private TrafficSplitPercent trafficSplitPercent = null;
32
33 public TrafficSplitConfig() {
slowr89c2ac12017-08-15 16:20:06 -070034 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080035
36 public TrafficSplitConfig(byte[] code) {
slowr89c2ac12017-08-15 16:20:06 -070037 this.code = code;
38 }
slowr13fa5b02017-08-08 16:32:31 -070039
slowr89c2ac12017-08-15 16:20:06 -070040 public CRNTI getCrnti() {
41 return crnti;
42 }
slowr13fa5b02017-08-08 16:32:31 -070043
slowr89c2ac12017-08-15 16:20:06 -070044 public void setCrnti(CRNTI crnti) {
45 this.crnti = crnti;
46 }
slowr13fa5b02017-08-08 16:32:31 -070047
slowr89c2ac12017-08-15 16:20:06 -070048 public ECGI getEcgi() {
49 return ecgi;
50 }
slowr13fa5b02017-08-08 16:32:31 -070051
slowr89c2ac12017-08-15 16:20:06 -070052 public void setEcgi(ECGI ecgi) {
53 this.ecgi = ecgi;
54 }
slowr13fa5b02017-08-08 16:32:31 -070055
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080056 public TrafficSplitPercent getTrafficSplitPercent() {
57 return trafficSplitPercent;
slowr89c2ac12017-08-15 16:20:06 -070058 }
slowr13fa5b02017-08-08 16:32:31 -070059
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080060 public void setTrafficSplitPercent(TrafficSplitPercent trafficSplitPercent) {
61 this.trafficSplitPercent = trafficSplitPercent;
slowr89c2ac12017-08-15 16:20:06 -070062 }
slowr13fa5b02017-08-08 16:32:31 -070063
slowr89c2ac12017-08-15 16:20:06 -070064 public int encode(BerByteArrayOutputStream os) throws IOException {
65 return encode(os, true);
66 }
slowr13fa5b02017-08-08 16:32:31 -070067
slowr89c2ac12017-08-15 16:20:06 -070068 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -070069
slowr89c2ac12017-08-15 16:20:06 -070070 if (code != null) {
71 for (int i = code.length - 1; i >= 0; i--) {
72 os.write(code[i]);
73 }
74 if (withTag) {
75 return tag.encode(os) + code.length;
76 }
77 return code.length;
78 }
slowr13fa5b02017-08-08 16:32:31 -070079
slowr89c2ac12017-08-15 16:20:06 -070080 int codeLength = 0;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080081 codeLength += trafficSplitPercent.encode(os, false);
slowr89c2ac12017-08-15 16:20:06 -070082 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
83 os.write(0xA2);
84 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070085
slowr89c2ac12017-08-15 16:20:06 -070086 codeLength += ecgi.encode(os, false);
87 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
88 os.write(0xA1);
89 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070090
slowr89c2ac12017-08-15 16:20:06 -070091 codeLength += crnti.encode(os, false);
92 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
93 os.write(0x80);
94 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070095
slowr89c2ac12017-08-15 16:20:06 -070096 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -070097
slowr89c2ac12017-08-15 16:20:06 -070098 if (withTag) {
99 codeLength += tag.encode(os);
100 }
slowr13fa5b02017-08-08 16:32:31 -0700101
slowr89c2ac12017-08-15 16:20:06 -0700102 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700103
slowr89c2ac12017-08-15 16:20:06 -0700104 }
105
106 public int decode(InputStream is) throws IOException {
107 return decode(is, true);
108 }
109
110 public int decode(InputStream is, boolean withTag) throws IOException {
111 int codeLength = 0;
112 int subCodeLength = 0;
113 BerTag berTag = new BerTag();
114
115 if (withTag) {
116 codeLength += tag.decodeAndCheck(is);
117 }
118
119 BerLength length = new BerLength();
120 codeLength += length.decode(is);
121
122 int totalLength = length.val;
123 codeLength += totalLength;
124
125 subCodeLength += berTag.decode(is);
126 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
127 crnti = new CRNTI();
128 subCodeLength += crnti.decode(is, false);
129 subCodeLength += berTag.decode(is);
130 } else {
131 throw new IOException("Tag does not match the mandatory sequence element tag.");
132 }
133
134 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
135 ecgi = new ECGI();
136 subCodeLength += ecgi.decode(is, false);
137 subCodeLength += berTag.decode(is);
138 } else {
139 throw new IOException("Tag does not match the mandatory sequence element tag.");
140 }
141
142 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800143 trafficSplitPercent = new TrafficSplitPercent();
144 subCodeLength += trafficSplitPercent.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700145 if (subCodeLength == totalLength) {
146 return codeLength;
147 }
148 }
149 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
150
151
152 }
153
154 public void encodeAndSave(int encodingSizeGuess) throws IOException {
155 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
156 encode(os, false);
157 code = os.getArray();
158 }
159
160 public String toString() {
161 StringBuilder sb = new StringBuilder();
162 appendAsString(sb, 0);
163 return sb.toString();
164 }
165
166 public void appendAsString(StringBuilder sb, int indentLevel) {
167
168 sb.append("{");
169 sb.append("\n");
170 for (int i = 0; i < indentLevel + 1; i++) {
171 sb.append("\t");
172 }
173 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700174 sb.append("crnti: ").append(crnti);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800175 } else {
176 sb.append("crnti: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700177 }
178
179 sb.append(",\n");
180 for (int i = 0; i < indentLevel + 1; i++) {
181 sb.append("\t");
182 }
183 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700184 sb.append("ecgi: ");
slowr89c2ac12017-08-15 16:20:06 -0700185 ecgi.appendAsString(sb, indentLevel + 1);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800186 } else {
187 sb.append("ecgi: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700188 }
189
190 sb.append(",\n");
191 for (int i = 0; i < indentLevel + 1; i++) {
192 sb.append("\t");
193 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800194 if (trafficSplitPercent != null) {
195 sb.append("trafficSplitPercent: ");
196 trafficSplitPercent.appendAsString(sb, indentLevel + 1);
197 } else {
198 sb.append("trafficSplitPercent: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700199 }
200
201 sb.append("\n");
202 for (int i = 0; i < indentLevel; i++) {
203 sb.append("\t");
204 }
205 sb.append("}");
206 }
207
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800208 public static class TrafficSplitPercent implements Serializable {
slowr89c2ac12017-08-15 16:20:06 -0700209
210 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
211 private static final long serialVersionUID = 1L;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800212 @JsonIgnore
213 public byte[] code = null;
214 private List<TrafficSplitPercentage> seqOf = null;
slowr89c2ac12017-08-15 16:20:06 -0700215
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800216 public TrafficSplitPercent() {
217 seqOf = new ArrayList<TrafficSplitPercentage>();
slowr89c2ac12017-08-15 16:20:06 -0700218 }
219
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800220 public TrafficSplitPercent(byte[] code) {
slowr89c2ac12017-08-15 16:20:06 -0700221 this.code = code;
222 }
223
slowr60d4d102017-08-16 18:33:58 -0700224 @JsonValue
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800225 public List<TrafficSplitPercentage> getTrafficSplitPercentage() {
slowr89c2ac12017-08-15 16:20:06 -0700226 if (seqOf == null) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800227 seqOf = new ArrayList<TrafficSplitPercentage>();
slowr89c2ac12017-08-15 16:20:06 -0700228 }
229 return seqOf;
230 }
231
232 public int encode(BerByteArrayOutputStream os) throws IOException {
233 return encode(os, true);
234 }
235
236 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
237
238 if (code != null) {
239 for (int i = code.length - 1; i >= 0; i--) {
240 os.write(code[i]);
241 }
242 if (withTag) {
243 return tag.encode(os) + code.length;
244 }
245 return code.length;
246 }
247
248 int codeLength = 0;
249 for (int i = (seqOf.size() - 1); i >= 0; i--) {
250 codeLength += seqOf.get(i).encode(os, true);
251 }
252
253 codeLength += BerLength.encodeLength(os, codeLength);
254
255 if (withTag) {
256 codeLength += tag.encode(os);
257 }
258
259 return codeLength;
260 }
261
262 public int decode(InputStream is) throws IOException {
263 return decode(is, true);
264 }
265
266 public int decode(InputStream is, boolean withTag) throws IOException {
267 int codeLength = 0;
268 int subCodeLength = 0;
269 if (withTag) {
270 codeLength += tag.decodeAndCheck(is);
271 }
272
273 BerLength length = new BerLength();
274 codeLength += length.decode(is);
275 int totalLength = length.val;
276
277 while (subCodeLength < totalLength) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800278 TrafficSplitPercentage element = new TrafficSplitPercentage();
slowr89c2ac12017-08-15 16:20:06 -0700279 subCodeLength += element.decode(is, true);
280 seqOf.add(element);
281 }
282 if (subCodeLength != totalLength) {
283 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
284
285 }
286 codeLength += subCodeLength;
287
288 return codeLength;
289 }
290
291 public void encodeAndSave(int encodingSizeGuess) throws IOException {
292 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
293 encode(os, false);
294 code = os.getArray();
295 }
296
297 public String toString() {
298 StringBuilder sb = new StringBuilder();
299 appendAsString(sb, 0);
300 return sb.toString();
301 }
302
303 public void appendAsString(StringBuilder sb, int indentLevel) {
304
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800305 sb.append("{\n");
slowr89c2ac12017-08-15 16:20:06 -0700306 for (int i = 0; i < indentLevel + 1; i++) {
307 sb.append("\t");
308 }
309 if (seqOf == null) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800310 sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700311 } else {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800312 Iterator<TrafficSplitPercentage> it = seqOf.iterator();
slowr89c2ac12017-08-15 16:20:06 -0700313 if (it.hasNext()) {
314 it.next().appendAsString(sb, indentLevel + 1);
315 while (it.hasNext()) {
316 sb.append(",\n");
317 for (int i = 0; i < indentLevel + 1; i++) {
318 sb.append("\t");
319 }
320 it.next().appendAsString(sb, indentLevel + 1);
321 }
322 }
323 }
slowr13fa5b02017-08-08 16:32:31 -0700324
slowr89c2ac12017-08-15 16:20:06 -0700325 sb.append("\n");
326 for (int i = 0; i < indentLevel; i++) {
327 sb.append("\t");
328 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800329 sb.append("}");
slowr89c2ac12017-08-15 16:20:06 -0700330 }
slowr13fa5b02017-08-08 16:32:31 -0700331
slowr89c2ac12017-08-15 16:20:06 -0700332 }
slowr13fa5b02017-08-08 16:32:31 -0700333
334}
335