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