blob: ea75cfb34217cfd6455d66591e44d940ec316364 [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
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
8import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
9import org.onosproject.xran.codecs.ber.BerLength;
10import org.onosproject.xran.codecs.ber.BerTag;
11import org.onosproject.xran.codecs.ber.types.BerEnum;
slowr13fa5b02017-08-08 16:32:31 -070012
13import java.io.IOException;
14import java.io.InputStream;
15import java.io.Serializable;
16
17
18public class DCCap implements Serializable {
19
20 private static final long serialVersionUID = 1L;
21
22 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
23
slowr60d4d102017-08-16 18:33:58 -070024 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070025 public byte[] code = null;
26 private BerEnum drbTypeSplit = null;
27
28 public DCCap() {
29 }
30
31 public DCCap(byte[] code) {
32 this.code = code;
33 }
34
35 public void setDrbTypeSplit(BerEnum drbTypeSplit) {
36 this.drbTypeSplit = drbTypeSplit;
37 }
38
39 public BerEnum getDrbTypeSplit() {
40 return drbTypeSplit;
41 }
42
43 public int encode(BerByteArrayOutputStream os) throws IOException {
44 return encode(os, true);
45 }
46
47 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
48
49 if (code != null) {
50 for (int i = code.length - 1; i >= 0; i--) {
51 os.write(code[i]);
52 }
53 if (withTag) {
54 return tag.encode(os) + code.length;
55 }
56 return code.length;
57 }
58
59 int codeLength = 0;
60 codeLength += drbTypeSplit.encode(os, false);
61 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
62 os.write(0x80);
63 codeLength += 1;
64
65 codeLength += BerLength.encodeLength(os, codeLength);
66
67 if (withTag) {
68 codeLength += tag.encode(os);
69 }
70
71 return codeLength;
72
73 }
74
75 public int decode(InputStream is) throws IOException {
76 return decode(is, true);
77 }
78
79 public int decode(InputStream is, boolean withTag) throws IOException {
80 int codeLength = 0;
81 int subCodeLength = 0;
82 BerTag berTag = new BerTag();
83
84 if (withTag) {
85 codeLength += tag.decodeAndCheck(is);
86 }
87
88 BerLength length = new BerLength();
89 codeLength += length.decode(is);
90
91 int totalLength = length.val;
92 codeLength += totalLength;
93
94 subCodeLength += berTag.decode(is);
95 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
96 drbTypeSplit = new BerEnum();
97 subCodeLength += drbTypeSplit.decode(is, false);
98 if (subCodeLength == totalLength) {
99 return codeLength;
100 }
101 }
102 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
103
104
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("{");
122 sb.append("\n");
123 for (int i = 0; i < indentLevel + 1; i++) {
124 sb.append("\t");
125 }
126 if (drbTypeSplit != null) {
slowr60d4d102017-08-16 18:33:58 -0700127 sb.append("drbTypeSplit: ").append(drbTypeSplit);
slowr13fa5b02017-08-08 16:32:31 -0700128 }
129
130 sb.append("\n");
131 for (int i = 0; i < indentLevel; i++) {
132 sb.append("\t");
133 }
134 sb.append("}");
135 }
136
137}
138