slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 4 | package org.onosproject.xran.asn1lib.ber.types.string; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 5 | |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 6 | import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream; |
| 7 | import org.onosproject.xran.asn1lib.ber.BerTag; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 8 | |
| 9 | import java.io.IOException; |
| 10 | import java.io.InputStream; |
| 11 | |
| 12 | public class BerObjectDescriptor extends BerGraphicString { |
| 13 | |
| 14 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.PRIMITIVE, BerTag.OBJECT_DESCRIPTOR_TAG); |
| 15 | private static final long serialVersionUID = 1L; |
| 16 | |
| 17 | public BerObjectDescriptor() { |
| 18 | } |
| 19 | |
| 20 | public BerObjectDescriptor(byte[] value) { |
| 21 | super(value); |
| 22 | } |
| 23 | |
| 24 | @Override |
| 25 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 26 | |
| 27 | int codeLength; |
| 28 | |
| 29 | codeLength = super.encode(os, false); |
| 30 | if (withTag) { |
| 31 | codeLength += tag.encode(os); |
| 32 | } |
| 33 | |
| 34 | return codeLength; |
| 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 39 | |
| 40 | int codeLength = 0; |
| 41 | |
| 42 | if (withTag) { |
| 43 | codeLength += tag.decodeAndCheck(is); |
| 44 | } |
| 45 | |
| 46 | codeLength += super.decode(is, false); |
| 47 | |
| 48 | return codeLength; |
| 49 | } |
| 50 | |
| 51 | } |