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