Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 1 | /** |
| 2 | * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org) |
| 3 | */ |
| 4 | |
| 5 | package org.onosproject.xran.asn1lib.api; |
| 6 | |
| 7 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 8 | import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream; |
| 9 | import org.onosproject.xran.asn1lib.ber.BerLength; |
| 10 | import org.onosproject.xran.asn1lib.ber.BerTag; |
| 11 | |
| 12 | import java.io.IOException; |
| 13 | import java.io.InputStream; |
| 14 | import java.io.Serializable; |
| 15 | |
| 16 | |
| 17 | public class A2Param implements Serializable { |
| 18 | |
| 19 | 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; |
| 23 | private ThresholdEUTRA a2Threshold = null; |
| 24 | |
| 25 | public A2Param() { |
| 26 | } |
| 27 | |
| 28 | public A2Param(byte[] code) { |
| 29 | this.code = code; |
| 30 | } |
| 31 | |
| 32 | public ThresholdEUTRA getA2Threshold() { |
| 33 | return a2Threshold; |
| 34 | } |
| 35 | |
| 36 | public void setA2Threshold(ThresholdEUTRA a2Threshold) { |
| 37 | this.a2Threshold = a2Threshold; |
| 38 | } |
| 39 | |
| 40 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 41 | return encode(os, true); |
| 42 | } |
| 43 | |
| 44 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 45 | |
| 46 | if (code != null) { |
| 47 | for (int i = code.length - 1; i >= 0; i--) { |
| 48 | os.write(code[i]); |
| 49 | } |
| 50 | if (withTag) { |
| 51 | return tag.encode(os) + code.length; |
| 52 | } |
| 53 | return code.length; |
| 54 | } |
| 55 | |
| 56 | int codeLength = 0; |
| 57 | int sublength; |
| 58 | |
| 59 | sublength = a2Threshold.encode(os); |
| 60 | codeLength += sublength; |
| 61 | codeLength += BerLength.encodeLength(os, sublength); |
| 62 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 63 | os.write(0xA0); |
| 64 | codeLength += 1; |
| 65 | |
| 66 | codeLength += BerLength.encodeLength(os, codeLength); |
| 67 | |
| 68 | if (withTag) { |
| 69 | codeLength += tag.encode(os); |
| 70 | } |
| 71 | |
| 72 | return codeLength; |
| 73 | |
| 74 | } |
| 75 | |
| 76 | public int decode(InputStream is) throws IOException { |
| 77 | return decode(is, true); |
| 78 | } |
| 79 | |
| 80 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 81 | int codeLength = 0; |
| 82 | int subCodeLength = 0; |
| 83 | BerTag berTag = new BerTag(); |
| 84 | |
| 85 | if (withTag) { |
| 86 | codeLength += tag.decodeAndCheck(is); |
| 87 | } |
| 88 | |
| 89 | BerLength length = new BerLength(); |
| 90 | codeLength += length.decode(is); |
| 91 | |
| 92 | int totalLength = length.val; |
| 93 | codeLength += totalLength; |
| 94 | |
| 95 | subCodeLength += berTag.decode(is); |
| 96 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 97 | subCodeLength += length.decode(is); |
| 98 | a2Threshold = new ThresholdEUTRA(); |
| 99 | subCodeLength += a2Threshold.decode(is, null); |
| 100 | if (subCodeLength == totalLength) { |
| 101 | return codeLength; |
| 102 | } |
| 103 | } |
| 104 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 105 | |
| 106 | |
| 107 | } |
| 108 | |
| 109 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 110 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 111 | encode(os, false); |
| 112 | code = os.getArray(); |
| 113 | } |
| 114 | |
| 115 | public String toString() { |
| 116 | StringBuilder sb = new StringBuilder(); |
| 117 | appendAsString(sb, 0); |
| 118 | return sb.toString(); |
| 119 | } |
| 120 | |
| 121 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 122 | |
| 123 | sb.append("{"); |
| 124 | sb.append("\n"); |
| 125 | for (int i = 0; i < indentLevel + 1; i++) { |
| 126 | sb.append("\t"); |
| 127 | } |
| 128 | if (a2Threshold != null) { |
| 129 | sb.append("a2Threshold: "); |
| 130 | a2Threshold.appendAsString(sb, indentLevel + 1); |
| 131 | } else { |
| 132 | sb.append("a2Threshold: <empty-required-field>"); |
| 133 | } |
| 134 | |
| 135 | sb.append("\n"); |
| 136 | for (int i = 0; i < indentLevel; i++) { |
| 137 | sb.append("\t"); |
| 138 | } |
| 139 | sb.append("}"); |
| 140 | } |
| 141 | |
| 142 | } |
| 143 | |