Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1;
  
  
Base class for defining an ASN.1 object.
 
 public abstract class ASN1Object
     implements ASN1EncodableEncodable
 {
    
Return the default BER or DER encoding for this object.

Returns:
BER/DER byte encoded object.
Throws:
java.io.IOException on encoding error.
 
     public byte[] getEncoded()
         throws IOException
     {
         ByteArrayOutputStream bOut = new ByteArrayOutputStream();
         ASN1OutputStream      aOut = new ASN1OutputStream(bOut);
 
         aOut.writeObject(this);
 
         return bOut.toByteArray();
     }

    
Return either the default for "BER" or a DER encoding if "DER" is specified.

Parameters:
encoding name of encoding to use.
Returns:
byte encoded object.
Throws:
java.io.IOException on encoding error.
 
     public byte[] getEncoded(
         String encoding)
         throws IOException
     {
         if (encoding.equals(.))
         {
             ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
             DEROutputStream         dOut = new DEROutputStream(bOut);
 
             dOut.writeObject(this);
 
             return bOut.toByteArray();
         }
         else if (encoding.equals(.))
         {
             ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
             DLOutputStream          dOut = new DLOutputStream(bOut);
 
             dOut.writeObject(this);
 
             return bOut.toByteArray();
         }
 
         return this.getEncoded();
     }
 
     public int hashCode()
     {
         return this.toASN1Primitive().hashCode();
     }
 
     public boolean equals(
         Object  o)
     {
         if (this == o)
         {
             return true;
         }
 
         if (!(o instanceof ASN1Encodable))
         {
             return false;
         }
 
         ASN1Encodable other = (ASN1Encodable)o;
 
         return this.toASN1Primitive().equals(other.toASN1Primitive());
     }

    

Deprecated:
use toASN1Primitive()
Returns:
the underlying primitive type.
 
     public ASN1Primitive toASN1Object()
     {
         return this.toASN1Primitive();
     }

    
Return true if obj is a byte array and represents an object with the given tag value.

Parameters:
obj object of interest.
tagValue tag value to check for.
Returns:
true if obj is a byte encoding starting with the given tag value, false otherwise.
    protected static boolean hasEncodedTagValue(Object objint tagValue)
    {
        return (obj instanceof byte[]) && ((byte[])obj)[0] == tagValue;
    }

    
Method providing a primitive representation of this object suitable for encoding.

Returns:
a primitive representation of this object.
    public abstract ASN1Primitive toASN1Primitive();
New to GrepCode? Check out our FAQ X