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