blob: 211369134928d2b66d800c6836a360a1d5d3a4d6 [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 CandScell 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 PhysCellId pci = null;
26 private ARFCNValue earfcnDl = null;
27
28 public CandScell() {
29 }
30
31 public CandScell(byte[] code) {
32 this.code = code;
33 }
34
35 public void setPci(PhysCellId pci) {
36 this.pci = pci;
37 }
38
39 public PhysCellId getPci() {
40 return pci;
41 }
42
43 public void setEarfcnDl(ARFCNValue earfcnDl) {
44 this.earfcnDl = earfcnDl;
45 }
46
47 public ARFCNValue getEarfcnDl() {
48 return earfcnDl;
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 += earfcnDl.encode(os, false);
69 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
70 os.write(0x81);
71 codeLength += 1;
72
73 codeLength += pci.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 pci = new PhysCellId();
110 subCodeLength += pci.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 earfcnDl = new ARFCNValue();
119 subCodeLength += earfcnDl.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 (pci != null) {
slowr60d4d102017-08-16 18:33:58 -0700149 sb.append("pci: ").append(pci);
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 (earfcnDl != null) {
slowr60d4d102017-08-16 18:33:58 -0700157 sb.append("earfcnDl: ").append(earfcnDl);
slowr13fa5b02017-08-08 16:32:31 -0700158 }
159 sb.append("\n");
160 for (int i = 0; i < indentLevel; i++) {
161 sb.append("\t");
162 }
163 sb.append("}");
164 }
165
166}
167