blob: cf37663a8da1401d7af16699c434cc1a528249f6 [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.api;
6
7import java.io.IOException;
8import java.io.EOFException;
9import java.io.InputStream;
10import java.util.List;
11import java.util.ArrayList;
12import java.util.Iterator;
13import java.io.UnsupportedEncodingException;
14import java.math.BigInteger;
15import java.io.Serializable;
slowr60d4d102017-08-16 18:33:58 -070016
17import com.fasterxml.jackson.annotation.JsonIgnore;
18import org.onosproject.xran.codecs.ber.*;
19import org.onosproject.xran.codecs.ber.types.*;
20import org.onosproject.xran.codecs.ber.types.string.*;
slowr13fa5b02017-08-08 16:32:31 -070021
22
23public class TrafficSplitPercentage implements Serializable {
24
25 private static final long serialVersionUID = 1L;
26
27 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
28
slowr60d4d102017-08-16 18:33:58 -070029 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070030 public byte[] code = null;
31 private ECGI ecgi = null;
32 private BerInteger trafficPercentDl = null;
33 private BerInteger trafficPercentUl = null;
34
35 public TrafficSplitPercentage() {
36 }
37
38 public TrafficSplitPercentage(byte[] code) {
39 this.code = code;
40 }
41
42 public void setEcgi(ECGI ecgi) {
43 this.ecgi = ecgi;
44 }
45
46 public ECGI getEcgi() {
47 return ecgi;
48 }
49
50 public void setTrafficPercentDl(BerInteger trafficPercentDl) {
51 this.trafficPercentDl = trafficPercentDl;
52 }
53
54 public BerInteger getTrafficPercentDl() {
55 return trafficPercentDl;
56 }
57
58 public void setTrafficPercentUl(BerInteger trafficPercentUl) {
59 this.trafficPercentUl = trafficPercentUl;
60 }
61
62 public BerInteger getTrafficPercentUl() {
63 return trafficPercentUl;
64 }
65
66 public int encode(BerByteArrayOutputStream os) throws IOException {
67 return encode(os, true);
68 }
69
70 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
71
72 if (code != null) {
73 for (int i = code.length - 1; i >= 0; i--) {
74 os.write(code[i]);
75 }
76 if (withTag) {
77 return tag.encode(os) + code.length;
78 }
79 return code.length;
80 }
81
82 int codeLength = 0;
83 if (trafficPercentUl != null) {
84 codeLength += trafficPercentUl.encode(os, false);
85 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
86 os.write(0x82);
87 codeLength += 1;
88 }
89
90 if (trafficPercentDl != null) {
91 codeLength += trafficPercentDl.encode(os, false);
92 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
93 os.write(0x81);
94 codeLength += 1;
95 }
96
97 codeLength += ecgi.encode(os, false);
98 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
99 os.write(0xA0);
100 codeLength += 1;
101
102 codeLength += BerLength.encodeLength(os, codeLength);
103
104 if (withTag) {
105 codeLength += tag.encode(os);
106 }
107
108 return codeLength;
109
110 }
111
112 public int decode(InputStream is) throws IOException {
113 return decode(is, true);
114 }
115
116 public int decode(InputStream is, boolean withTag) throws IOException {
117 int codeLength = 0;
118 int subCodeLength = 0;
119 BerTag berTag = new BerTag();
120
121 if (withTag) {
122 codeLength += tag.decodeAndCheck(is);
123 }
124
125 BerLength length = new BerLength();
126 codeLength += length.decode(is);
127
128 int totalLength = length.val;
129 codeLength += totalLength;
130
131 subCodeLength += berTag.decode(is);
132 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
133 ecgi = new ECGI();
134 subCodeLength += ecgi.decode(is, false);
135 if (subCodeLength == totalLength) {
136 return codeLength;
137 }
138 subCodeLength += berTag.decode(is);
139 }
140 else {
141 throw new IOException("Tag does not match the mandatory sequence element tag.");
142 }
143
144 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
145 trafficPercentDl = new BerInteger();
146 subCodeLength += trafficPercentDl.decode(is, false);
147 if (subCodeLength == totalLength) {
148 return codeLength;
149 }
150 subCodeLength += berTag.decode(is);
151 }
152
153 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
154 trafficPercentUl = new BerInteger();
155 subCodeLength += trafficPercentUl.decode(is, false);
156 if (subCodeLength == totalLength) {
157 return codeLength;
158 }
159 }
160 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
161
162
163 }
164
165 public void encodeAndSave(int encodingSizeGuess) throws IOException {
166 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
167 encode(os, false);
168 code = os.getArray();
169 }
170
171 public String toString() {
172 StringBuilder sb = new StringBuilder();
173 appendAsString(sb, 0);
174 return sb.toString();
175 }
176
177 public void appendAsString(StringBuilder sb, int indentLevel) {
178
179 sb.append("{");
180 sb.append("\n");
181 for (int i = 0; i < indentLevel + 1; i++) {
182 sb.append("\t");
183 }
184 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700185 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700186 ecgi.appendAsString(sb, indentLevel + 1);
187 }
188
189 if (trafficPercentDl != null) {
190 sb.append(",\n");
191 for (int i = 0; i < indentLevel + 1; i++) {
192 sb.append("\t");
193 }
slowr60d4d102017-08-16 18:33:58 -0700194 sb.append("trafficPercentDl: ").append(trafficPercentDl);
slowr13fa5b02017-08-08 16:32:31 -0700195 }
196
197 if (trafficPercentUl != null) {
198 sb.append(",\n");
199 for (int i = 0; i < indentLevel + 1; i++) {
200 sb.append("\t");
201 }
slowr60d4d102017-08-16 18:33:58 -0700202 sb.append("trafficPercentUl: ").append(trafficPercentUl);
slowr13fa5b02017-08-08 16:32:31 -0700203 }
204
205 sb.append("\n");
206 for (int i = 0; i < indentLevel; i++) {
207 sb.append("\t");
208 }
209 sb.append("}");
210 }
211
212}
213