com.objsys.asn1j.runtime
Class Asn1Integer

java.lang.Object
  extended by com.objsys.asn1j.runtime.Asn1Type
      extended by com.objsys.asn1j.runtime.Asn1Integer
All Implemented Interfaces:
Asn1TypeIF, java.io.Serializable, java.lang.Cloneable

public class Asn1Integer
extends Asn1Type

This class represents the ASN.1 INTEGER built-in type.

See Also:
Serialized Form

Field Summary
static java.lang.Object MAX
           
static java.lang.Object MIN
           
static Asn1Tag TAG
          The TAG constant describes the universal tag for this data type (UNIVERSAL 2).
 long value
          This public member variable is where the integer value is stored.
 
Fields inherited from class com.objsys.asn1j.runtime.Asn1Type
BIT_STRING, BMPString, BOOLEAN, DATE, DATE_TIME, DURATION, ENUMERATED, EOC, EXTERNAL, GeneralString, GeneralTime, GraphicString, IA5String, INTEGER, NULL, NumericString, OBJECT_IDENTIFIER, ObjectDescriptor, OCTET_STRING, OID_IRI, OpenType, PrintableString, REAL, RELATIVE_OID_IRI, RelativeOID, SEQUENCE, SET, T61String, TeletexString, TIME, TIME_OF_DAY, UniversalString, UTCTime, UTF8String, VideotexString, VisibleString
 
Constructor Summary
Asn1Integer()
          The default constructor sets the integer value to zero.
Asn1Integer(long value_)
          This constructor creates an integer object from a integer value.
 
Method Summary
 void decode(Asn1BerDecodeBuffer buffer, boolean explicit, int implicitLength)
          This method decodes an ASN.1 integer value including the UNIVERSAL tag value and length if explicit tagging is specified.
 void decode(Asn1JsonDecodeBuffer buffer)
          Decode ASN.1 INTEGER from JSON.
 void decode(Asn1PerDecodeBuffer buffer)
          This method decodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, long lower, long upper)
          This method decodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, long lower, java.lang.Object upper)
          This method decodes a semi-constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, java.lang.Object lower, long upper)
          This method decodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void decode(Asn1PerDecodeBuffer buffer, java.lang.Object lower, java.lang.Object upper)
          This method decodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void decode16Bit(Asn1MderDecodeBuffer buffer, boolean signed)
          Decode a signed or unsigned 16-bit integer from an MDER encoding.
 void decode32Bit(Asn1MderDecodeBuffer buffer, boolean signed)
          Decode a signed or unsigned 32-bit integer from an MDER encoding.
 void decode8Bit(Asn1MderDecodeBuffer buffer, boolean signed)
          Decode a signed or unsigned 8-bit integer from an MDER encoding.
static long decodeValue(Asn1PerDecodeBuffer buffer)
          This method decodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
