blob: cd2ef5c300c61452dda0810ed25ecb4e70d47cc4 [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 org.openmuc.jasn1.ber.BerByteArrayOutputStream;
8import org.openmuc.jasn1.ber.BerLength;
9import org.openmuc.jasn1.ber.BerTag;
10import org.openmuc.jasn1.ber.types.BerBoolean;
11import org.openmuc.jasn1.ber.types.BerEnum;
12import org.openmuc.jasn1.ber.types.BerInteger;
13
14import java.io.IOException;
15import java.io.InputStream;
16import java.io.Serializable;
17
18
19public class CACap 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 BerInteger band = null;
27 private BerEnum caclassdl = null;
28 private BerEnum caclassul = null;
29 private BerBoolean crossCarrierSched = null;
30
31 public CACap() {
32 }
33
34 public CACap(byte[] code) {
35 this.code = code;
36 }
37
38 public void setBand(BerInteger band) {
39 this.band = band;
40 }
41
42 public BerInteger getBand() {
43 return band;
44 }
45
46 public void setCaclassdl(BerEnum caclassdl) {
47 this.caclassdl = caclassdl;
48 }
49
50 public BerEnum getCaclassdl() {
51 return caclassdl;
52 }
53
54 public void setCaclassul(BerEnum caclassul) {
55 this.caclassul = caclassul;
56 }
57
58 public BerEnum getCaclassul() {
59 return caclassul;
60 }
61
62 public void setCrossCarrierSched(BerBoolean crossCarrierSched) {
63 this.crossCarrierSched = crossCarrierSched;
64 }
65
66 public BerBoolean getCrossCarrierSched() {
67 return crossCarrierSched;
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 codeLength += crossCarrierSched.encode(os, false);
88 // write tag: CONTEXT_CLASS, PRIMITIVE, 3
89 os.write(0x83);
90 codeLength += 1;
91
92 codeLength += caclassul.encode(os, false);
93 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
94 os.write(0x82);
95 codeLength += 1;
96
97 codeLength += caclassdl.encode(os, false);
98 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
99 os.write(0x81);
100 codeLength += 1;
101
102 codeLength += band.encode(os, false);
103 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
104 os.write(0x80);
105 codeLength += 1;
106
107 codeLength += BerLength.encodeLength(os, codeLength);
108
109 if (withTag) {
110 codeLength += tag.encode(os);
111 }
112
113 return codeLength;
114
115 }
116
117 public int decode(InputStream is) throws IOException {
118 return decode(is, true);
119 }
120
121 public int decode(InputStream is, boolean withTag) throws IOException {
122 int codeLength = 0;
123 int subCodeLength = 0;
124 BerTag berTag = new BerTag();
125
126 if (withTag) {
127 codeLength += tag.decodeAndCheck(is);
128 }
129
130 BerLength length = new BerLength();
131 codeLength += length.decode(is);
132
133 int totalLength = length.val;
134 codeLength += totalLength;
135
136 subCodeLength += berTag.decode(is);
137 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
138 band = new BerInteger();
139 subCodeLength += band.decode(is, false);
140 subCodeLength += berTag.decode(is);
141 }
142 else {
143 throw new IOException("Tag does not match the mandatory sequence element tag.");
144 }
145
146 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
147 caclassdl = new BerEnum();
148 subCodeLength += caclassdl.decode(is, false);
149 subCodeLength += berTag.decode(is);
150 }
151 else {
152 throw new IOException("Tag does not match the mandatory sequence element tag.");
153 }
154
155 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
156 caclassul = new BerEnum();
157 subCodeLength += caclassul.decode(is, false);
158 subCodeLength += berTag.decode(is);
159 }
160 else {
161 throw new IOException("Tag does not match the mandatory sequence element tag.");
162 }
163
164 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
165 crossCarrierSched = new BerBoolean();
166 subCodeLength += crossCarrierSched.decode(is, false);
167 if (subCodeLength == totalLength) {
168 return codeLength;
169 }
170 }
171 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
172
173
174 }
175
176 public void encodeAndSave(int encodingSizeGuess) throws IOException {
177 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
178 encode(os, false);
179 code = os.getArray();
180 }
181
182 public String toString() {
183 StringBuilder sb = new StringBuilder();
184 appendAsString(sb, 0);
185 return sb.toString();
186 }
187
188 public void appendAsString(StringBuilder sb, int indentLevel) {
189
190 sb.append("{");
191 sb.append("\n");
192 for (int i = 0; i < indentLevel + 1; i++) {
193 sb.append("\t");
194 }
195 if (band != null) {
196 sb.append("\"band\":").append(band);
197 }
198
199 sb.append(",\n");
200 for (int i = 0; i < indentLevel + 1; i++) {
201 sb.append("\t");
202 }
203 if (caclassdl != null) {
204 sb.append("\"caclassdl\":").append(caclassdl);
205 }
206
207 sb.append(",\n");
208 for (int i = 0; i < indentLevel + 1; i++) {
209 sb.append("\t");
210 }
211 if (caclassul != null) {
212 sb.append("\"caclassul\":").append(caclassul);
213 }
214
215 sb.append(",\n");
216 for (int i = 0; i < indentLevel + 1; i++) {
217 sb.append("\t");
218 }
219 if (crossCarrierSched != null) {
220 sb.append("\"crossCarrierSched\":").append(crossCarrierSched);
221 }
222
223 sb.append("\n");
224 for (int i = 0; i < indentLevel; i++) {
225 sb.append("\t");
226 }
227 sb.append("}");
228 }
229
230}
231