blob: eaff5a9d220d1afb36c1f8aa68f015007abfabc7 [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 com.fasterxml.jackson.annotation.JsonValue;
19import org.onosproject.xran.codecs.ber.*;
20import org.onosproject.xran.codecs.ber.types.*;
21import org.onosproject.xran.codecs.ber.types.string.*;
slowr13fa5b02017-08-08 16:32:31 -070022
23
24public class ERABResponse implements Serializable {
25
26 private static final long serialVersionUID = 1L;
27
28 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
slowr60d4d102017-08-16 18:33:58 -070029 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070030 public byte[] code = null;
31 private List<ERABResponseItem> seqOf = null;
32
33 public ERABResponse() {
34 seqOf = new ArrayList<ERABResponseItem>();
35 }
36
37 public ERABResponse(byte[] code) {
38 this.code = code;
39 }
40
slowr60d4d102017-08-16 18:33:58 -070041 @JsonValue
slowr13fa5b02017-08-08 16:32:31 -070042 public List<ERABResponseItem> getERABResponseItem() {
43 if (seqOf == null) {
44 seqOf = new ArrayList<ERABResponseItem>();
45 }
46 return seqOf;
47 }
48
49 public void setERABResponse(ERABResponseItem erabResponseItem) {
50 seqOf.add(erabResponseItem);
51 }
52
53 public int encode(BerByteArrayOutputStream os) throws IOException {
54 return encode(os, true);
55 }
56
57 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
58
59 if (code != null) {
60 for (int i = code.length - 1; i >= 0; i--) {
61 os.write(code[i]);
62 }
63 if (withTag) {
64 return tag.encode(os) + code.length;
65 }
66 return code.length;
67 }
68
69 int codeLength = 0;
70 for (int i = (seqOf.size() - 1); i >= 0; i--) {
71 codeLength += seqOf.get(i).encode(os, true);
72 }
73
74 codeLength += BerLength.encodeLength(os, codeLength);
75
76 if (withTag) {
77 codeLength += tag.encode(os);
78 }
79
80 return codeLength;
81 }
82
83 public int decode(InputStream is) throws IOException {
84 return decode(is, true);
85 }
86
87 public int decode(InputStream is, boolean withTag) throws IOException {
88 int codeLength = 0;
89 int subCodeLength = 0;
90 if (withTag) {
91 codeLength += tag.decodeAndCheck(is);
92 }
93
94 BerLength length = new BerLength();
95 codeLength += length.decode(is);
96 int totalLength = length.val;
97
98 while (subCodeLength < totalLength) {
99 ERABResponseItem element = new ERABResponseItem();
100 subCodeLength += element.decode(is, true);
101 seqOf.add(element);
102 }
103 if (subCodeLength != totalLength) {
104 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
105
106 }
107 codeLength += subCodeLength;
108
109 return codeLength;
110 }
111
112 public void encodeAndSave(int encodingSizeGuess) throws IOException {
113 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
114 encode(os, false);
115 code = os.getArray();
116 }
117
118 public String toString() {
119 StringBuilder sb = new StringBuilder();
120 appendAsString(sb, 0);
121 return sb.toString();
122 }
123
124 public void appendAsString(StringBuilder sb, int indentLevel) {
125
126 sb.append("[\n");
127 for (int i = 0; i < indentLevel + 1; i++) {
128 sb.append("\t");
129 }
130 if (seqOf == null) {
131 // sb.append("null");
132 }
133 else {
134 Iterator<ERABResponseItem> it = seqOf.iterator();
135 if (it.hasNext()) {
136 it.next().appendAsString(sb, indentLevel + 1);
137 while (it.hasNext()) {
138 sb.append(",\n");
139 for (int i = 0; i < indentLevel + 1; i++) {
140 sb.append("\t");
141 }
142 it.next().appendAsString(sb, indentLevel + 1);
143 }
144 }
145 }
146
147 sb.append("\n");
148 for (int i = 0; i < indentLevel; i++) {
149 sb.append("\t");
150 }
151 sb.append("]");
152 }
153
154}
155