static long decodeValue(Asn1PerDecodeBuffer buffer, long lower, long upper)
          This method decodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void decodeXER(java.lang.String buffer, java.lang.String attrs)
          This method decodes an ASN.1 integer value using the XML encoding rules (XER).
 void decodeXML(java.lang.String buffer, java.lang.String attrs)
          This method decodes an ASN.1 integer value using the XML schema encoding rules.
 int encode(Asn1BerEncodeBuffer buffer, boolean explicit)
          This method encodes an ASN.1 integer value including the UNIVERSAL tag value and length if explicit tagging is specified.
 void encode(Asn1BerOutputStream out, boolean explicit)
          This method encodes and writes to the stream an ASN.1 integer value including the UNIVERSAL tag value and length if explicit tagging is specified.
 void encode(Asn1JsonOutputStream out)
          Encode the value of this object as a JSON number.
 void encode(Asn1PerEncodeBuffer buffer)
          This method encodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, long lower, long upper)
          This method encodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, long lower, java.lang.Object upper)
          This method encodes a semi-constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, java.lang.Object lower, long upper)
          This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerEncodeBuffer buffer, java.lang.Object lower, java.lang.Object upper)
          This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerOutputStream out)
          This method encodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerOutputStream out, long lower, long upper)
          This method encodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerOutputStream out, long lower, java.lang.Object upper)
          This method encodes a semi-constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerOutputStream out, java.lang.Object lower, long upper)
          This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1PerOutputStream out, java.lang.Object lower, java.lang.Object upper)
          This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER).
 void encode(Asn1XerEncoder buffer, java.lang.String elemName)
          This method encodes an ASN.1 integer value using the XML encoding rules (XER).
 void encode(Asn1XmlEncoder buffer, java.lang.String elemName, java.lang.String nsPrefix)
          This method encodes an ASN.1 integer value using the XML Encoding as specified in the XML schema standard(asn2xsd).
 void encode16Bit(Asn1MderOutputStream out, boolean signed)
          This method encodes this ASN.1 INTEGER value to the MDER encoding.
 void encode32Bit(Asn1MderOutputStream out, boolean signed)
          This method encodes this ASN.1 INTEGER value to the MDER encoding.
 void encode8Bit(Asn1MderOutputStream out, boolean signed)
          This method encodes this ASN.1 INTEGER value to the MDER encoding.
 void encodeAttribute(Asn1XmlEncoder buffer, java.lang.String attrName)
          This method encodes an ASN.1 integer value using the XML Encoding as specified in the XML schema standard(asn2xsd).
static void encodeValue(Asn1PerEncoder encoder, long value, long lower, long upper)
          This method encodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER).
 boolean equals(long lvalue)
          This method compares this integer value to the given value for equality.
 boolean equals(java.lang.Object o)
          This method compares this integer value to the given value for equality.
 int getBitCount()
          This method calculates the count of bits in the contained integer value.
static int getBitCount(long ivalue)
          This method calculates the count of bits in an integer value.
 int getUnsignedBitCount()
          This method calculates the count of bits in the contained unsigned integer value.
static int getUnsignedBitCount(long ivalue)
          This method calculates the count of bits in an unsigned integer value.
 int hashCode()
          This method returns the hash code for this integer value.
 java.lang.String toString()
          This method will return a string representation of the integer value.
 
Methods inherited from class com.objsys.asn1j.runtime.Asn1Type
clone, decode, decode, decode, decode, decode, encode, encode, equals, getLength, getTypeName, indent, isOpenType, matchTag, matchTag, pdiag, print, setKey, setOpenType
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN

public static final java.lang.Object MIN

MAX

public static final java.lang.Object MAX

TAG

public static final Asn1Tag TAG
The TAG constant describes the universal tag for this data type (UNIVERSAL 2).


value

public transient long value
This public member variable is where the integer value is stored. This is the value that is encoded when one of the encode methods is called. It is also where the decoded result is stored when a decode method is called.

Constructor Detail

Asn1Integer

public Asn1Integer()
The default constructor sets the integer value to zero.


Asn1Integer

public Asn1Integer(long value_)
This constructor creates an integer object from a integer value.

Parameters:
value_ - Integer value
Method Detail

decode

public void decode(Asn1BerDecodeBuffer buffer,
                   boolean explicit,
                   int implicitLength)
            throws Asn1Exception,
                   java.io.IOException
This method decodes an ASN.1 integer value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Specified by:
decode in interface Asn1TypeIF
Overrides:
decode in class Asn1Type
Parameters:
buffer - Decode message buffer object
explicit - Flag indicating element is explicitly tagged
implicitLength - Length of contents if implicit
Throws:
Asn1Exception
java.io.IOException

encode

public int encode(Asn1BerEncodeBuffer buffer,
                  boolean explicit)
           throws Asn1Exception
This method encodes an ASN.1 integer value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - Encode message buffer object
explicit - Flag indicating explicit tagging should be done
Returns:
Length of component or negative status value
Throws:
Asn1Exception

