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 | |
| 11 | import java.io.IOException; |
| 12 | import java.io.InputStream; |
| 13 | import java.io.Serializable; |
| 14 | |
| 15 | |
| 16 | public class CandScell 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 PhysCellId pci = null; |
| 24 | private ARFCNValue earfcnDl = null; |
| 25 | |
| 26 | public CandScell() { |
| 27 | } |
| 28 | |
| 29 | public CandScell(byte[] code) { |
| 30 | this.code = code; |
| 31 | } |
| 32 | |
| 33 | public void setPci(PhysCellId pci) { |
| 34 | this.pci = pci; |
| 35 | } |
| 36 | |
| 37 | public PhysCellId getPci() { |
| 38 | return pci; |
| 39 | } |
| 40 | |
| 41 | public void setEarfcnDl(ARFCNValue earfcnDl) { |
| 42 | this.earfcnDl = earfcnDl; |
| 43 | } |
| 44 | |
| 45 | public ARFCNValue getEarfcnDl() { |
| 46 | return earfcnDl; |
| 47 | } |
| 48 | |
| 49 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 50 | return encode(os, true); |
| 51 | } |
| 52 | |
| 53 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 54 | |
| 55 | 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 | } |
| 64 | |
| 65 | int codeLength = 0; |
| 66 | codeLength += earfcnDl.encode(os, false); |
| 67 | // write tag: CONTEXT_CLASS, PRIMITIVE, 1 |
| 68 | os.write(0x81); |
| 69 | codeLength += 1; |
| 70 | |
| 71 | codeLength += pci.encode(os, false); |
| 72 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 73 | os.write(0x80); |
| 74 | codeLength += 1; |
| 75 | |
| 76 | codeLength += BerLength.encodeLength(os, codeLength); |
| 77 | |
| 78 | if (withTag) { |
| 79 | codeLength += tag.encode(os); |
| 80 | } |
| 81 | |
| 82 | return codeLength; |
| 83 | |
| 84 | } |
| 85 | |
| 86 | public int decode(InputStream is) throws IOException { |
| 87 | return decode(is, true); |
| 88 | } |
| 89 | |
| 90 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 91 | int codeLength = 0; |
| 92 | int subCodeLength = 0; |
| 93 | BerTag berTag = new BerTag(); |
| 94 | |
| 95 | if (withTag) { |
| 96 | codeLength += tag.decodeAndCheck(is); |
| 97 | } |
| 98 | |
| 99 | BerLength length = new BerLength(); |
| 100 | codeLength += length.decode(is); |
| 101 | |
| 102 | int totalLength = length.val; |
| 103 | codeLength += totalLength; |
| 104 | |
| 105 | subCodeLength += berTag.decode(is); |
| 106 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 107 | pci = new PhysCellId(); |
| 108 | subCodeLength += pci.decode(is, false); |
| 109 | subCodeLength += berTag.decode(is); |
| 110 | } |
| 111 | else { |
| 112 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 113 | } |
| 114 | |
| 115 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { |
| 116 | earfcnDl = new ARFCNValue(); |
| 117 | subCodeLength += earfcnDl.decode(is, false); |
| 118 | if (subCodeLength == totalLength) { |
| 119 | return codeLength; |
| 120 | } |
| 121 | } |
| 122 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 123 | |
| 124 | |
| 125 | } |
| 126 | |
| 127 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 128 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 129 | encode(os, false); |
| 130 | code = os.getArray(); |
| 131 | } |
| 132 | |
| 133 | public String toString() { |
| 134 | StringBuilder sb = new StringBuilder(); |
| 135 | appendAsString(sb, 0); |
| 136 | return sb.toString(); |
| 137 | } |
| 138 | |
| 139 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 140 | |
| 141 | sb.append("{"); |
| 142 | sb.append("\n"); |
| 143 | for (int i = 0; i < indentLevel + 1; i++) { |
| 144 | sb.append("\t"); |
| 145 | } |
| 146 | if (pci != null) { |
| 147 | sb.append("\"pci\": ").append(pci); |
| 148 | } |
| 149 | |
| 150 | sb.append(",\n"); |
| 151 | for (int i = 0; i < indentLevel + 1; i++) { |
| 152 | sb.append("\t"); |
| 153 | } |
| 154 | if (earfcnDl != null) { |
| 155 | sb.append("\"earfcnDl\": ").append(earfcnDl); |
| 156 | } |
| 157 | sb.append("\n"); |
| 158 | for (int i = 0; i < indentLevel; i++) { |
| 159 | sb.append("\t"); |
| 160 | } |
| 161 | sb.append("}"); |
| 162 | } |
| 163 | |
| 164 | } |
| 165 | |