blob: 01789f2bdf0296245ca1916731356114feb2ed2c [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.api;
6
7import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
8import org.openmuc.jasn1.ber.BerLength;
9import org.openmuc.jasn1.ber.BerTag;
10
11import java.io.IOException;
12import java.io.InputStream;
13import java.io.Serializable;
14
15
16public class ECGI 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 PLMNIdentity pLMNIdentity = null;
24 private EUTRANCellIdentifier eUTRANcellIdentifier = null;
25
26 public ECGI() {
27 }
28
29 public ECGI(byte[] code) {
30 this.code = code;
31 }
32
33 public void setPLMNIdentity(PLMNIdentity pLMNIdentity) {
34 this.pLMNIdentity = pLMNIdentity;
35 }
36
37 public PLMNIdentity getPLMNIdentity() {
38 return pLMNIdentity;
39 }
40
41 public void setEUTRANcellIdentifier(EUTRANCellIdentifier eUTRANcellIdentifier) {
42 this.eUTRANcellIdentifier = eUTRANcellIdentifier;
43 }
44
45 public EUTRANCellIdentifier getEUTRANcellIdentifier() {
46 return eUTRANcellIdentifier;
47 }
48
49 public int encode(BerByteArrayOutputStream os) throws IOException {
50 return encode(os, true);
51 }
52
53 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
54
55 if (code != null) {
56 for (int i = code.length - 1; i >= 0; i--) {
57 os.write(code[i]);
58 }
59 if (withTag) {
60 return tag.encode(os) + code.length;
61 }
62 return code.length;
63 }
64
65 int codeLength = 0;
66 codeLength += eUTRANcellIdentifier.encode(os, false);
67 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
68 os.write(0x81);
69 codeLength += 1;
70
71 codeLength += pLMNIdentity.encode(os, false);
72 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
73 os.write(0x80);
74 codeLength += 1;
75
76 codeLength += BerLength.encodeLength(os, codeLength);
77
78 if (withTag) {
79 codeLength += tag.encode(os);
80 }
81
82 return codeLength;
83
84 }
85
86 public int decode(InputStream is) throws IOException {
87 return decode(is, true);
88 }
89
90 public int decode(InputStream is, boolean withTag) throws IOException {
91 int codeLength = 0;
92 int subCodeLength = 0;
93 BerTag berTag = new BerTag();
94
95 if (withTag) {
96 codeLength += tag.decodeAndCheck(is);
97 }
98
99 BerLength length = new BerLength();
100 codeLength += length.decode(is);
101
102 int totalLength = length.val;
103 codeLength += totalLength;
104
105 subCodeLength += berTag.decode(is);
106 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
107 pLMNIdentity = new PLMNIdentity();
108 subCodeLength += pLMNIdentity.decode(is, false);
109 subCodeLength += berTag.decode(is);
110 }
111 else {
112 throw new IOException("Tag does not match the mandatory sequence element tag.");
113 }
114
115 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
116 eUTRANcellIdentifier = new EUTRANCellIdentifier();
117 subCodeLength += eUTRANcellIdentifier.decode(is, false);
118 if (subCodeLength == totalLength) {
119 return codeLength;
120 }
121 }
122 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
123
124
125 }
126
127 public void encodeAndSave(int encodingSizeGuess) throws IOException {
128 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
129 encode(os, false);
130 code = os.getArray();
131 }
132
133 public String toString() {
134 StringBuilder sb = new StringBuilder();
135 appendAsString(sb, 0);
136 return sb.toString();
137 }
138
139 public void appendAsString(StringBuilder sb, int indentLevel) {
140
141 sb.append("{");
142 sb.append("\n");
143 for (int i = 0; i < indentLevel + 1; i++) {
144 sb.append("\t");
145 }
146 if (pLMNIdentity != null) {
147 sb.append("\"pLMNIdentity\": ").append(pLMNIdentity);
148 }
149
150 sb.append(",\n");
151 for (int i = 0; i < indentLevel + 1; i++) {
152 sb.append("\t");
153 }
154 if (eUTRANcellIdentifier != null) {
155 sb.append("\"eUTRANcellIdentifier\": ").append(eUTRANcellIdentifier);
156 }
157
158 sb.append("\n");
159 for (int i = 0; i < indentLevel; i++) {
160 sb.append("\t");
161 }
162 sb.append("}");
163 }
164
165 @Override
166 public boolean equals(Object o) {
167 if (this == o) return true;
168 if (o == null || getClass() != o.getClass()) return false;
169
170 ECGI ecgi = (ECGI) o;
171
172 return eUTRANcellIdentifier.equals(ecgi.eUTRANcellIdentifier);
173 }
174
175 @Override
176 public int hashCode() {
177 return eUTRANcellIdentifier.hashCode();
178 }
179}
180