slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /** |
| 2 | * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org) |
| 3 | */ |
| 4 | |
| 5 | package org.onosproject.xran.codecs.api; |
| 6 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 7 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 8 | import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream; |
| 9 | import org.onosproject.xran.codecs.ber.BerLength; |
| 10 | import org.onosproject.xran.codecs.ber.BerTag; |
| 11 | import org.onosproject.xran.codecs.ber.types.BerBoolean; |
| 12 | import org.onosproject.xran.codecs.ber.types.BerEnum; |
| 13 | import org.onosproject.xran.codecs.ber.types.BerInteger; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 14 | |
| 15 | import java.io.IOException; |
| 16 | import java.io.InputStream; |
| 17 | import java.io.Serializable; |
| 18 | |
| 19 | |
| 20 | public class CACap implements Serializable { |
| 21 | |
| 22 | private static final long serialVersionUID = 1L; |
| 23 | |
| 24 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 25 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 26 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 27 | public byte[] code = null; |
| 28 | private BerInteger band = null; |
| 29 | private BerEnum caclassdl = null; |
| 30 | private BerEnum caclassul = null; |
| 31 | private BerBoolean crossCarrierSched = null; |
| 32 | |
| 33 | public CACap() { |
| 34 | } |
| 35 | |
| 36 | public CACap(byte[] code) { |
| 37 | this.code = code; |
| 38 | } |
| 39 | |
| 40 | public void setBand(BerInteger band) { |
| 41 | this.band = band; |
| 42 | } |
| 43 | |
| 44 | public BerInteger getBand() { |
| 45 | return band; |
| 46 | } |
| 47 | |
| 48 | public void setCaclassdl(BerEnum caclassdl) { |
| 49 | this.caclassdl = caclassdl; |
| 50 | } |
| 51 | |
| 52 | public BerEnum getCaclassdl() { |
| 53 | return caclassdl; |
| 54 | } |
| 55 | |
| 56 | public void setCaclassul(BerEnum caclassul) { |
| 57 | this.caclassul = caclassul; |
| 58 | } |
| 59 | |
| 60 | public BerEnum getCaclassul() { |
| 61 | return caclassul; |
| 62 | } |
| 63 | |
| 64 | public void setCrossCarrierSched(BerBoolean crossCarrierSched) { |
| 65 | this.crossCarrierSched = crossCarrierSched; |
| 66 | } |
| 67 | |
| 68 | public BerBoolean getCrossCarrierSched() { |
| 69 | return crossCarrierSched; |
| 70 | } |
| 71 | |
| 72 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 73 | return encode(os, true); |
| 74 | } |
| 75 | |
| 76 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 77 | |
| 78 | if (code != null) { |
| 79 | for (int i = code.length - 1; i >= 0; i--) { |
| 80 | os.write(code[i]); |
| 81 | } |
| 82 | if (withTag) { |
| 83 | return tag.encode(os) + code.length; |
| 84 | } |
| 85 | return code.length; |
| 86 | } |
| 87 | |
| 88 | int codeLength = 0; |
| 89 | codeLength += crossCarrierSched.encode(os, false); |
| 90 | // write tag: CONTEXT_CLASS, PRIMITIVE, 3 |
| 91 | os.write(0x83); |
| 92 | codeLength += 1; |
| 93 | |
| 94 | codeLength += caclassul.encode(os, false); |
| 95 | // write tag: CONTEXT_CLASS, PRIMITIVE, 2 |
| 96 | os.write(0x82); |
| 97 | codeLength += 1; |
| 98 | |
| 99 | codeLength += caclassdl.encode(os, false); |
| 100 | // write tag: CONTEXT_CLASS, PRIMITIVE, 1 |
| 101 | os.write(0x81); |
| 102 | codeLength += 1; |
| 103 | |
| 104 | codeLength += band.encode(os, false); |
| 105 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 106 | os.write(0x80); |
| 107 | codeLength += 1; |
| 108 | |
| 109 | codeLength += BerLength.encodeLength(os, codeLength); |
| 110 | |
| 111 | if (withTag) { |
| 112 | codeLength += tag.encode(os); |
| 113 | } |
| 114 | |
| 115 | return codeLength; |
| 116 | |
| 117 | } |
| 118 | |
| 119 | public int decode(InputStream is) throws IOException { |
| 120 | return decode(is, true); |
| 121 | } |
| 122 | |
| 123 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 124 | int codeLength = 0; |
| 125 | int subCodeLength = 0; |
| 126 | BerTag berTag = new BerTag(); |
| 127 | |
| 128 | if (withTag) { |
| 129 | codeLength += tag.decodeAndCheck(is); |
| 130 | } |
| 131 | |
| 132 | BerLength length = new BerLength(); |
| 133 | codeLength += length.decode(is); |
| 134 | |
| 135 | int totalLength = length.val; |
| 136 | codeLength += totalLength; |
| 137 | |
| 138 | subCodeLength += berTag.decode(is); |
| 139 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 140 | band = new BerInteger(); |
| 141 | subCodeLength += band.decode(is, false); |
| 142 | subCodeLength += berTag.decode(is); |
| 143 | } |
| 144 | else { |
| 145 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 146 | } |
| 147 | |
| 148 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { |
| 149 | caclassdl = new BerEnum(); |
| 150 | subCodeLength += caclassdl.decode(is, false); |
| 151 | subCodeLength += berTag.decode(is); |
| 152 | } |
| 153 | else { |
| 154 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 155 | } |
| 156 | |
| 157 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { |
| 158 | caclassul = new BerEnum(); |
| 159 | subCodeLength += caclassul.decode(is, false); |
| 160 | subCodeLength += berTag.decode(is); |
| 161 | } |
| 162 | else { |
| 163 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 164 | } |
| 165 | |
| 166 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { |
| 167 | crossCarrierSched = new BerBoolean(); |
| 168 | subCodeLength += crossCarrierSched.decode(is, false); |
| 169 | if (subCodeLength == totalLength) { |
| 170 | return codeLength; |
| 171 | } |
| 172 | } |
| 173 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 174 | |
| 175 | |
| 176 | } |
| 177 | |
| 178 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 179 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 180 | encode(os, false); |
| 181 | code = os.getArray(); |
| 182 | } |
| 183 | |
| 184 | public String toString() { |
| 185 | StringBuilder sb = new StringBuilder(); |
| 186 | appendAsString(sb, 0); |
| 187 | return sb.toString(); |
| 188 | } |
| 189 | |
| 190 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 191 | |
| 192 | sb.append("{"); |
| 193 | sb.append("\n"); |
| 194 | for (int i = 0; i < indentLevel + 1; i++) { |
| 195 | sb.append("\t"); |
| 196 | } |
| 197 | if (band != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 198 | sb.append("band:").append(band); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | sb.append(",\n"); |
| 202 | for (int i = 0; i < indentLevel + 1; i++) { |
| 203 | sb.append("\t"); |
| 204 | } |
| 205 | if (caclassdl != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 206 | sb.append("caclassdl:").append(caclassdl); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | sb.append(",\n"); |
| 210 | for (int i = 0; i < indentLevel + 1; i++) { |
| 211 | sb.append("\t"); |
| 212 | } |
| 213 | if (caclassul != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 214 | sb.append("caclassul:").append(caclassul); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | sb.append(",\n"); |
| 218 | for (int i = 0; i < indentLevel + 1; i++) { |
| 219 | sb.append("\t"); |
| 220 | } |
| 221 | if (crossCarrierSched != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 222 | sb.append("crossCarrierSched:").append(crossCarrierSched); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | sb.append("\n"); |
| 226 | for (int i = 0; i < indentLevel; i++) { |
| 227 | sb.append("\t"); |
| 228 | } |
| 229 | sb.append("}"); |
| 230 | } |
| 231 | |
| 232 | } |
| 233 | |