blob: 9b96818f100313c2151495aad37d77985e098422 [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.pdu;
6
7
8import com.fasterxml.jackson.annotation.JsonIgnore;
9import org.onosproject.xran.asn1lib.api.CRNTI;
10import org.onosproject.xran.asn1lib.api.ECGI;
11import org.onosproject.xran.asn1lib.api.HOFailureCause;
12import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
13import org.onosproject.xran.asn1lib.ber.BerLength;
14import org.onosproject.xran.asn1lib.ber.BerTag;
15
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
19
20public class HOFailure implements Serializable {
21
22 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
23 private static final long serialVersionUID = 1L;
24 @JsonIgnore
25 public byte[] code = null;
26 private CRNTI crnti = null;
27 private ECGI ecgi = null;
28 private HOFailureCause cause = null;
29
30 public HOFailure() {
31 }
32
33 public HOFailure(byte[] code) {
34 this.code = code;
35 }
36
37 public CRNTI getCrnti() {
38 return crnti;
39 }
40
41 public void setCrnti(CRNTI crnti) {
42 this.crnti = crnti;
43 }
44
45 public ECGI getEcgi() {
46 return ecgi;
47 }
48
49 public void setEcgi(ECGI ecgi) {
50 this.ecgi = ecgi;
51 }
52
53 public HOFailureCause getCause() {
54 return cause;
55 }
56
57 public void setCause(HOFailureCause cause) {
58 this.cause = cause;
59 }
60
61 public int encode(BerByteArrayOutputStream os) throws IOException {
62 return encode(os, true);
63 }
64
65 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
66
67 if (code != null) {
68 for (int i = code.length - 1; i >= 0; i--) {
69 os.write(code[i]);
70 }
71 if (withTag) {
72 return tag.encode(os) + code.length;
73 }
74 return code.length;
75 }
76
77 int codeLength = 0;
78 codeLength += cause.encode(os, false);
79 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
80 os.write(0x82);
81 codeLength += 1;
82
83 codeLength += ecgi.encode(os, false);
84 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
85 os.write(0xA1);
86 codeLength += 1;
87
88 codeLength += crnti.encode(os, false);
89 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
90 os.write(0x80);
91 codeLength += 1;
92
93 codeLength += BerLength.encodeLength(os, codeLength);
94
95 if (withTag) {
96 codeLength += tag.encode(os);
97 }
98
99 return codeLength;
100
101 }
102
103 public int decode(InputStream is) throws IOException {
104 return decode(is, true);
105 }
106
107 public int decode(InputStream is, boolean withTag) throws IOException {
108 int codeLength = 0;
109 int subCodeLength = 0;
110 BerTag berTag = new BerTag();
111
112 if (withTag) {
113 codeLength += tag.decodeAndCheck(is);
114 }
115
116 BerLength length = new BerLength();
117 codeLength += length.decode(is);
118
119 int totalLength = length.val;
120 codeLength += totalLength;
121
122 subCodeLength += berTag.decode(is);
123 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
124 crnti = new CRNTI();
125 subCodeLength += crnti.decode(is, false);
126 subCodeLength += berTag.decode(is);
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 ecgi = new ECGI();
133 subCodeLength += ecgi.decode(is, false);
134 subCodeLength += berTag.decode(is);
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.PRIMITIVE, 2)) {
140 cause = new HOFailureCause();
141 subCodeLength += cause.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 } else {
173 sb.append("crnti: <empty-required-field>");
174 }
175
176 sb.append(",\n");
177 for (int i = 0; i < indentLevel + 1; i++) {
178 sb.append("\t");
179 }
180 if (ecgi != null) {
181 sb.append("ecgi: ");
182 ecgi.appendAsString(sb, indentLevel + 1);
183 } else {
184 sb.append("ecgi: <empty-required-field>");
185 }
186
187 sb.append(",\n");
188 for (int i = 0; i < indentLevel + 1; i++) {
189 sb.append("\t");
190 }
191 if (cause != null) {
192 sb.append("cause: ").append(cause);
193 } else {
194 sb.append("cause: <empty-required-field>");
195 }
196
197 sb.append("\n");
198 for (int i = 0; i < indentLevel; i++) {
199 sb.append("\t");
200 }
201 sb.append("}");
202 }
203
204}
205