FileDocCategorySizeDatePackage
ASN1Integer.javaAPI DocAndroid 1.5 API3970Wed May 06 22:41:06 BST 2009org.apache.harmony.security.asn1

ASN1Integer

public class ASN1Integer extends ASN1Primitive
This class represents ASN.1 Integer type.
see
ASN.1

Fields Summary
private static final ASN1Integer
ASN1
Constructors Summary
public ASN1Integer()
Constructs ASN.1 Integer type The constructor is provided for inheritance purposes when there is a need to create a custom ASN.1 Integer type. To get a default implementation it is recommended to use getInstance() method.


                                             
      
        super(TAG_INTEGER);
    
Methods Summary
public java.lang.Objectdecode(BerInputStream in)

        in.readInteger();

        if (in.isVerify) {
            return null;
        }
        return getDecodedObject(in);
    
public voidencodeContent(BerOutputStream out)

        out.encodeInteger();
    
public static java.lang.ObjectfromIntValue(int value)
Converts primitive int value to a form most suitable for encoding.

param
value primitive value to be encoded
return
object suitable for encoding

        //FIXME optimize
        return BigInteger.valueOf(value).toByteArray();
    
public java.lang.ObjectgetDecodedObject(BerInputStream in)
Extracts array of bytes from BER input stream.

param
in - BER input stream
return
array of bytes

        byte[] bytesEncoded = new byte[in.length];
        System.arraycopy(in.buffer, in.contentOffset, bytesEncoded, 0,
                in.length);
        return bytesEncoded;
    
public static org.apache.harmony.security.asn1.ASN1IntegergetInstance()
Returns ASN.1 Integer type default implementation The default implementation works with encoding that is represented as byte array in two's-complement notation.

return
ASN.1 Integer type default implementation

        return ASN1;
    
public voidsetEncodingContent(BerOutputStream out)

        out.length = ((byte[]) out.content).length;
    
public static java.math.BigIntegertoBigIntegerValue(java.lang.Object decoded)
Converts decoded ASN.1 Integer to a BigInteger.

param
decoded a decoded object corresponding to this type
return
decoded BigInteger value.

        return new BigInteger((byte[]) decoded);//FIXME optimize
    
public static inttoIntValue(java.lang.Object decoded)
Converts decoded ASN.1 Integer to int value. If the object represents an integer value larger than 32 bits, the high bits will be lost.

param
decoded a decoded object corresponding to this type
return
decoded int value.

        return new BigInteger((byte[]) decoded).intValue();//FIXME optimize