slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /** |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 2 | * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 3 | */ |
| 4 | |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 5 | package org.onosproject.xran.asn1lib.api; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 6 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 7 | import com.fasterxml.jackson.annotation.JsonIgnore; |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 8 | import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream; |
| 9 | import org.onosproject.xran.asn1lib.ber.BerLength; |
| 10 | import org.onosproject.xran.asn1lib.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 PhysCellId getPci() { |
| 34 | return pci; |
| 35 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 36 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 37 | public void setPci(PhysCellId pci) { |
| 38 | this.pci = pci; |
| 39 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 40 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 41 | public ARFCNValue getEarfcnDl() { |
| 42 | return earfcnDl; |
| 43 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 44 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 45 | public void setEarfcnDl(ARFCNValue earfcnDl) { |
| 46 | this.earfcnDl = earfcnDl; |
| 47 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 48 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 49 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 50 | return encode(os, true); |
| 51 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 52 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 53 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 54 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 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 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 64 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 65 | int codeLength = 0; |
| 66 | codeLength += earfcnDl.encode(os, false); |
| 67 | // write tag: CONTEXT_CLASS, PRIMITIVE, 1 |
| 68 | os.write(0x81); |
| 69 | codeLength += 1; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 70 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 71 | codeLength += pci.encode(os, false); |
| 72 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 73 | os.write(0x80); |
| 74 | codeLength += 1; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 75 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 76 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 77 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 78 | if (withTag) { |
| 79 | codeLength += tag.encode(os); |
| 80 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 81 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 82 | return codeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 83 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 84 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 85 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 86 | public int decode(InputStream is) throws IOException { |
| 87 | return decode(is, true); |
| 88 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 89 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 90 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 91 | int codeLength = 0; |
| 92 | int subCodeLength = 0; |
| 93 | BerTag berTag = new BerTag(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 94 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 95 | if (withTag) { |
| 96 | codeLength += tag.decodeAndCheck(is); |
| 97 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 98 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 99 | BerLength length = new BerLength(); |
| 100 | codeLength += length.decode(is); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 101 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 102 | int totalLength = length.val; |
| 103 | codeLength += totalLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 104 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 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 | } else { |
| 111 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 112 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 113 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 114 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { |
| 115 | earfcnDl = new ARFCNValue(); |
| 116 | subCodeLength += earfcnDl.decode(is, false); |
| 117 | if (subCodeLength == totalLength) { |
| 118 | return codeLength; |
| 119 | } |
| 120 | } |
| 121 | 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] | 122 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 123 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 124 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 125 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 126 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 127 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 128 | encode(os, false); |
| 129 | code = os.getArray(); |
| 130 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 131 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 132 | public String toString() { |
| 133 | StringBuilder sb = new StringBuilder(); |
| 134 | appendAsString(sb, 0); |
| 135 | return sb.toString(); |
| 136 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 137 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 138 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 139 | |
| 140 | sb.append("{"); |
| 141 | sb.append("\n"); |
| 142 | for (int i = 0; i < indentLevel + 1; i++) { |
| 143 | sb.append("\t"); |
| 144 | } |
| 145 | if (pci != null) { |
| 146 | sb.append("pci: ").append(pci); |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 147 | } else { |
| 148 | sb.append("pci: <empty-required-field>"); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | sb.append(",\n"); |
| 152 | for (int i = 0; i < indentLevel + 1; i++) { |
| 153 | sb.append("\t"); |
| 154 | } |
| 155 | if (earfcnDl != null) { |
| 156 | sb.append("earfcnDl: ").append(earfcnDl); |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 157 | } else { |
| 158 | sb.append("earfcnDl: <empty-required-field>"); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | sb.append("\n"); |
| 162 | for (int i = 0; i < indentLevel; i++) { |
| 163 | sb.append("\t"); |
| 164 | } |
| 165 | sb.append("}"); |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public boolean equals(Object o) { |
| 170 | if (o instanceof PCIARFCN) { |
| 171 | return pci.equals(((PCIARFCN) o).getPci()) && earfcnDl.equals(((PCIARFCN) o).getEarfcnDl()); |
| 172 | } |
| 173 | |
| 174 | return super.equals(o); |
| 175 | } |
| 176 | |
| 177 | @Override |
| 178 | public int hashCode() { |
| 179 | int result = pci.hashCode(); |
| 180 | result = 31 * result + earfcnDl.hashCode(); |
| 181 | return result; |
| 182 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 183 | } |
| 184 | |