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

DEROutputStream

public class DEROutputStream extends FilterOutputStream implements DERTags

Fields Summary
Constructors Summary
public DEROutputStream(OutputStream os)

        super(os);
    
Methods Summary
voidwriteEncoded(int tag, byte[] bytes)

        write(tag);
        writeLength(bytes.length);
        write(bytes);
    
private voidwriteLength(int length)

        if (length > 127)
        {
            int size = 1;
            int val = length;

            while ((val >>>= 8) != 0)
            {
                size++;
            }

            write((byte)(size | 0x80));

            for (int i = (size - 1) * 8; i >= 0; i -= 8)
            {
                write((byte)(length >> i));
            }
        }
        else
        {
            write((byte)length);
        }
    
protected voidwriteNull()

        write(NULL);
        write(0x00);
    
public voidwriteObject(java.lang.Object obj)

        if (obj == null)
        {
            writeNull();
        }
        else if (obj instanceof DERObject)
        {
            ((DERObject)obj).encode(this);
        }
        else if (obj instanceof DEREncodable)
        {
            ((DEREncodable)obj).getDERObject().encode(this);
        }
        else 
        {
            throw new IOException("object not DEREncodable");
        }