blob: 7a442832b163481a13dee0049c5455879d21a848 [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 PCIARFCN implements Serializable {
18
slowr577f3222017-08-28 10:49:08 -070019 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
20 private static final long serialVersionUID = 1L;
21 @JsonIgnore
22 public byte[] code = null;
23 private PhysCellId pci = null;
24 private ARFCNValue earfcnDl = null;
slowr13fa5b02017-08-08 16:32:31 -070025
slowr577f3222017-08-28 10:49:08 -070026 public PCIARFCN() {
27 }
slowr13fa5b02017-08-08 16:32:31 -070028
slowr577f3222017-08-28 10:49:08 -070029 public PCIARFCN(byte[] code) {
30 this.code = code;
31 }
slowr13fa5b02017-08-08 16:32:31 -070032
slowr577f3222017-08-28 10:49:08 -070033 public static PCIARFCN valueOf(PhysCellId pci, ARFCNValue arfcnValue) {
34 PCIARFCN pciarfcn = new PCIARFCN();
35 pciarfcn.setEarfcnDl(arfcnValue);
36 pciarfcn.setPci(pci);
37 return pciarfcn;
38 }
slowr13fa5b02017-08-08 16:32:31 -070039
slowr577f3222017-08-28 10:49:08 -070040 public PhysCellId getPci() {
41 return pci;
42 }
slowr13fa5b02017-08-08 16:32:31 -070043
slowr577f3222017-08-28 10:49:08 -070044 public void setPci(PhysCellId pci) {
45 this.pci = pci;
46 }
slowr13fa5b02017-08-08 16:32:31 -070047
slowr577f3222017-08-28 10:49:08 -070048 public ARFCNValue getEarfcnDl() {
49 return earfcnDl;
50 }
slowr13fa5b02017-08-08 16:32:31 -070051
slowr577f3222017-08-28 10:49:08 -070052 public void setEarfcnDl(ARFCNValue earfcnDl) {
53 this.earfcnDl = earfcnDl;
54 }
slowr13fa5b02017-08-08 16:32:31 -070055
slowr577f3222017-08-28 10:49:08 -070056 public int encode(BerByteArrayOutputStream os) throws IOException {
57 return encode(os, true);
58 }
slowr13fa5b02017-08-08 16:32:31 -070059
slowr577f3222017-08-28 10:49:08 -070060 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -070061
slowr577f3222017-08-28 10:49:08 -070062 if (code != null) {
63 for (int i = code.length - 1; i >= 0; i--) {
64 os.write(code[i]);
65 }
66 if (withTag) {
67 return tag.encode(os) + code.length;
68 }
69 return code.length;
70 }
slowr13fa5b02017-08-08 16:32:31 -070071
slowr577f3222017-08-28 10:49:08 -070072 int codeLength = 0;
73 codeLength += earfcnDl.encode(os, false);
74 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
75 os.write(0x81);
76 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070077
slowr577f3222017-08-28 10:49:08 -070078 codeLength += pci.encode(os, false);
79 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
80 os.write(0x80);
81 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070082
slowr577f3222017-08-28 10:49:08 -070083 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -070084
slowr577f3222017-08-28 10:49:08 -070085 if (withTag) {
86 codeLength += tag.encode(os);
87 }
slowr13fa5b02017-08-08 16:32:31 -070088
slowr577f3222017-08-28 10:49:08 -070089 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -070090
slowr577f3222017-08-28 10:49:08 -070091 }
slowr13fa5b02017-08-08 16:32:31 -070092
slowr577f3222017-08-28 10:49:08 -070093 public int decode(InputStream is) throws IOException {
94 return decode(is, true);
95 }
slowr13fa5b02017-08-08 16:32:31 -070096
slowr577f3222017-08-28 10:49:08 -070097 public int decode(InputStream is, boolean withTag) throws IOException {
98 int codeLength = 0;
99 int subCodeLength = 0;
100 BerTag berTag = new BerTag();
slowr13fa5b02017-08-08 16:32:31 -0700101
slowr577f3222017-08-28 10:49:08 -0700102 if (withTag) {
103 codeLength += tag.decodeAndCheck(is);
104 }
slowr13fa5b02017-08-08 16:32:31 -0700105
slowr577f3222017-08-28 10:49:08 -0700106 BerLength length = new BerLength();
107 codeLength += length.decode(is);
slowr13fa5b02017-08-08 16:32:31 -0700108
slowr577f3222017-08-28 10:49:08 -0700109 int totalLength = length.val;
110 codeLength += totalLength;
slowr13fa5b02017-08-08 16:32:31 -0700111
slowr577f3222017-08-28 10:49:08 -0700112 subCodeLength += berTag.decode(is);
113 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
114 pci = new PhysCellId();
115 subCodeLength += pci.decode(is, false);
116 subCodeLength += berTag.decode(is);
117 } else {
118 throw new IOException("Tag does not match the mandatory sequence element tag.");
119 }
slowr13fa5b02017-08-08 16:32:31 -0700120
slowr577f3222017-08-28 10:49:08 -0700121 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
122 earfcnDl = new ARFCNValue();
123 subCodeLength += earfcnDl.decode(is, false);
124 if (subCodeLength == totalLength) {
125 return codeLength;
126 }
127 }
128 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
slowr13fa5b02017-08-08 16:32:31 -0700129
slowr13fa5b02017-08-08 16:32:31 -0700130
slowr577f3222017-08-28 10:49:08 -0700131 }
slowr13fa5b02017-08-08 16:32:31 -0700132
slowr577f3222017-08-28 10:49:08 -0700133 public void encodeAndSave(int encodingSizeGuess) throws IOException {
134 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
135 encode(os, false);
136 code = os.getArray();
137 }
slowr13fa5b02017-08-08 16:32:31 -0700138
slowr577f3222017-08-28 10:49:08 -0700139 public String toString() {
140 StringBuilder sb = new StringBuilder();
141 appendAsString(sb, 0);
142 return sb.toString();
143 }
slowr13fa5b02017-08-08 16:32:31 -0700144
slowr577f3222017-08-28 10:49:08 -0700145 public void appendAsString(StringBuilder sb, int indentLevel) {
146
147 sb.append("{");
148 sb.append("\n");
149 for (int i = 0; i < indentLevel + 1; i++) {
150 sb.append("\t");
151 }
152 if (pci != null) {
153 sb.append("pci: ").append(pci);
154 }
155
156 sb.append(",\n");
157 for (int i = 0; i < indentLevel + 1; i++) {
158 sb.append("\t");
159 }
160 if (earfcnDl != null) {
161 sb.append("earfcnDl: ").append(earfcnDl);
162 }
163
164 sb.append("\n");
165 for (int i = 0; i < indentLevel; i++) {
166 sb.append("\t");
167 }
168 sb.append("}");
169 }
170
171 @Override
172 public boolean equals(Object o) {
173 if (o instanceof PCIARFCN) {
174 return pci.equals(((PCIARFCN) o).getPci()) && earfcnDl.equals(((PCIARFCN) o).getEarfcnDl());
175 }
176
177 return super.equals(o);
178 }
179
180 @Override
181 public int hashCode() {
182 int result = pci.hashCode();
183 result = 31 * result + earfcnDl.hashCode();
184 return result;
185 }
slowr13fa5b02017-08-08 16:32:31 -0700186}
187