blob: c903fd61858ff4bf001b36aa61ae835baf43be1a [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
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
8import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
9import org.onosproject.xran.codecs.ber.BerLength;
10import org.onosproject.xran.codecs.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070011
12import java.io.IOException;
13import java.io.InputStream;
14import java.io.Serializable;
15
16
17public class ECGI implements Serializable {
18
19 private static final long serialVersionUID = 1L;
20
21 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
22
slowr60d4d102017-08-16 18:33:58 -070023 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070024 public byte[] code = null;
25 private PLMNIdentity pLMNIdentity = null;
26 private EUTRANCellIdentifier eUTRANcellIdentifier = null;
27
28 public ECGI() {
29 }
30
31 public ECGI(byte[] code) {
32 this.code = code;
33 }
34
35 public void setPLMNIdentity(PLMNIdentity pLMNIdentity) {
36 this.pLMNIdentity = pLMNIdentity;
37 }
38
39 public PLMNIdentity getPLMNIdentity() {
40 return pLMNIdentity;
41 }
42
43 public void setEUTRANcellIdentifier(EUTRANCellIdentifier eUTRANcellIdentifier) {
44 this.eUTRANcellIdentifier = eUTRANcellIdentifier;
45 }
46
47 public EUTRANCellIdentifier getEUTRANcellIdentifier() {
48 return eUTRANcellIdentifier;
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 += eUTRANcellIdentifier.encode(os, false);
69 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
70 os.write(0x81);
71 codeLength += 1;
72
73 codeLength += pLMNIdentity.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 pLMNIdentity = new PLMNIdentity();
110 subCodeLength += pLMNIdentity.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.PRIMITIVE, 1)) {
118 eUTRANcellIdentifier = new EUTRANCellIdentifier();
119 subCodeLength += eUTRANcellIdentifier.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 (pLMNIdentity != null) {
slowr60d4d102017-08-16 18:33:58 -0700149 sb.append("pLMNIdentity: ").append(pLMNIdentity);
slowr13fa5b02017-08-08 16:32:31 -0700150 }
151
152 sb.append(",\n");
153 for (int i = 0; i < indentLevel + 1; i++) {
154 sb.append("\t");
155 }
156 if (eUTRANcellIdentifier != null) {
slowr60d4d102017-08-16 18:33:58 -0700157 sb.append("eUTRANcellIdentifier: ").append(eUTRANcellIdentifier);
slowr13fa5b02017-08-08 16:32:31 -0700158 }
159
160 sb.append("\n");
161 for (int i = 0; i < indentLevel; i++) {
162 sb.append("\t");
163 }
164 sb.append("}");
165 }
166
167 @Override
168 public boolean equals(Object o) {
169 if (this == o) return true;
170 if (o == null || getClass() != o.getClass()) return false;
171
172 ECGI ecgi = (ECGI) o;
173
174 return eUTRANcellIdentifier.equals(ecgi.eUTRANcellIdentifier);
175 }
176
177 @Override
178 public int hashCode() {
179 return eUTRANcellIdentifier.hashCode();
180 }
181}
182