blob: 5d50d9e1aafca3a605cec386ba91b24ad9680d7a [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/**
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08002 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
slowr13fa5b02017-08-08 16:32:31 -07003 */
4
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08005package org.onosproject.xran.asn1lib.api;
slowr13fa5b02017-08-08 16:32:31 -07006
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08008import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
9import org.onosproject.xran.asn1lib.ber.BerLength;
10import org.onosproject.xran.asn1lib.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 PhysCellId getPci() {
34 return pci;
35 }
slowr13fa5b02017-08-08 16:32:31 -070036
slowr577f3222017-08-28 10:49:08 -070037 public void setPci(PhysCellId pci) {
38 this.pci = pci;
39 }
slowr13fa5b02017-08-08 16:32:31 -070040
slowr577f3222017-08-28 10:49:08 -070041 public ARFCNValue getEarfcnDl() {
42 return earfcnDl;
43 }
slowr13fa5b02017-08-08 16:32:31 -070044
slowr577f3222017-08-28 10:49:08 -070045 public void setEarfcnDl(ARFCNValue earfcnDl) {
46 this.earfcnDl = earfcnDl;
47 }
slowr13fa5b02017-08-08 16:32:31 -070048
slowr577f3222017-08-28 10:49:08 -070049 public int encode(BerByteArrayOutputStream os) throws IOException {
50 return encode(os, true);
51 }
slowr13fa5b02017-08-08 16:32:31 -070052
slowr577f3222017-08-28 10:49:08 -070053 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -070054
slowr577f3222017-08-28 10:49:08 -070055 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 }
slowr13fa5b02017-08-08 16:32:31 -070064
slowr577f3222017-08-28 10:49:08 -070065 int codeLength = 0;
66 codeLength += earfcnDl.encode(os, false);
67 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
68 os.write(0x81);
69 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070070
slowr577f3222017-08-28 10:49:08 -070071 codeLength += pci.encode(os, false);
72 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
73 os.write(0x80);
74 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070075
slowr577f3222017-08-28 10:49:08 -070076 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -070077
slowr577f3222017-08-28 10:49:08 -070078 if (withTag) {
79 codeLength += tag.encode(os);
80 }
slowr13fa5b02017-08-08 16:32:31 -070081
slowr577f3222017-08-28 10:49:08 -070082 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -070083
slowr577f3222017-08-28 10:49:08 -070084 }
slowr13fa5b02017-08-08 16:32:31 -070085
slowr577f3222017-08-28 10:49:08 -070086 public int decode(InputStream is) throws IOException {
87 return decode(is, true);
88 }
slowr13fa5b02017-08-08 16:32:31 -070089
slowr577f3222017-08-28 10:49:08 -070090 public int decode(InputStream is, boolean withTag) throws IOException {
91 int codeLength = 0;
92 int subCodeLength = 0;
93 BerTag berTag = new BerTag();
slowr13fa5b02017-08-08 16:32:31 -070094
slowr577f3222017-08-28 10:49:08 -070095 if (withTag) {
96 codeLength += tag.decodeAndCheck(is);
97 }
slowr13fa5b02017-08-08 16:32:31 -070098
slowr577f3222017-08-28 10:49:08 -070099 BerLength length = new BerLength();
100 codeLength += length.decode(is);
slowr13fa5b02017-08-08 16:32:31 -0700101
slowr577f3222017-08-28 10:49:08 -0700102 int totalLength = length.val;
103 codeLength += totalLength;
slowr13fa5b02017-08-08 16:32:31 -0700104
slowr577f3222017-08-28 10:49:08 -0700105 subCodeLength += berTag.decode(is);
106 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
107 pci = new PhysCellId();
108 subCodeLength += pci.decode(is, false);
109 subCodeLength += berTag.decode(is);
110 } else {
111 throw new IOException("Tag does not match the mandatory sequence element tag.");
112 }
slowr13fa5b02017-08-08 16:32:31 -0700113
slowr577f3222017-08-28 10:49:08 -0700114 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
115 earfcnDl = new ARFCNValue();
116 subCodeLength += earfcnDl.decode(is, false);
117 if (subCodeLength == totalLength) {
118 return codeLength;
119 }
120 }
121 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
slowr13fa5b02017-08-08 16:32:31 -0700122
slowr13fa5b02017-08-08 16:32:31 -0700123
slowr577f3222017-08-28 10:49:08 -0700124 }
slowr13fa5b02017-08-08 16:32:31 -0700125
slowr577f3222017-08-28 10:49:08 -0700126 public void encodeAndSave(int encodingSizeGuess) throws IOException {
127 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
128 encode(os, false);
129 code = os.getArray();
130 }
slowr13fa5b02017-08-08 16:32:31 -0700131
slowr577f3222017-08-28 10:49:08 -0700132 public String toString() {
133 StringBuilder sb = new StringBuilder();
134 appendAsString(sb, 0);
135 return sb.toString();
136 }
slowr13fa5b02017-08-08 16:32:31 -0700137
slowr577f3222017-08-28 10:49:08 -0700138 public void appendAsString(StringBuilder sb, int indentLevel) {
139
140 sb.append("{");
141 sb.append("\n");
142 for (int i = 0; i < indentLevel + 1; i++) {
143 sb.append("\t");
144 }
145 if (pci != null) {
146 sb.append("pci: ").append(pci);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800147 } else {
148 sb.append("pci: <empty-required-field>");
slowr577f3222017-08-28 10:49:08 -0700149 }
150
151 sb.append(",\n");
152 for (int i = 0; i < indentLevel + 1; i++) {
153 sb.append("\t");
154 }
155 if (earfcnDl != null) {
156 sb.append("earfcnDl: ").append(earfcnDl);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800157 } else {
158 sb.append("earfcnDl: <empty-required-field>");
slowr577f3222017-08-28 10:49:08 -0700159 }
160
161 sb.append("\n");
162 for (int i = 0; i < indentLevel; i++) {
163 sb.append("\t");
164 }
165 sb.append("}");
166 }
167
168 @Override
169 public boolean equals(Object o) {
170 if (o instanceof PCIARFCN) {
171 return pci.equals(((PCIARFCN) o).getPci()) && earfcnDl.equals(((PCIARFCN) o).getEarfcnDl());
172 }
173
174 return super.equals(o);
175 }
176
177 @Override
178 public int hashCode() {
179 int result = pci.hashCode();
180 result = 31 * result + earfcnDl.hashCode();
181 return result;
182 }
slowr13fa5b02017-08-08 16:32:31 -0700183}
184