blob: 878ae61d3446eeec1f9401ac7d13642d370b7796 [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;
11
12import java.io.IOException;
13import java.io.InputStream;
14import java.io.Serializable;
15
16
17public class A5Param implements Serializable {
18
19 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
20 private static final long serialVersionUID = 1L;
21 @JsonIgnore
22 public byte[] code = null;
23 private ThresholdEUTRA a5Threshold1 = null;
24 private ThresholdEUTRA a5Threshold2 = null;
25
26 public A5Param() {
27 }
28
29 public A5Param(byte[] code) {
30 this.code = code;
31 }
32
33 public ThresholdEUTRA getA5Threshold1() {
34 return a5Threshold1;
35 }
36
37 public void setA5Threshold1(ThresholdEUTRA a5Threshold1) {
38 this.a5Threshold1 = a5Threshold1;
39 }
40
41 public ThresholdEUTRA getA5Threshold2() {
42 return a5Threshold2;
43 }
44
45 public void setA5Threshold2(ThresholdEUTRA a5Threshold2) {
46 this.a5Threshold2 = a5Threshold2;
47 }
48
49 public int encode(BerByteArrayOutputStream os) throws IOException {
50 return encode(os, true);
51 }
52
53 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
54
55 if (code != null) {
56 for (int i = code.length - 1; i >= 0; i--) {
57 os.write(code[i]);
58 }
59 if (withTag) {
60 return tag.encode(os) + code.length;
61 }
62 return code.length;
63 }
64
65 int codeLength = 0;
66 int sublength;
67
68 sublength = a5Threshold2.encode(os);
69 codeLength += sublength;
70 codeLength += BerLength.encodeLength(os, sublength);
71 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
72 os.write(0xA1);
73 codeLength += 1;
74
75 sublength = a5Threshold1.encode(os);
76 codeLength += sublength;
77 codeLength += BerLength.encodeLength(os, sublength);
78 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
79 os.write(0xA0);
80 codeLength += 1;
81
82 codeLength += BerLength.encodeLength(os, codeLength);
83
84 if (withTag) {
85 codeLength += tag.encode(os);
86 }
87
88 return codeLength;
89
90 }
91
92 public int decode(InputStream is) throws IOException {
93 return decode(is, true);
94 }
95
96 public int decode(InputStream is, boolean withTag) throws IOException {
97 int codeLength = 0;
98 int subCodeLength = 0;
99 BerTag berTag = new BerTag();
100
101 if (withTag) {
102 codeLength += tag.decodeAndCheck(is);
103 }
104
105 BerLength length = new BerLength();
106 codeLength += length.decode(is);
107
108 int totalLength = length.val;
109 codeLength += totalLength;
110
111 subCodeLength += berTag.decode(is);
112 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
113 subCodeLength += length.decode(is);
114 a5Threshold1 = new ThresholdEUTRA();
115 subCodeLength += a5Threshold1.decode(is, null);
116 subCodeLength += berTag.decode(is);
117 } else {
118 throw new IOException("Tag does not match the mandatory sequence element tag.");
119 }
120
121 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
122 subCodeLength += length.decode(is);
123 a5Threshold2 = new ThresholdEUTRA();
124 subCodeLength += a5Threshold2.decode(is, null);
125 if (subCodeLength == totalLength) {
126 return codeLength;
127 }
128 }
129 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
130
131
132 }
133
134 public void encodeAndSave(int encodingSizeGuess) throws IOException {
135 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
136 encode(os, false);
137 code = os.getArray();
138 }
139
140 public String toString() {
141 StringBuilder sb = new StringBuilder();
142 appendAsString(sb, 0);
143 return sb.toString();
144 }
145
146 public void appendAsString(StringBuilder sb, int indentLevel) {
147
148 sb.append("{");
149 sb.append("\n");
150 for (int i = 0; i < indentLevel + 1; i++) {
151 sb.append("\t");
152 }
153 if (a5Threshold1 != null) {
154 sb.append("a5Threshold1: ");
155 a5Threshold1.appendAsString(sb, indentLevel + 1);
156 } else {
157 sb.append("a5Threshold1: <empty-required-field>");
158 }
159
160 sb.append(",\n");
161 for (int i = 0; i < indentLevel + 1; i++) {
162 sb.append("\t");
163 }
164 if (a5Threshold2 != null) {
165 sb.append("a5Threshold2: ");
166 a5Threshold2.appendAsString(sb, indentLevel + 1);
167 } else {
168 sb.append("a5Threshold2: <empty-required-field>");
169 }
170
171 sb.append("\n");
172 for (int i = 0; i < indentLevel; i++) {
173 sb.append("\t");
174 }
175 sb.append("}");
176 }
177
178}
179