1
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}