decode

public void decode(Asn1PerDecodeBuffer buffer)
            throws Asn1Exception,
                   java.io.IOException
This method decodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are decoded. The decoded result is stored in the public member 'value' in this object.

Specified by:
decode in interface Asn1TypeIF
Overrides:
decode in class Asn1Type
Parameters:
buffer - PER Decode message buffer object
Throws:
Asn1Exception
java.io.IOException

decodeValue

public static long decodeValue(Asn1PerDecodeBuffer buffer)
                        throws Asn1Exception,
                               java.io.IOException
This method decodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are decoded.

Parameters:
buffer - PER Decode message buffer object
Returns:
The decoded value
Throws:
Asn1Exception
java.io.IOException

decodeValue

public static long decodeValue(Asn1PerDecodeBuffer buffer,
                               long lower,
                               long upper)
                        throws Asn1Exception,
                               java.io.IOException
This method decodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER).

Parameters:
buffer - PER Decode message buffer object
lower - Lower bound of the integer range
upper - Upper bound of the integer range
Returns:
The decoded result.
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   long lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER). The decoded result is stored in the public member 'value' in this object.

Parameters:
buffer - PER Decode message buffer object
lower - Lower bound of the integer range
upper - Upper bound of the integer range
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   java.lang.Object lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The decoded result is stored in the public member 'value' in this object.

Parameters:
buffer - PER Decode message buffer object
lower - Lower bound equal MIN
upper - Upper bound of the integer range
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   long lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a semi-constrained ASN.1 integer value using the Packed Encoding Rules (PER). The decoded result is stored in the public member 'value' in this object.

Parameters:
buffer - PER Decode message buffer object
lower - Lower bound of the integer range
upper - Upper bound equal MAX
Throws:
Asn1Exception
java.io.IOException

decode

public void decode(Asn1PerDecodeBuffer buffer,
                   java.lang.Object lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method decodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The decoded result is stored in the public member 'value' in this object.

Parameters:
buffer - PER Decode message buffer object
lower - Lower bound equal MIN
upper - Upper bound equal MAX
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer)
            throws Asn1Exception,
                   java.io.IOException
This method encodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - PER Encode message buffer object
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   long lower,
                   long upper)
            throws Asn1Exception
This method encodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
buffer - PER Encode message buffer object
lower - Lower bound (inclusive) of integer being encoded
upper - Upper bound (inclusive) of integer being encoded
Throws:
Asn1Exception

encodeValue

public static void encodeValue(Asn1PerEncoder encoder,
                               long value,
                               long lower,
                               long upper)
                        throws Asn1Exception
This method encodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
buffer - PER Encode message buffer object
value - The value to encode
lower - Lower bound (inclusive) of integer being encoded
upper - Upper bound (inclusive) of integer being encoded
Throws:
Asn1Exception

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   java.lang.Object lower,
                   long upper)
            throws Asn1Exception
This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
buffer - PER Encode message buffer object
lower - Lower bound equal MIN
upper - Upper bound (inclusive) of integer being encoded
Throws:
Asn1Exception

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   long lower,
                   java.lang.Object upper)
            throws Asn1Exception
This method encodes a semi-constrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
buffer - PER Encode message buffer object
lower - Lower bound (inclusive) of integer being encoded
upper - Upper bound equal MAX
Throws:
Asn1Exception

encode

public void encode(Asn1PerEncodeBuffer buffer,
                   java.lang.Object lower,
                   java.lang.Object upper)
            throws Asn1Exception
This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
buffer - PER Encode message buffer object
lower - Lower bound equal MIN
upper - Upper bound equal MAX
Throws:
Asn1Exception

decode8Bit

public void decode8Bit(Asn1MderDecodeBuffer buffer,
                       boolean signed)
                throws Asn1Exception,
                       java.io.IOException
