FileDocCategorySizeDatePackage
DERUniversalString.javaAPI DocAzureus 3.0.3.42521Tue Jun 08 05:12:56 BST 2004org.bouncycastle.asn1

DERUniversalString

public class DERUniversalString extends DERObject implements DERString
DER UniversalString object.

Fields Summary
byte[]
string
char[]
table
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()
UniversalStrings have characters which are 4 bytes long - for the moment we just return them in Hex...

        StringBuffer    buf = new StringBuffer();

        for (int i = 0; i != string.length; i++)
        {
            buf.append(table[(string[i] >>> 4) % 0xf]);
            buf.append(table[string[i] & 0xf]);
        }

        return buf.toString();