blob: 9b601adb199818df1951331e3636aa1b8efb1028 [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 */
4package org.onosproject.xran.codecs.pdu;
5
6import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
7import org.openmuc.jasn1.ber.BerLength;
8import org.openmuc.jasn1.ber.BerTag;
9import org.onosproject.xran.codecs.api.CRNTI;
10import org.onosproject.xran.codecs.api.ECGI;
11import org.onosproject.xran.codecs.api.RelCause;
12
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.Serializable;
16
17public class UEReleaseInd 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 ecgi = null;
26 private RelCause releaseCause = null;
27
28 public UEReleaseInd() {
29 }
30
31 public UEReleaseInd(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 setEcgi(ECGI ecgi) {
44 this.ecgi = ecgi;
45 }
46
47 public ECGI getEcgi() {
48 return ecgi;
49 }
50
51 public void setReleaseCause(RelCause releaseCause) {
52 this.releaseCause = releaseCause;
53 }
54
55 public RelCause getReleaseCause() {
56 return releaseCause;
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 += releaseCause.encode(os, false);
77 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
78 os.write(0x82);
79 codeLength += 1;
80
81 codeLength += ecgi.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 ecgi = new ECGI();
132 subCodeLength += ecgi.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.PRIMITIVE, 2)) {
140 releaseCause = new RelCause();
141 subCodeLength += releaseCause.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 (ecgi != null) {
179 sb.append("\"ecgi\": ");
180 ecgi.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 (releaseCause != null) {
188 sb.append("\"releaseCause\": ").append(releaseCause);
189 }
190
191 sb.append("\n");
192 for (int i = 0; i < indentLevel; i++) {
193 sb.append("\t");
194 }
195 sb.append("}");
196 }
197
198}
199