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