blob: cfd8d65beb3c4fdd40ce4aa28874d90aead4fd88 [file] [log] [blame]
slowr60d4d102017-08-16 18:33:58 -07001/* 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/. */
4package org.onosproject.xran.codecs.ber.types;
5
6import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
7import org.onosproject.xran.codecs.ber.BerTag;
8import org.onosproject.xran.codecs.ber.types.string.BerVisibleString;
9
10import java.io.IOException;
11import java.io.InputStream;
12import java.io.UnsupportedEncodingException;
13
14public class BerTime extends BerVisibleString {
15
16 public final static BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.PRIMITIVE, BerTag.TIME_TAG);
17 private static final long serialVersionUID = 1L;
18
19 public BerTime() {
20 }
21
22 public BerTime(byte[] value) {
23 super(value);
24 }
25
26 public BerTime(String valueAsString) throws UnsupportedEncodingException {
27 super(valueAsString);
28 }
29
30 @Override
31 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
32
33 int codeLength = super.encode(os, false);
34
35 if (withTag) {
36 codeLength += tag.encode(os);
37 }
38
39 return codeLength;
40 }
41
42 @Override
43 public int decode(InputStream is, boolean withTag) throws IOException {
44
45 int codeLength = 0;
46
47 if (withTag) {
48 codeLength += tag.decodeAndCheck(is);
49 }
50
51 codeLength += super.decode(is, false);
52
53 return codeLength;
54 }
55
56}