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