blob: fe514bc2f6c9a4dc9bcd0175e501de9933b91508 [file] [log] [blame]
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08001/**
2 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
3 */
4
5package org.onosproject.xran.asn1lib.api;
6
7import com.fasterxml.jackson.annotation.JsonIgnore;
8import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
9import org.onosproject.xran.asn1lib.ber.BerLength;
10import org.onosproject.xran.asn1lib.ber.BerTag;
11
12import java.io.IOException;
13import java.io.InputStream;
14import java.io.Serializable;
15
16
17public class A4Param implements Serializable {
18
19 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 ThresholdEUTRA a4Threshold = null;
24
25 public A4Param() {
26 }
27
28 public A4Param(byte[] code) {
29 this.code = code;
30 }
31
32 public ThresholdEUTRA getA4Threshold() {
33 return a4Threshold;
34 }
35
36 public void setA4Threshold(ThresholdEUTRA a4Threshold) {
37 this.a4Threshold = a4Threshold;
38 }
39
40 public int encode(BerByteArrayOutputStream os) throws IOException {
41 return encode(os, true);
42 }
43
44 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
45
46 if (code != null) {
47 for (int i = code.length - 1; i >= 0; i--) {
48 os.write(code[i]);
49 }
50 if (withTag) {
51 return tag.encode(os) + code.length;
52 }
53 return code.length;
54 }
55
56 int codeLength = 0;
57 int sublength;
58
59 sublength = a4Threshold.encode(os);
60 codeLength += sublength;
61 codeLength += BerLength.encodeLength(os, sublength);
62 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
63 os.write(0xA0);
64 codeLength += 1;
65
66 codeLength += BerLength.encodeLength(os, codeLength);
67
68 if (withTag) {
69 codeLength += tag.encode(os);
70 }
71
72 return codeLength;
73
74 }
75
76 public int decode(InputStream is) throws IOException {
77 return decode(is, true);
78 }
79
80 public int decode(InputStream is, boolean withTag) throws IOException {
81 int codeLength = 0;
82 int subCodeLength = 0;
83 BerTag berTag = new BerTag();
84
85 if (withTag) {
86 codeLength += tag.decodeAndCheck(is);
87 }
88
89 BerLength length = new BerLength();
90 codeLength += length.decode(is);
91
92 int totalLength = length.val;
93 codeLength += totalLength;
94
95 subCodeLength += berTag.decode(is);
96 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
97 subCodeLength += length.decode(is);
98 a4Threshold = new ThresholdEUTRA();
99 subCodeLength += a4Threshold.decode(is, null);
100 if (subCodeLength == totalLength) {
101 return codeLength;
102 }
103 }
104 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
105
106
107 }
108
109 public void encodeAndSave(int encodingSizeGuess) throws IOException {
110 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
111 encode(os, false);
112 code = os.getArray();
113 }
114
115 public String toString() {
116 StringBuilder sb = new StringBuilder();
117 appendAsString(sb, 0);
118 return sb.toString();
119 }
120
121 public void appendAsString(StringBuilder sb, int indentLevel) {
122
123 sb.append("{");
124 sb.append("\n");
125 for (int i = 0; i < indentLevel + 1; i++) {
126 sb.append("\t");
127 }
128 if (a4Threshold != null) {
129 sb.append("a4Threshold: ");
130 a4Threshold.appendAsString(sb, indentLevel + 1);
131 } else {
132 sb.append("a4Threshold: <empty-required-field>");
133 }
134
135 sb.append("\n");
136 for (int i = 0; i < indentLevel; i++) {
137 sb.append("\t");
138 }
139 sb.append("}");
140 }
141
142}
143