1 /*
2  * @(#) $Id: ASN1Integer.java,v 1.4 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10package org.jstk.asn1;
11
12import java.math.BigInteger;
13
14public class ASN1Integer extends ASN1Type {
15    public ASN1Integer(){
16        super(UNIVERSAL, NONE, INTEGER, INTEGER);
17    }
18    public ASN1Integer(byte tagClass, int taggingMethod, int tagNumber){
19        super(tagClass, taggingMethod, tagNumber, INTEGER);
20    }
21    public void setValue(BigInteger value){
22        byte[] val = value.toByteArray();
23        setValue(val);
24    }
25    public void setDefaultValue(BigInteger value){
26        this.defvalue = value.toByteArray();
27    }
28    public BigInteger getDefaultValue(){
29        return new BigInteger(defvalue);
30    }
31    public String toString(){
32        if (getValue() == null)
33            return null;
34        return (new BigInteger(getValue())).toString();
35    }
36
37    public static void main(String[] args){
38        byte[] bytes = { (byte)0x00, 0x01 };
39        ASN1Integer ai = new ASN1Integer();
40        ai.setValue(bytes);
41        System.out.println(ai.toString());
42    }
43}