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