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.pdu; |
| 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.onosproject.xran.codecs.api.ECGI; |
| 11 | |
| 12 | import java.io.IOException; |
| 13 | import java.io.InputStream; |
| 14 | import java.io.Serializable; |
| 15 | |
| 16 | public class CellConfigRequest implements Serializable { |
| 17 | |
| 18 | private static final long serialVersionUID = 1L; |
| 19 | |
| 20 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 21 | |
| 22 | public byte[] code = null; |
| 23 | private ECGI ecgi = null; |
| 24 | |
| 25 | public CellConfigRequest() { |
| 26 | } |
| 27 | |
| 28 | public CellConfigRequest(byte[] code) { |
| 29 | this.code = code; |
| 30 | } |
| 31 | |
| 32 | public void setEcgi(ECGI ecgi) { |
| 33 | this.ecgi = ecgi; |
| 34 | } |
| 35 | |
| 36 | public ECGI getEcgi() { |
| 37 | return ecgi; |
| 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 | codeLength += ecgi.encode(os, false); |
| 58 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 59 | os.write(0xA0); |
| 60 | codeLength += 1; |
| 61 | |
| 62 | codeLength += BerLength.encodeLength(os, codeLength); |
| 63 | |
| 64 | if (withTag) { |
| 65 | codeLength += tag.encode(os); |
| 66 | } |
| 67 | |
| 68 | return codeLength; |
| 69 | |
| 70 | } |
| 71 | |
| 72 | public int decode(InputStream is) throws IOException { |
| 73 | return decode(is, true); |
| 74 | } |
| 75 | |
| 76 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 77 | int codeLength = 0; |
| 78 | int subCodeLength = 0; |
| 79 | BerTag berTag = new BerTag(); |
| 80 | |
| 81 | if (withTag) { |
| 82 | codeLength += tag.decodeAndCheck(is); |
| 83 | } |
| 84 | |
| 85 | BerLength length = new BerLength(); |
| 86 | codeLength += length.decode(is); |
| 87 | |
| 88 | int totalLength = length.val; |
| 89 | codeLength += totalLength; |
| 90 | |
| 91 | subCodeLength += berTag.decode(is); |
| 92 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 93 | ecgi = new ECGI(); |
| 94 | subCodeLength += ecgi.decode(is, false); |
| 95 | if (subCodeLength == totalLength) { |
| 96 | return codeLength; |
| 97 | } |
| 98 | } |
| 99 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 100 | |
| 101 | |
| 102 | } |
| 103 | |
| 104 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 105 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 106 | encode(os, false); |
| 107 | code = os.getArray(); |
| 108 | } |
| 109 | |
| 110 | public String toString() { |
| 111 | StringBuilder sb = new StringBuilder(); |
| 112 | appendAsString(sb, 0); |
| 113 | return sb.toString(); |
| 114 | } |
| 115 | |
| 116 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 117 | |
| 118 | sb.append("{"); |
| 119 | sb.append("\n"); |
| 120 | for (int i = 0; i < indentLevel + 1; i++) { |
| 121 | sb.append("\t"); |
| 122 | } |
| 123 | if (ecgi != null) { |
| 124 | sb.append("\"ecgi\": "); |
| 125 | ecgi.appendAsString(sb, indentLevel + 1); |
| 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 | |