Decode a signed or unsigned 8-bit integer from an MDER encoding. This should be used to decode integer types that are constrained to exactly the value space of a signed/unsigned 8 bit integer.

Throws:
Asn1Exception
java.io.IOException

decode16Bit

public void decode16Bit(Asn1MderDecodeBuffer buffer,
                        boolean signed)
                 throws Asn1Exception,
                        java.io.IOException
Decode a signed or unsigned 16-bit integer from an MDER encoding. This should be used to decode integer types that are constrained to exactly the value space of a signed/unsigned 16 bit integer.

Throws:
Asn1Exception
java.io.IOException

decode32Bit

public void decode32Bit(Asn1MderDecodeBuffer buffer,
                        boolean signed)
                 throws Asn1Exception,
                        java.io.IOException
Decode a signed or unsigned 32-bit integer from an MDER encoding. This should be used to decode integer types that are constrained to exactly the value space of a signed/unsigned 32 bit integer.

Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1XerEncoder buffer,
                   java.lang.String elemName)
            throws java.io.IOException,
                   Asn1Exception
This method encodes an ASN.1 integer value using the XML encoding rules (XER).

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
buffer - Encode message buffer object
elemName - Element name
Throws:
java.io.IOException - Any exception thrown by the underlying stream.
Asn1Exception - Thrown, if operation is failed.

decodeXER

public void decodeXER(java.lang.String buffer,
                      java.lang.String attrs)
               throws Asn1Exception
This method decodes an ASN.1 integer value using the XML encoding rules (XER).

Parameters:
buffer - String containing data to be decoded
attrs - Attributes string from element tag
Throws:
Asn1Exception

encode

public void encode(Asn1XmlEncoder buffer,
                   java.lang.String elemName,
                   java.lang.String nsPrefix)
            throws java.io.IOException,
                   Asn1Exception
This method encodes an ASN.1 integer value using the XML Encoding as specified in the XML schema standard(asn2xsd).

Parameters:
buffer - Encode message buffer object
elemName - Element name
nsPrefix - XML element name space prefix
Throws:
java.io.IOException
Asn1Exception

encodeAttribute

public void encodeAttribute(Asn1XmlEncoder buffer,
                            java.lang.String attrName)
                     throws Asn1Exception,
                            java.io.IOException
This method encodes an ASN.1 integer value using the XML Encoding as specified in the XML schema standard(asn2xsd).

Parameters:
buffer - Encode message buffer object
attrName - Attribute name
Throws:
Asn1Exception
java.io.IOException

decodeXML

public void decodeXML(java.lang.String buffer,
                      java.lang.String attrs)
               throws Asn1Exception
This method decodes an ASN.1 integer value using the XML schema encoding rules.

Specified by:
decodeXML in interface Asn1TypeIF
Overrides:
decodeXML in class Asn1Type
Parameters:
buffer - String containing data to be decoded
attrs - Attributes string from element tag
Throws:
Asn1Exception

decode

public void decode(Asn1JsonDecodeBuffer buffer)
            throws java.io.IOException
Decode ASN.1 INTEGER from JSON.

Parameters:
buffer -
Throws:
java.io.IOException

encode

public void encode(Asn1JsonOutputStream out)
            throws java.io.IOException
Encode the value of this object as a JSON number.

Parameters:
out -
Throws:
java.io.IOException

equals

public boolean equals(long lvalue)
This method compares this integer value to the given value for equality.

Parameters:
lvalue - Integer test value

equals

public boolean equals(java.lang.Object o)
This method compares this integer value to the given value for equality.

Overrides:
equals in class java.lang.Object
Parameters:
o - Asn1Integer object containing value to compare

hashCode

public int hashCode()
This method returns the hash code for this integer value.

Overrides:
hashCode in class Asn1Type

getBitCount

public static int getBitCount(long ivalue)
This method calculates the count of bits in an integer value.

