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 java.io.IOException; |
| 8 | import java.io.EOFException; |
| 9 | import java.io.InputStream; |
| 10 | import java.util.List; |
| 11 | import java.util.ArrayList; |
| 12 | import java.util.Iterator; |
| 13 | import java.io.UnsupportedEncodingException; |
| 14 | import java.math.BigInteger; |
| 15 | import java.io.Serializable; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 16 | |
| 17 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 18 | import org.onosproject.xran.codecs.ber.*; |
| 19 | import org.onosproject.xran.codecs.ber.types.*; |
| 20 | import org.onosproject.xran.codecs.ber.types.string.*; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 21 | |
| 22 | |
| 23 | public class RXSigReport implements Serializable { |
| 24 | |
| 25 | private static final long serialVersionUID = 1L; |
| 26 | |
| 27 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 28 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 29 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 30 | public byte[] code = null; |
| 31 | private PCIARFCN pciArfcn = null; |
| 32 | private RSRPRange rsrp = null; |
| 33 | private RSRQRange rsrq = null; |
| 34 | |
| 35 | public RXSigReport() { |
| 36 | } |
| 37 | |
| 38 | public RXSigReport(byte[] code) { |
| 39 | this.code = code; |
| 40 | } |
| 41 | |
| 42 | public void setPciArfcn(PCIARFCN pciArfcn) { |
| 43 | this.pciArfcn = pciArfcn; |
| 44 | } |
| 45 | |
| 46 | public PCIARFCN getPciArfcn() { |
| 47 | return pciArfcn; |
| 48 | } |
| 49 | |
| 50 | public void setRsrp(RSRPRange rsrp) { |
| 51 | this.rsrp = rsrp; |
| 52 | } |
| 53 | |
| 54 | public RSRPRange getRsrp() { |
| 55 | return rsrp; |
| 56 | } |
| 57 | |
| 58 | public void setRsrq(RSRQRange rsrq) { |
| 59 | this.rsrq = rsrq; |
| 60 | } |
| 61 | |
| 62 | public RSRQRange getRsrq() { |
| 63 | return rsrq; |
| 64 | } |
| 65 | |
| 66 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 67 | return encode(os, true); |
| 68 | } |
| 69 | |
| 70 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 71 | |
| 72 | if (code != null) { |
| 73 | for (int i = code.length - 1; i >= 0; i--) { |
| 74 | os.write(code[i]); |
| 75 | } |
| 76 | if (withTag) { |
| 77 | return tag.encode(os) + code.length; |
| 78 | } |
| 79 | return code.length; |
| 80 | } |
| 81 | |
| 82 | int codeLength = 0; |
| 83 | codeLength += rsrq.encode(os, false); |
| 84 | // write tag: CONTEXT_CLASS, PRIMITIVE, 2 |
| 85 | os.write(0x82); |
| 86 | codeLength += 1; |
| 87 | |
| 88 | codeLength += rsrp.encode(os, false); |
| 89 | // write tag: CONTEXT_CLASS, PRIMITIVE, 1 |
| 90 | os.write(0x81); |
| 91 | codeLength += 1; |
| 92 | |
| 93 | codeLength += pciArfcn.encode(os, false); |
| 94 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 95 | os.write(0xA0); |
| 96 | codeLength += 1; |
| 97 | |
| 98 | codeLength += BerLength.encodeLength(os, codeLength); |
| 99 | |
| 100 | if (withTag) { |
| 101 | codeLength += tag.encode(os); |
| 102 | } |
| 103 | |
| 104 | return codeLength; |
| 105 | |
| 106 | } |
| 107 | |
| 108 | public int decode(InputStream is) throws IOException { |
| 109 | return decode(is, true); |
| 110 | } |
| 111 | |
| 112 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 113 | int codeLength = 0; |
| 114 | int subCodeLength = 0; |
| 115 | BerTag berTag = new BerTag(); |
| 116 | |
| 117 | if (withTag) { |
| 118 | codeLength += tag.decodeAndCheck(is); |
| 119 | } |
| 120 | |
| 121 | BerLength length = new BerLength(); |
| 122 | codeLength += length.decode(is); |
| 123 | |
| 124 | int totalLength = length.val; |
| 125 | codeLength += totalLength; |
| 126 | |
| 127 | subCodeLength += berTag.decode(is); |
| 128 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 129 | pciArfcn = new PCIARFCN(); |
| 130 | subCodeLength += pciArfcn.decode(is, false); |
| 131 | subCodeLength += berTag.decode(is); |
| 132 | } |
| 133 | else { |
| 134 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 135 | } |
| 136 | |
| 137 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { |
| 138 | rsrp = new RSRPRange(); |
| 139 | subCodeLength += rsrp.decode(is, false); |
| 140 | subCodeLength += berTag.decode(is); |
| 141 | } |
| 142 | else { |
| 143 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 144 | } |
| 145 | |
| 146 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { |
| 147 | rsrq = new RSRQRange(); |
| 148 | subCodeLength += rsrq.decode(is, false); |
| 149 | if (subCodeLength == totalLength) { |
| 150 | return codeLength; |
| 151 | } |
| 152 | } |
| 153 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 154 | |
| 155 | |
| 156 | } |
| 157 | |
| 158 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 159 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 160 | encode(os, false); |
| 161 | code = os.getArray(); |
| 162 | } |
| 163 | |
| 164 | public String toString() { |
| 165 | StringBuilder sb = new StringBuilder(); |
| 166 | appendAsString(sb, 0); |
| 167 | return sb.toString(); |
| 168 | } |
| 169 | |
| 170 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 171 | |
| 172 | sb.append("{"); |
| 173 | sb.append("\n"); |
| 174 | for (int i = 0; i < indentLevel + 1; i++) { |
| 175 | sb.append("\t"); |
| 176 | } |
| 177 | if (pciArfcn != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 178 | sb.append("pciArfcn: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 179 | pciArfcn.appendAsString(sb, indentLevel + 1); |
| 180 | } |
| 181 | |
| 182 | sb.append(",\n"); |
| 183 | for (int i = 0; i < indentLevel + 1; i++) { |
| 184 | sb.append("\t"); |
| 185 | } |
| 186 | if (rsrp != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 187 | sb.append("rsrp: ").append(rsrp); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 188 | } |
| 189 | sb.append(",\n"); |
| 190 | for (int i = 0; i < indentLevel + 1; i++) { |
| 191 | sb.append("\t"); |
| 192 | } |
| 193 | if (rsrq != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 194 | sb.append("rsrq: ").append(rsrq); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | sb.append("\n"); |
| 198 | for (int i = 0; i < indentLevel; i++) { |
| 199 | sb.append("\t"); |
| 200 | } |
| 201 | sb.append("}"); |
| 202 | } |
| 203 | |
| 204 | } |
| 205 | |