blob: 84758d1a4f56510fe27dc89267ce6b414365b832 [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 */
4
5package org.onosproject.xran.codecs.pdu;
6
7import org.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.ECGI;
9import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
10import org.openmuc.jasn1.ber.BerLength;
11import org.openmuc.jasn1.ber.BerTag;
12
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.Serializable;
16
17
18public class UECapabilityEnquiry 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
24 public byte[] code = null;
25 private CRNTI crnti = null;
26 private ECGI ecgi = null;
27
28 public UECapabilityEnquiry() {
29 }
30
31 public UECapabilityEnquiry(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 int encode(BerByteArrayOutputStream os) throws IOException {
52 return encode(os, true);
53 }
54
55 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
56
57 if (code != null) {
58 for (int i = code.length - 1; i >= 0; i--) {
59 os.write(code[i]);
60 }
61 if (withTag) {
62 return tag.encode(os) + code.length;
63 }
64 return code.length;
65 }
66
67 int codeLength = 0;
68 codeLength += ecgi.encode(os, false);
69 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
70 os.write(0xA1);
71 codeLength += 1;
72
73 codeLength += crnti.encode(os, false);
74 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
75 os.write(0x80);
76 codeLength += 1;
77
78 codeLength += BerLength.encodeLength(os, codeLength);
79
80 if (withTag) {
81 codeLength += tag.encode(os);
82 }
83
84 return codeLength;
85
86 }
87
88 public int decode(InputStream is) throws IOException {
89 return decode(is, true);
90 }
91
92 public int decode(InputStream is, boolean withTag) throws IOException {
93 int codeLength = 0;
94 int subCodeLength = 0;
95 BerTag berTag = new BerTag();
96
97 if (withTag) {
98 codeLength += tag.decodeAndCheck(is);
99 }
100
101 BerLength length = new BerLength();
102 codeLength += length.decode(is);
103
104 int totalLength = length.val;
105 codeLength += totalLength;
106
107 subCodeLength += berTag.decode(is);
108 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
109 crnti = new CRNTI();
110 subCodeLength += crnti.decode(is, false);
111 subCodeLength += berTag.decode(is);
112 }
113 else {
114 throw new IOException("Tag does not match the mandatory sequence element tag.");
115 }
116
117 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
118 ecgi = new ECGI();
119 subCodeLength += ecgi.decode(is, false);
120 if (subCodeLength == totalLength) {
121 return codeLength;
122 }
123 }
124 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
125
126
127 }
128
129 public void encodeAndSave(int encodingSizeGuess) throws IOException {
130 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
131 encode(os, false);
132 code = os.getArray();
133 }
134
135 public String toString() {
136 StringBuilder sb = new StringBuilder();
137 appendAsString(sb, 0);
138 return sb.toString();
139 }
140
141 public void appendAsString(StringBuilder sb, int indentLevel) {
142
143 sb.append("{");
144 sb.append("\n");
145 for (int i = 0; i < indentLevel + 1; i++) {
146 sb.append("\t");
147 }
148 if (crnti != null) {
149 sb.append("\"crnti\": ").append(crnti);
150 }
151
152 sb.append(",\n");
153 for (int i = 0; i < indentLevel + 1; i++) {
154 sb.append("\t");
155 }
156 if (ecgi != null) {
157 sb.append("\"ecgi\": ");
158 ecgi.appendAsString(sb, indentLevel + 1);
159 }
160
161 sb.append("\n");
162 for (int i = 0; i < indentLevel; i++) {
163 sb.append("\t");
164 }
165 sb.append("}");
166 }
167
168}
169