blob: 14b9dc5352df9e89ac41b80d2001dce46d7f9cfb [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
slowr60d4d102017-08-16 18:33:58 -07006import com.fasterxml.jackson.annotation.JsonIgnore;
slowr13fa5b02017-08-08 16:32:31 -07007import org.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.ECGI;
slowr60d4d102017-08-16 18:33:58 -07009import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
10import org.onosproject.xran.codecs.ber.BerLength;
11import org.onosproject.xran.codecs.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070012
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.Serializable;
16
17
18public class SeNBDelete 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
slowr60d4d102017-08-16 18:33:58 -070024 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070025 public byte[] code = null;
26 private CRNTI crnti = null;
27 private ECGI mEcgi = null;
28 private ECGI sEcgi = null;
29
30 public SeNBDelete() {
31 }
32
33 public SeNBDelete(byte[] code) {
34 this.code = code;
35 }
36
37 public void setCrnti(CRNTI crnti) {
38 this.crnti = crnti;
39 }
40
41 public CRNTI getCrnti() {
42 return crnti;
43 }
44
45 public void setMEcgi(ECGI mEcgi) {
46 this.mEcgi = mEcgi;
47 }
48
49 public ECGI getMEcgi() {
50 return mEcgi;
51 }
52
53 public void setSEcgi(ECGI sEcgi) {
54 this.sEcgi = sEcgi;
55 }
56
57 public ECGI getSEcgi() {
58 return sEcgi;
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 += sEcgi.encode(os, false);
79 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
80 os.write(0xA2);
81 codeLength += 1;
82
83 codeLength += mEcgi.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 }
128 else {
129 throw new IOException("Tag does not match the mandatory sequence element tag.");
130 }
131
132 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
133 mEcgi = new ECGI();
134 subCodeLength += mEcgi.decode(is, false);
135 subCodeLength += berTag.decode(is);
136 }
137 else {
138 throw new IOException("Tag does not match the mandatory sequence element tag.");
139 }
140
141 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
142 sEcgi = new ECGI();
143 subCodeLength += sEcgi.decode(is, false);
144 if (subCodeLength == totalLength) {
145 return codeLength;
146 }
147 }
148 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
149
150
151 }
152
153 public void encodeAndSave(int encodingSizeGuess) throws IOException {
154 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
155 encode(os, false);
156 code = os.getArray();
157 }
158
159 public String toString() {
160 StringBuilder sb = new StringBuilder();
161 appendAsString(sb, 0);
162 return sb.toString();
163 }
164
165 public void appendAsString(StringBuilder sb, int indentLevel) {
166
167 sb.append("{");
168 sb.append("\n");
169 for (int i = 0; i < indentLevel + 1; i++) {
170 sb.append("\t");
171 }
172 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700173 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700174 }
175
176 sb.append(",\n");
177 for (int i = 0; i < indentLevel + 1; i++) {
178 sb.append("\t");
179 }
180 if (mEcgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700181 sb.append("mEcgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700182 mEcgi.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 (sEcgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700190 sb.append("sEcgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700191 sEcgi.appendAsString(sb, indentLevel + 1);
192 }
193
194 sb.append("\n");
195 for (int i = 0; i < indentLevel; i++) {
196 sb.append("\t");
197 }
198 sb.append("}");
199 }
200
201}
202