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