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