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