1 /*
2  * @(#) $Id: ASN1IA5String.java,v 1.2 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
12public class ASN1IA5String extends ASN1Type {
13    private static char[] hexChars =
14        { '0', '1', '2', '3', '4', '5', '6', '7',
15          '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
16    public ASN1IA5String(){
17        super(UNIVERSAL, NONE, IA5String, IA5String);
18    }
19    public byte[] getValue(){
20        return value;
21    }
22    public void setValue(byte[] value){
23        this.value = value;
24    }
25    public String getString(){
26        return new String(value);
27    }
28    public void setString(String s){
29        this.value = s.getBytes();
30    }
31    public String toString(){
32        if (value == null)
33            return null;
34        return "IA5String: " + new String(value);
35    }
36
37    public static void main(String[] args){
38        byte[] bytes = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x65, 0x72, 0x20, 0x31 };
39        ASN1IA5String ps = new ASN1IA5String();
40        ps.setValue(bytes);
41        System.out.println(ps.toString());
42    }
43}