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