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 | |
| 7 | import org.openmuc.jasn1.ber.BerByteArrayOutputStream; |
| 8 | import org.openmuc.jasn1.ber.BerLength; |
| 9 | import org.openmuc.jasn1.ber.BerTag; |
| 10 | import org.openmuc.jasn1.ber.types.BerEnum; |
| 11 | |
| 12 | import java.io.IOException; |
| 13 | import java.io.InputStream; |
| 14 | import java.io.Serializable; |
| 15 | |
| 16 | |
| 17 | public class DCCap implements Serializable { |
| 18 | |
| 19 | private static final long serialVersionUID = 1L; |
| 20 | |
| 21 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 22 | |
| 23 | public byte[] code = null; |
| 24 | private BerEnum drbTypeSplit = null; |
| 25 | |
| 26 | public DCCap() { |
| 27 | } |
| 28 | |
| 29 | public DCCap(byte[] code) { |
| 30 | this.code = code; |
| 31 | } |
| 32 | |
| 33 | public void setDrbTypeSplit(BerEnum drbTypeSplit) { |
| 34 | this.drbTypeSplit = drbTypeSplit; |
| 35 | } |
| 36 | |
| 37 | public BerEnum getDrbTypeSplit() { |
| 38 | return drbTypeSplit; |
| 39 | } |
| 40 | |
| 41 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 42 | return encode(os, true); |
| 43 | } |
| 44 | |
| 45 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 46 | |
| 47 | if (code != null) { |
| 48 | for (int i = code.length - 1; i >= 0; i--) { |
| 49 | os.write(code[i]); |
| 50 | } |
| 51 | if (withTag) { |
| 52 | return tag.encode(os) + code.length; |
| 53 | } |
| 54 | return code.length; |
| 55 | } |
| 56 | |
| 57 | int codeLength = 0; |
| 58 | codeLength += drbTypeSplit.encode(os, false); |
| 59 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 60 | os.write(0x80); |
| 61 | codeLength += 1; |
| 62 | |
| 63 | codeLength += BerLength.encodeLength(os, codeLength); |
| 64 | |
| 65 | if (withTag) { |
| 66 | codeLength += tag.encode(os); |
| 67 | } |
| 68 | |
| 69 | return codeLength; |
| 70 | |
| 71 | } |
| 72 | |
| 73 | public int decode(InputStream is) throws IOException { |
| 74 | return decode(is, true); |
| 75 | } |
| 76 | |
| 77 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 78 | int codeLength = 0; |
| 79 | int subCodeLength = 0; |
| 80 | BerTag berTag = new BerTag(); |
| 81 | |
| 82 | if (withTag) { |
| 83 | codeLength += tag.decodeAndCheck(is); |
| 84 | } |
| 85 | |
| 86 | BerLength length = new BerLength(); |
| 87 | codeLength += length.decode(is); |
| 88 | |
| 89 | int totalLength = length.val; |
| 90 | codeLength += totalLength; |
| 91 | |
| 92 | subCodeLength += berTag.decode(is); |
| 93 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 94 | drbTypeSplit = new BerEnum(); |
| 95 | subCodeLength += drbTypeSplit.decode(is, false); |
| 96 | if (subCodeLength == totalLength) { |
| 97 | return codeLength; |
| 98 | } |
| 99 | } |
| 100 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 101 | |
| 102 | |
| 103 | } |
| 104 | |
| 105 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 106 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 107 | encode(os, false); |
| 108 | code = os.getArray(); |
| 109 | } |
| 110 | |
| 111 | public String toString() { |
| 112 | StringBuilder sb = new StringBuilder(); |
| 113 | appendAsString(sb, 0); |
| 114 | return sb.toString(); |
| 115 | } |
| 116 | |
| 117 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 118 | |
| 119 | sb.append("{"); |
| 120 | sb.append("\n"); |
| 121 | for (int i = 0; i < indentLevel + 1; i++) { |
| 122 | sb.append("\t"); |
| 123 | } |
| 124 | if (drbTypeSplit != null) { |
| 125 | sb.append("\"drbTypeSplit\": ").append(drbTypeSplit); |
| 126 | } |
| 127 | |
| 128 | sb.append("\n"); |
| 129 | for (int i = 0; i < indentLevel; i++) { |
| 130 | sb.append("\t"); |
| 131 | } |
| 132 | sb.append("}"); |
| 133 | } |
| 134 | |
| 135 | } |
| 136 | |