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