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