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