Class ASN1Integer

All Implemented Interfaces:
ASN1Constants

public final class ASN1Integer
extends ASN1Primitive
This class represents ASN.1 Integer type.
See Also:
ASN.1
  • Constructor Details

    • ASN1Integer

      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.
  • Method Details

    • getInstance

      public static ASN1Integer getInstance()
      Returns ASN.1 Integer type default implementation The default implementation works with encoding that is represented as byte array in two's-complement notation.
      Returns:
      ASN.1 Integer type default implementation
    • decode

      public Object decode​(BerInputStream in) throws IOException
      Description copied from class: ASN1Type
      Decodes ASN.1 type.
      Specified by:
      decode in class ASN1Type
      Throws:
      IOException - if an I/O error occurs or the end of the stream is reached
    • getDecodedObject

      public Object getDecodedObject​(BerInputStream in) throws IOException
      Extracts array of bytes from BER input stream.
      Overrides:
      getDecodedObject in class ASN1Type
      Returns:
      array of bytes
      Throws:
      IOException
    • encodeContent

      public void encodeContent​(BerOutputStream out)
      Specified by:
      encodeContent in class ASN1Type
    • setEncodingContent

      public void setEncodingContent​(BerOutputStream out)
      Specified by:
      setEncodingContent in class ASN1Type
    • toIntValue

      public static int toIntValue​(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.
      Parameters:
      decoded - a decoded object corresponding to this type
      Returns:
      decoded int value.
    • toBigIntegerValue

      public static BigInteger toBigIntegerValue​(Object decoded)
      Converts decoded ASN.1 Integer to a BigInteger.
      Parameters:
      decoded - a decoded object corresponding to this type
      Returns:
      decoded BigInteger value.
    • fromIntValue

      public static Object fromIntValue​(int value)
      Converts primitive int value to a form most suitable for encoding.
      Parameters:
      value - primitive value to be encoded
      Returns:
      object suitable for encoding