FileDocCategorySizeDatePackage
DERUniversalString.javaAPI DocAndroid 1.5 API2963Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1

DERUniversalString

public class DERUniversalString extends DERObject implements DERString
DER UniversalString object.

Fields Summary
private static final char[]
table
private byte[]
string
Constructors Summary
public DERUniversalString(byte[] string)
basic constructor - byte encoded string.

        this.string = string;
    
Methods Summary
voidencode(DEROutputStream out)

        out.writeEncoded(UNIVERSAL_STRING, this.getOctets());
    
public booleanequals(java.lang.Object o)

        if ((o == null) || !(o instanceof DERUniversalString))
        {
            return false;
        }

        return this.getString().equals(((DERUniversalString)o).getString());
    
public static org.bouncycastle.asn1.DERUniversalStringgetInstance(java.lang.Object obj)
return a Universal String from the passed in object.

exception
IllegalArgumentException if the object cannot be converted.

    
                          
       
          
    
        if (obj == null || obj instanceof DERUniversalString)
        {
            return (DERUniversalString)obj;
        }

        if (obj instanceof ASN1OctetString)
        {
            return new DERUniversalString(((ASN1OctetString)obj).getOctets());
        }

        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
    
public static org.bouncycastle.asn1.DERUniversalStringgetInstance(ASN1TaggedObject obj, boolean explicit)
return a Universal String from a tagged object.

param
obj the tagged object holding the object we want
param
explicit true if the object is meant to be explicitly tagged false otherwise.
exception
IllegalArgumentException if the tagged object cannot be converted.

        return getInstance(obj.getObject());
    
public byte[]getOctets()

        return string;
    
public java.lang.StringgetString()

        StringBuffer    buf = new StringBuffer("#");
        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
        ASN1OutputStream            aOut = new ASN1OutputStream(bOut);
        
        try
        {
            aOut.writeObject(this);
        }
        catch (IOException e)
        {
           throw new RuntimeException("internal error encoding BitString");
        }
        
        byte[]    string = bOut.toByteArray();
        
        for (int i = 0; i != string.length; i++)
        {
            buf.append(table[(string[i] >>> 4) % 0xf]);
            buf.append(table[string[i] & 0xf]);
        }
        
        return buf.toString();
    
public inthashCode()

        return this.getString().hashCode();