blob: 35fc047b82b12e3764418d4afeb3e1927759c418 [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
7import com.fasterxml.jackson.annotation.JsonIgnore;
8import org.onosproject.xran.asn1lib.api.CRNTI;
9import org.onosproject.xran.asn1lib.api.ECGI;
10import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
11import org.onosproject.xran.asn1lib.ber.BerLength;
12import org.onosproject.xran.asn1lib.ber.BerTag;
13
14import java.io.IOException;
15import java.io.InputStream;
16import java.io.Serializable;
17
18public class SeNBDelete implements Serializable {
19
20 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
21 private static final long serialVersionUID = 1L;
22 @JsonIgnore
23 public byte[] code = null;
24 private CRNTI crnti = null;
25 private ECGI mEcgi = null;
26 private ECGI sEcgi = null;
27
28 public SeNBDelete() {
29 }
30
31 public SeNBDelete(byte[] code) {
32 this.code = code;
33 }
34
35 public CRNTI getCrnti() {
36 return crnti;
37 }
38
39 public void setCrnti(CRNTI crnti) {
40 this.crnti = crnti;
41 }
42
43 public ECGI getMEcgi() {
44 return mEcgi;
45 }
46
47 public void setMEcgi(ECGI mEcgi) {
48 this.mEcgi = mEcgi;
49 }
50
51 public ECGI getSEcgi() {
52 return sEcgi;
53 }
54
55 public void setSEcgi(ECGI sEcgi) {
56 this.sEcgi = sEcgi;
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 += sEcgi.encode(os, false);
77 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
78 os.write(0xA2);
79 codeLength += 1;
80
81 codeLength += mEcgi.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 } else {
126 throw new IOException("Tag does not match the mandatory sequence element tag.");
127 }
128
129 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
130 mEcgi = new ECGI();
131 subCodeLength += mEcgi.decode(is, false);
132 subCodeLength += berTag.decode(is);
133 } else {
134 throw new IOException("Tag does not match the mandatory sequence element tag.");
135 }
136
137 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
138 sEcgi = new ECGI();
139 subCodeLength += sEcgi.decode(is, false);
140 if (subCodeLength == totalLength) {
141 return codeLength;
142 }
143 }
144 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
145
146
147 }
148
149 public void encodeAndSave(int encodingSizeGuess) throws IOException {
150 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
151 encode(os, false);
152 code = os.getArray();
153 }
154
155 public String toString() {
156 StringBuilder sb = new StringBuilder();
157 appendAsString(sb, 0);
158 return sb.toString();
159 }
160
161 public void appendAsString(StringBuilder sb, int indentLevel) {
162
163 sb.append("{");
164 sb.append("\n");
165 for (int i = 0; i < indentLevel + 1; i++) {
166 sb.append("\t");
167 }
168 if (crnti != null) {
169 sb.append("crnti: ").append(crnti);
170 } else {
171 sb.append("crnti: <empty-required-field>");
172 }
173
174 sb.append(",\n");
175 for (int i = 0; i < indentLevel + 1; i++) {
176 sb.append("\t");
177 }
178 if (mEcgi != null) {
179 sb.append("mEcgi: ");
180 mEcgi.appendAsString(sb, indentLevel + 1);
181 } else {
182 sb.append("mEcgi: <empty-required-field>");
183 }
184
185 sb.append(",\n");
186 for (int i = 0; i < indentLevel + 1; i++) {
187 sb.append("\t");
188 }
189 if (sEcgi != null) {
190 sb.append("sEcgi: ");
191 sEcgi.appendAsString(sb, indentLevel + 1);
192 } else {
193 sb.append("sEcgi: <empty-required-field>");
194 }
195
196 sb.append("\n");
197 for (int i = 0; i < indentLevel; i++) {
198 sb.append("\t");
199 }
200 sb.append("}");
201 }
202
203}
204