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