blob: 3590d0958b3e38ead820b4454b402a09eda36ae9 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/**
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08002 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
slowr13fa5b02017-08-08 16:32:31 -07003 */
4
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08005package org.onosproject.xran.asn1lib.api;
slowr13fa5b02017-08-08 16:32:31 -07006
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08008import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
9import org.onosproject.xran.asn1lib.ber.BerLength;
10import org.onosproject.xran.asn1lib.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070011
12import java.io.IOException;
13import java.io.InputStream;
14import java.io.Serializable;
15
16
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080017public class UEAMBR implements Serializable {
slowr13fa5b02017-08-08 16:32:31 -070018
slowr577f3222017-08-28 10:49:08 -070019 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
20 private static final long serialVersionUID = 1L;
21 @JsonIgnore
22 public byte[] code = null;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080023 private BitRate ambrDl = null;
24 private BitRate ambrUl = null;
slowr13fa5b02017-08-08 16:32:31 -070025
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080026 public UEAMBR() {
slowr577f3222017-08-28 10:49:08 -070027 }
slowr13fa5b02017-08-08 16:32:31 -070028
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080029 public UEAMBR(byte[] code) {
slowr577f3222017-08-28 10:49:08 -070030 this.code = code;
31 }
slowr13fa5b02017-08-08 16:32:31 -070032
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080033 public BitRate getAmbrDl() {
34 return ambrDl;
slowr577f3222017-08-28 10:49:08 -070035 }
slowr13fa5b02017-08-08 16:32:31 -070036
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080037 public void setAmbrDl(BitRate ambrDl) {
38 this.ambrDl = ambrDl;
slowr577f3222017-08-28 10:49:08 -070039 }
slowr13fa5b02017-08-08 16:32:31 -070040
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080041 public BitRate getAmbrUl() {
42 return ambrUl;
slowr577f3222017-08-28 10:49:08 -070043 }
slowr13fa5b02017-08-08 16:32:31 -070044
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080045 public void setAmbrUl(BitRate ambrUl) {
46 this.ambrUl = ambrUl;
slowr577f3222017-08-28 10:49:08 -070047 }
slowr13fa5b02017-08-08 16:32:31 -070048
slowr577f3222017-08-28 10:49:08 -070049 public int encode(BerByteArrayOutputStream os) throws IOException {
50 return encode(os, true);
51 }
slowr13fa5b02017-08-08 16:32:31 -070052
slowr577f3222017-08-28 10:49:08 -070053 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -070054
slowr577f3222017-08-28 10:49:08 -070055 if (code != null) {
56 for (int i = code.length - 1; i >= 0; i--) {
57 os.write(code[i]);
58 }
59 if (withTag) {
60 return tag.encode(os) + code.length;
61 }
62 return code.length;
63 }
slowr13fa5b02017-08-08 16:32:31 -070064
slowr577f3222017-08-28 10:49:08 -070065 int codeLength = 0;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080066 codeLength += ambrUl.encode(os, false);
slowr577f3222017-08-28 10:49:08 -070067 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
68 os.write(0x81);
69 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070070
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080071 codeLength += ambrDl.encode(os, false);
slowr577f3222017-08-28 10:49:08 -070072 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
73 os.write(0x80);
74 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -070075
slowr577f3222017-08-28 10:49:08 -070076 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -070077
slowr577f3222017-08-28 10:49:08 -070078 if (withTag) {
79 codeLength += tag.encode(os);
80 }
slowr13fa5b02017-08-08 16:32:31 -070081
slowr577f3222017-08-28 10:49:08 -070082 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -070083
slowr577f3222017-08-28 10:49:08 -070084 }
slowr13fa5b02017-08-08 16:32:31 -070085
slowr577f3222017-08-28 10:49:08 -070086 public int decode(InputStream is) throws IOException {
87 return decode(is, true);
88 }
slowr13fa5b02017-08-08 16:32:31 -070089
slowr577f3222017-08-28 10:49:08 -070090 public int decode(InputStream is, boolean withTag) throws IOException {
91 int codeLength = 0;
92 int subCodeLength = 0;
93 BerTag berTag = new BerTag();
slowr13fa5b02017-08-08 16:32:31 -070094
slowr577f3222017-08-28 10:49:08 -070095 if (withTag) {
96 codeLength += tag.decodeAndCheck(is);
97 }
slowr13fa5b02017-08-08 16:32:31 -070098
slowr577f3222017-08-28 10:49:08 -070099 BerLength length = new BerLength();
100 codeLength += length.decode(is);
slowr13fa5b02017-08-08 16:32:31 -0700101
slowr577f3222017-08-28 10:49:08 -0700102 int totalLength = length.val;
103 codeLength += totalLength;
slowr13fa5b02017-08-08 16:32:31 -0700104
slowr577f3222017-08-28 10:49:08 -0700105 subCodeLength += berTag.decode(is);
106 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800107 ambrDl = new BitRate();
108 subCodeLength += ambrDl.decode(is, false);
slowr577f3222017-08-28 10:49:08 -0700109 subCodeLength += berTag.decode(is);
110 } else {
111 throw new IOException("Tag does not match the mandatory sequence element tag.");
112 }
slowr13fa5b02017-08-08 16:32:31 -0700113
slowr577f3222017-08-28 10:49:08 -0700114 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800115 ambrUl = new BitRate();
116 subCodeLength += ambrUl.decode(is, false);
slowr577f3222017-08-28 10:49:08 -0700117 if (subCodeLength == totalLength) {
118 return codeLength;
119 }
120 }
121 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
slowr13fa5b02017-08-08 16:32:31 -0700122
slowr13fa5b02017-08-08 16:32:31 -0700123
slowr577f3222017-08-28 10:49:08 -0700124 }
slowr13fa5b02017-08-08 16:32:31 -0700125
slowr577f3222017-08-28 10:49:08 -0700126 public void encodeAndSave(int encodingSizeGuess) throws IOException {
127 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
128 encode(os, false);
129 code = os.getArray();
130 }
slowr13fa5b02017-08-08 16:32:31 -0700131
slowr577f3222017-08-28 10:49:08 -0700132 public String toString() {
133 StringBuilder sb = new StringBuilder();
134 appendAsString(sb, 0);
135 return sb.toString();
136 }
slowr13fa5b02017-08-08 16:32:31 -0700137
slowr577f3222017-08-28 10:49:08 -0700138 public void appendAsString(StringBuilder sb, int indentLevel) {
139
140 sb.append("{");
141 sb.append("\n");
142 for (int i = 0; i < indentLevel + 1; i++) {
143 sb.append("\t");
144 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800145 if (ambrDl != null) {
146 sb.append("ambrDl: ").append(ambrDl);
147 } else {
148 sb.append("ambrDl: <empty-required-field>");
slowr577f3222017-08-28 10:49:08 -0700149 }
150
151 sb.append(",\n");
152 for (int i = 0; i < indentLevel + 1; i++) {
153 sb.append("\t");
154 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800155 if (ambrUl != null) {
156 sb.append("ambrUl: ").append(ambrUl);
157 } else {
158 sb.append("ambrUl: <empty-required-field>");
slowr577f3222017-08-28 10:49:08 -0700159 }
160
161 sb.append("\n");
162 for (int i = 0; i < indentLevel; i++) {
163 sb.append("\t");
164 }
165 sb.append("}");
166 }
167
slowr13fa5b02017-08-08 16:32:31 -0700168}
169