blob: 4d1e9ea9e60d640f460b676b3f6c2eb11f0caec7 [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;
11import org.onosproject.xran.asn1lib.ber.types.BerInteger;
12
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.Serializable;
16
17
18public class A3Param implements Serializable {
19
20 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
21 private static final long serialVersionUID = 1L;
22 @JsonIgnore
23 public byte[] code = null;
24 private BerInteger a3Offset = null;
25
26 public A3Param() {
27 }
28
29 public A3Param(byte[] code) {
30 this.code = code;
31 }
32
33 public BerInteger getA3Offset() {
34 return a3Offset;
35 }
36
37 public void setA3Offset(BerInteger a3Offset) {
38 this.a3Offset = a3Offset;
39 }
40
41 public int encode(BerByteArrayOutputStream os) throws IOException {
42 return encode(os, true);
43 }
44
45 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
46
47 if (code != null) {
48 for (int i = code.length - 1; i >= 0; i--) {
49 os.write(code[i]);
50 }
51 if (withTag) {
52 return tag.encode(os) + code.length;
53 }
54 return code.length;
55 }
56
57 int codeLength = 0;
58 codeLength += a3Offset.encode(os, false);
59 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
60 os.write(0x80);
61 codeLength += 1;
62
63 codeLength += BerLength.encodeLength(os, codeLength);
64
65 if (withTag) {
66 codeLength += tag.encode(os);
67 }
68
69 return codeLength;
70
71 }
72
73 public int decode(InputStream is) throws IOException {
74 return decode(is, true);
75 }
76
77 public int decode(InputStream is, boolean withTag) throws IOException {
78 int codeLength = 0;
79 int subCodeLength = 0;
80 BerTag berTag = new BerTag();
81
82 if (withTag) {
83 codeLength += tag.decodeAndCheck(is);
84 }
85
86 BerLength length = new BerLength();
87 codeLength += length.decode(is);
88
89 int totalLength = length.val;
90 codeLength += totalLength;
91
92 subCodeLength += berTag.decode(is);
93 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
94 a3Offset = new BerInteger();
95 subCodeLength += a3Offset.decode(is, false);
96 if (subCodeLength == totalLength) {
97 return codeLength;
98 }
99 }
100 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
101
102
103 }
104
105 public void encodeAndSave(int encodingSizeGuess) throws IOException {
106 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
107 encode(os, false);
108 code = os.getArray();
109 }
110
111 public String toString() {
112 StringBuilder sb = new StringBuilder();
113 appendAsString(sb, 0);
114 return sb.toString();
115 }
116
117 public void appendAsString(StringBuilder sb, int indentLevel) {
118
119 sb.append("{");
120 sb.append("\n");
121 for (int i = 0; i < indentLevel + 1; i++) {
122 sb.append("\t");
123 }
124 if (a3Offset != null) {
125 sb.append("a3Offset: ").append(a3Offset);
126 } else {
127 sb.append("a3Offset: <empty-required-field>");
128 }
129
130 sb.append("\n");
131 for (int i = 0; i < indentLevel; i++) {
132 sb.append("\t");
133 }
134 sb.append("}");
135 }
136
137}
138