blob: 7079944424da960c2c1d5bc28af019b433025df2 [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.pdu;
6
7import org.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.ECGI;
9import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
10import org.openmuc.jasn1.ber.BerLength;
11import org.openmuc.jasn1.ber.BerTag;
12
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.Serializable;
16
17public class HORequest implements Serializable {
18
19 private static final long serialVersionUID = 1L;
20
21 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
22
23 public byte[] code = null;
24 private CRNTI crnti = null;
25 private ECGI ecgiS = null;
26 private ECGI ecgiT = null;
27
28 public HORequest() {
29 }
30
31 public HORequest(byte[] code) {
32 this.code = code;
33 }
34
35 public void setCrnti(CRNTI crnti) {
36 this.crnti = crnti;
37 }
38
39 public CRNTI getCrnti() {
40 return crnti;
41 }
42
43 public void setEcgiS(ECGI ecgiS) {
44 this.ecgiS = ecgiS;
45 }
46
47 public ECGI getEcgiS() {
48 return ecgiS;
49 }
50
51 public void setEcgiT(ECGI ecgiT) {
52 this.ecgiT = ecgiT;
53 }
54
55 public ECGI getEcgiT() {
56 return ecgiT;
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 codeLength += ecgiT.encode(os, false);
77 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
78 os.write(0xA2);
79 codeLength += 1;
80
81 codeLength += ecgiS.encode(os, false);
82 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
83 os.write(0xA1);
84 codeLength += 1;
85
86 codeLength += crnti.encode(os, false);
87 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
88 os.write(0x80);
89 codeLength += 1;
90
91 codeLength += BerLength.encodeLength(os, codeLength);
92
93 if (withTag) {
94 codeLength += tag.encode(os);
95 }
96
97 return codeLength;
98
99 }
100
101 public int decode(InputStream is) throws IOException {
102 return decode(is, true);
103 }
104
105 public int decode(InputStream is, boolean withTag) throws IOException {
106 int codeLength = 0;
107 int subCodeLength = 0;
108 BerTag berTag = new BerTag();
109
110 if (withTag) {
111 codeLength += tag.decodeAndCheck(is);
112 }
113
114 BerLength length = new BerLength();
115 codeLength += length.decode(is);
116
117 int totalLength = length.val;
118 codeLength += totalLength;
119
120 subCodeLength += berTag.decode(is);
121 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
122 crnti = new CRNTI();
123 subCodeLength += crnti.decode(is, false);
124 subCodeLength += berTag.decode(is);
125 }
126 else {
127 throw new IOException("Tag does not match the mandatory sequence element tag.");
128 }
129
130 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
131 ecgiS = new ECGI();
132 subCodeLength += ecgiS.decode(is, false);
133 subCodeLength += berTag.decode(is);
134 }
135 else {
136 throw new IOException("Tag does not match the mandatory sequence element tag.");
137 }
138
139 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
140 ecgiT = new ECGI();
141 subCodeLength += ecgiT.decode(is, false);
142 if (subCodeLength == totalLength) {
143 return codeLength;
144 }
145 }
146 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
147
148
149 }
150
151 public void encodeAndSave(int encodingSizeGuess) throws IOException {
152 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
153 encode(os, false);
154 code = os.getArray();
155 }
156
157 public String toString() {
158 StringBuilder sb = new StringBuilder();
159 appendAsString(sb, 0);
160 return sb.toString();
161 }
162
163 public void appendAsString(StringBuilder sb, int indentLevel) {
164
165 sb.append("{");
166 sb.append("\n");
167 for (int i = 0; i < indentLevel + 1; i++) {
168 sb.append("\t");
169 }
170 if (crnti != null) {
171 sb.append("\"crnti\": ").append(crnti);
172 }
173
174 sb.append(",\n");
175 for (int i = 0; i < indentLevel + 1; i++) {
176 sb.append("\t");
177 }
178 if (ecgiS != null) {
179 sb.append("\"ecgiS\": ");
180 ecgiS.appendAsString(sb, indentLevel + 1);
181 }
182
183 sb.append(",\n");
184 for (int i = 0; i < indentLevel + 1; i++) {
185 sb.append("\t");
186 }
187 if (ecgiT != null) {
188 sb.append("\"ecgiT\": ");
189 ecgiT.appendAsString(sb, indentLevel + 1);
190 }
191
192 sb.append("\n");
193 for (int i = 0; i < indentLevel; i++) {
194 sb.append("\t");
195 }
196 sb.append("}");
197 }
198
199}
200