1 /*
2  * @(#) $Id: ASN1PrintableString.java,v 1.3 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 ASN1PrintableString 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 ASN1PrintableString(){
17        super(UNIVERSAL, NONE, PrintableString, PrintableString);
18    }
19
20    public String getString(){
21        return new String(value);
22    }
23    public void setString(String s){
24        this.value = s.getBytes();
25        this.length = this.value.length;
26    }
27    public String toString(){
28        if (value == null)
29            return null;
30        return new String(value);
31    }
32
33    public static void main(String[] args){
34        byte[] bytes = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x65, 0x72, 0x20, 0x31 };
35        ASN1PrintableString ps = new ASN1PrintableString();
36        ps.setValue(bytes);
37        System.out.println(ps.toString());
38    }
39}