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 RXSigReport 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 PCIARFCN pciArfcn = null; |
| 24 | private ECGI ecgi = null; |
| 25 | private RSRPRange rsrp = null; |
| 26 | private RSRQRange rsrq = null; |
| 27 | |
| 28 | public RXSigReport() { |
| 29 | } |
| 30 | |
| 31 | public RXSigReport(byte[] code) { |
| 32 | this.code = code; |
| 33 | } |
| 34 | |
| 35 | public PCIARFCN getPciArfcn() { |
| 36 | return pciArfcn; |
| 37 | } |
| 38 | |
| 39 | public void setPciArfcn(PCIARFCN pciArfcn) { |
| 40 | this.pciArfcn = pciArfcn; |
| 41 | } |
| 42 | |
| 43 | public ECGI getEcgi() { |
| 44 | return ecgi; |
| 45 | } |
| 46 | |
| 47 | public void setEcgi(ECGI ecgi) { |
| 48 | this.ecgi = ecgi; |
| 49 | } |
| 50 | |
| 51 | public RSRPRange getRsrp() { |
| 52 | return rsrp; |
| 53 | } |
| 54 | |
| 55 | public void setRsrp(RSRPRange rsrp) { |
| 56 | this.rsrp = rsrp; |
| 57 | } |
| 58 | |
| 59 | public RSRQRange getRsrq() { |
| 60 | return rsrq; |
| 61 | } |
| 62 | |
| 63 | public void setRsrq(RSRQRange rsrq) { |
| 64 | this.rsrq = rsrq; |
| 65 | } |
| 66 | |
| 67 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 68 | return encode(os, true); |
| 69 | } |
| 70 | |
| 71 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 72 | |
| 73 | if (code != null) { |
| 74 | for (int i = code.length - 1; i >= 0; i--) { |
| 75 | os.write(code[i]); |
| 76 | } |
| 77 | if (withTag) { |
| 78 | return tag.encode(os) + code.length; |
| 79 | } |
| 80 | return code.length; |
| 81 | } |
| 82 | |
| 83 | int codeLength = 0; |
| 84 | if (rsrq != null) { |
| 85 | codeLength += rsrq.encode(os, false); |
| 86 | // write tag: CONTEXT_CLASS, PRIMITIVE, 3 |
| 87 | os.write(0x83); |
| 88 | codeLength += 1; |
| 89 | } |
| 90 | |
| 91 | if (rsrp != null) { |
| 92 | codeLength += rsrp.encode(os, false); |
| 93 | // write tag: CONTEXT_CLASS, PRIMITIVE, 2 |
| 94 | os.write(0x82); |
| 95 | codeLength += 1; |
| 96 | } |
| 97 | |
| 98 | if (ecgi != null) { |
| 99 | codeLength += ecgi.encode(os, false); |
| 100 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 101 | os.write(0xA1); |
| 102 | codeLength += 1; |
| 103 | } |
| 104 | |
| 105 | codeLength += pciArfcn.encode(os, false); |
| 106 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 107 | os.write(0xA0); |
| 108 | codeLength += 1; |
| 109 | |
| 110 | codeLength += BerLength.encodeLength(os, codeLength); |
| 111 | |
| 112 | if (withTag) { |
| 113 | codeLength += tag.encode(os); |
| 114 | } |
| 115 | |
| 116 | return codeLength; |
| 117 | |
| 118 | } |
| 119 | |
| 120 | public int decode(InputStream is) throws IOException { |
| 121 | return decode(is, true); |
| 122 | } |
| 123 | |
| 124 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 125 | int codeLength = 0; |
| 126 | int subCodeLength = 0; |
| 127 | BerTag berTag = new BerTag(); |
| 128 | |
| 129 | if (withTag) { |
| 130 | codeLength += tag.decodeAndCheck(is); |
| 131 | } |
| 132 | |
| 133 | BerLength length = new BerLength(); |
| 134 | codeLength += length.decode(is); |
| 135 | |
| 136 | int totalLength = length.val; |
| 137 | codeLength += totalLength; |
| 138 | |
| 139 | subCodeLength += berTag.decode(is); |
| 140 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 141 | pciArfcn = new PCIARFCN(); |
| 142 | subCodeLength += pciArfcn.decode(is, false); |
| 143 | if (subCodeLength == totalLength) { |
| 144 | return codeLength; |
| 145 | } |
| 146 | subCodeLength += berTag.decode(is); |
| 147 | } else { |
| 148 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 149 | } |
| 150 | |
| 151 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 152 | ecgi = new ECGI(); |
| 153 | subCodeLength += ecgi.decode(is, false); |
| 154 | if (subCodeLength == totalLength) { |
| 155 | return codeLength; |
| 156 | } |
| 157 | subCodeLength += berTag.decode(is); |
| 158 | } |
| 159 | |
| 160 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { |
| 161 | rsrp = new RSRPRange(); |
| 162 | subCodeLength += rsrp.decode(is, false); |
| 163 | if (subCodeLength == totalLength) { |
| 164 | return codeLength; |
| 165 | } |
| 166 | subCodeLength += berTag.decode(is); |
| 167 | } |
| 168 | |
| 169 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { |
| 170 | rsrq = new RSRQRange(); |
| 171 | subCodeLength += rsrq.decode(is, false); |
| 172 | if (subCodeLength == totalLength) { |
| 173 | return codeLength; |
| 174 | } |
| 175 | } |
| 176 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 177 | |
| 178 | |
| 179 | } |
| 180 | |
| 181 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 182 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 183 | encode(os, false); |
| 184 | code = os.getArray(); |
| 185 | } |
| 186 | |
| 187 | public String toString() { |
| 188 | StringBuilder sb = new StringBuilder(); |
| 189 | appendAsString(sb, 0); |
| 190 | return sb.toString(); |
| 191 | } |
| 192 | |
| 193 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 194 | |
| 195 | sb.append("{"); |
| 196 | sb.append("\n"); |
| 197 | for (int i = 0; i < indentLevel + 1; i++) { |
| 198 | sb.append("\t"); |
| 199 | } |
| 200 | if (pciArfcn != null) { |
| 201 | sb.append("pciArfcn: "); |
| 202 | pciArfcn.appendAsString(sb, indentLevel + 1); |
| 203 | } else { |
| 204 | sb.append("pciArfcn: <empty-required-field>"); |
| 205 | } |
| 206 | |
| 207 | if (ecgi != null) { |
| 208 | sb.append(",\n"); |
| 209 | for (int i = 0; i < indentLevel + 1; i++) { |
| 210 | sb.append("\t"); |
| 211 | } |
| 212 | sb.append("ecgi: "); |
| 213 | ecgi.appendAsString(sb, indentLevel + 1); |
| 214 | } |
| 215 | |
| 216 | if (rsrp != null) { |
| 217 | sb.append(",\n"); |
| 218 | for (int i = 0; i < indentLevel + 1; i++) { |
| 219 | sb.append("\t"); |
| 220 | } |
| 221 | sb.append("rsrp: ").append(rsrp); |
| 222 | } |
| 223 | |
| 224 | if (rsrq != null) { |
| 225 | sb.append(",\n"); |
| 226 | for (int i = 0; i < indentLevel + 1; i++) { |
| 227 | sb.append("\t"); |
| 228 | } |
| 229 | sb.append("rsrq: ").append(rsrq); |
| 230 | } |
| 231 | |
| 232 | sb.append("\n"); |
| 233 | for (int i = 0; i < indentLevel; i++) { |
| 234 | sb.append("\t"); |
| 235 | } |
| 236 | sb.append("}"); |
| 237 | } |
| 238 | |
| 239 | } |
| 240 | |