Parameters:
ivalue - Integer value in which to count bits.
Returns:
Bit count.

getBitCount

public int getBitCount()
This method calculates the count of bits in the contained integer value.

Returns:
Bit count.

getUnsignedBitCount

public static int getUnsignedBitCount(long ivalue)
This method calculates the count of bits in an unsigned integer value.

Parameters:
ivalue - Integer value in which to count bits.
Returns:
Bit count.

getUnsignedBitCount

public int getUnsignedBitCount()
This method calculates the count of bits in the contained unsigned integer value.

Returns:
Bit count.

toString

public java.lang.String toString()
This method will return a string representation of the integer value. The format is the ASN.1 value format for this type.

Overrides:
toString in class java.lang.Object
Returns:
Stringified representation of the value

encode

public void encode(Asn1BerOutputStream out,
                   boolean explicit)
            throws Asn1Exception,
                   java.io.IOException
This method encodes and writes to the stream an ASN.1 integer value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
out - BER Output Stream object
explicit - Flag indicating explicit tagging should be done
Throws:
java.io.IOException - Any exception thrown by the underlying OutputStream.
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1PerOutputStream out)
            throws Asn1Exception,
                   java.io.IOException
This method encodes an unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Specified by:
encode in interface Asn1TypeIF
Overrides:
encode in class Asn1Type
Parameters:
out - PER Encode message buffer object
Throws:
java.io.IOException - Any exception thrown by the Asn1PerOutputStream.
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1PerOutputStream out,
                   long lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a constrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
out - PER Encode message buffer object
lower - Lower bound (inclusive) of integer being encoded
upper - Upper bound (inclusive) of integer being encoded
Throws:
java.io.IOException - Any exception thrown by the Asn1PerOutputStream.
Asn1Exception - Thrown, if operation is failed.

encode

public void encode(Asn1PerOutputStream out,
                   java.lang.Object lower,
                   long upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
out - PER Encode message buffer object
lower - Lower bound equal MIN
upper - Upper bound (inclusive) of integer being encoded
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerOutputStream out,
                   long lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a semi-constrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
out - PER Encode message buffer object
lower - Lower bound (inclusive) of integer being encoded
upper - Upper bound equal MAX
Throws:
Asn1Exception
java.io.IOException

encode

public void encode(Asn1PerOutputStream out,
                   java.lang.Object lower,
                   java.lang.Object upper)
            throws Asn1Exception,
                   java.io.IOException
This method encodes a unconstrained ASN.1 integer value using the Packed Encoding Rules (PER). The length and contents components of the message are encoded.

Parameters:
out - PER Encode message buffer object
lower - Lower bound equal MIN
upper - Upper bound equal MAX
Throws:
Asn1Exception
java.io.IOException

encode8Bit

public final void encode8Bit(Asn1MderOutputStream out,
                             boolean signed)
                      throws Asn1Exception,
                             java.io.IOException
This method encodes this ASN.1 INTEGER value to the MDER encoding. The value must fall in the set of 8-bit unsigned integers (if signed is false) or 8-bit signed integers (if signed is true).

Throws:
Asn1Exception
java.io.IOException

encode16Bit

public final void encode16Bit(Asn1MderOutputStream out,
                              boolean signed)
                       throws Asn1Exception,
                              java.io.IOException
This method encodes this ASN.1 INTEGER value to the MDER encoding. The value must fall in the set of 16-bit unsigned integers (if signed is false) or 16-bit signed integers (if signed is true).

Throws:
Asn1Exception
java.io.IOException

encode32Bit

public final void encode32Bit(Asn1MderOutputStream out,
                              boolean signed)
                       throws Asn1Exception,
                              java.io.IOException
This method encodes this ASN.1 INTEGER value to the MDER encoding. The value must fall in the set of 32-bit unsigned integers (if signed is false) or 32-bit signed integers (if signed is true).

Throws:
Asn1Exception
java.io.IOException