org.demac.impl.j2me.process.base.service.webservices.asn1
Class ASN1Integer

java.lang.Object
  extended by org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1AbstractType
      extended by org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1Integer
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, ASN1Type
Direct Known Subclasses:
ASN1Enumerated

public class ASN1Integer
extends ASN1AbstractType

Represents an ASN.1 INTEGER type. The corresponding Java type is java.math.BigInteger.

See Also:
Serialized Form

Constructor Summary
ASN1Integer()
          Creates a new instance ready for parsing.
ASN1Integer(java.math.BigInteger val)
          Creates a new instance with the given BigInteger as its initial value.
ASN1Integer(byte[] val)
          Creates a new instance from the given byte array.
ASN1Integer(int n)
          Creates an instance with the given int value.
ASN1Integer(int signum, byte[] magnitude)
          Translates the sign-magnitude representation of a BigInteger into an ASN.1 INTEGER.
ASN1Integer(java.lang.String val)
          Creates an ASN.1 INTEGER from the given string representation.
 
Method Summary
 void decode(Decoder dec)
           
 void encode(Encoder enc)
           
 java.math.BigInteger getBigInteger()
           
 int getTag()
          Returns the corresponding ASN.1 tag.
 java.lang.Object getValue()
          This abstract method should return the value wrapped by the ASN1Type.
 void setBigInteger(java.math.BigInteger n)
           
 java.lang.String toString()
           
 
Methods inherited from class org.demac.impl.j2me.process.base.service.webservices.asn1.ASN1AbstractType
checkConstraints, getConstraint, getTagClass, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, writeExternal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ASN1Integer

public ASN1Integer()
Creates a new instance ready for parsing. The value of this instance is set to 0.


ASN1Integer

public ASN1Integer(java.math.BigInteger val)
Creates a new instance with the given BigInteger as its initial value.

Parameters:
val - The value.

ASN1Integer

public ASN1Integer(java.lang.String val)
            throws java.lang.NumberFormatException
Creates an ASN.1 INTEGER from the given string representation. This method calls the equivalent constructor of class java.math.BigInteger.

Parameters:
val - The string representation of the multiple precision integer.
Throws:
java.lang.NumberFormatException - if the string could not be parsed successfully.

ASN1Integer

public ASN1Integer(byte[] val)
            throws java.lang.NumberFormatException
Creates a new instance from the given byte array. The byte array contains the two's-complement binary representation of a BigInteger. The input array is assumed to be in big endian byte-order. The most significant byte is in the zeroth element. This method calls the equivalent constructor of class java.math.BigInteger.

Parameters:
val - The two's-complement input number in big endian byte-order.
Throws:
java.lang.NumberFormatException - if val is zero bytes long.

ASN1Integer

public ASN1Integer(int signum,
                   byte[] magnitude)
            throws java.lang.NumberFormatException
Translates the sign-magnitude representation of a BigInteger into an ASN.1 INTEGER. The sign is represented as an integer signum value: -1 for negative, 0 for zero, or 1 for positive. The magnitude is a byte array in big-endian byte-order: the most significant byte is in the zeroth element. A zero-length magnitude array is permissible, and will result in in a BigInteger value of 0, whether signum is -1, 0 or 1.

This method calls the equivalent constructor of class java.math.BigInteger.

Parameters:
signum - signum of the number (-1 for negative, 0 for zero, 1 for positive).
magnitude - The big endian binary representation of the magnitude of the number.
Throws:
java.lang.NumberFormatException - signum is not one of the three legal values (-1, 0, and 1), or signum is 0 and magnitude contains one or more non-zero bytes.

ASN1Integer

public ASN1Integer(int n)
Creates an instance with the given int value.

Parameters:
n - The integer to initialize with.
Method Detail

getValue

public java.lang.Object getValue()
Description copied from class: ASN1AbstractType
This abstract method should return the value wrapped by the ASN1Type.

Specified by:
getValue in interface ASN1Type
Specified by:
getValue in class ASN1AbstractType
Returns:
the internal value

getBigInteger

public java.math.BigInteger getBigInteger()

setBigInteger

public void setBigInteger(java.math.BigInteger n)
                   throws ConstraintException
Throws:
ConstraintException

getTag

public int getTag()
Description copied from class: ASN1AbstractType
Returns the corresponding ASN.1 tag.

Specified by:
getTag in interface ASN1Type
Specified by:
getTag in class ASN1AbstractType
Returns:
the corresponding ASN.1 tag

encode

public void encode(Encoder enc)
            throws ASN1Exception,
                   java.io.IOException
Specified by:
encode in interface ASN1Type
Specified by:
encode in class ASN1AbstractType
Throws:
ASN1Exception
java.io.IOException

decode

public void decode(Decoder dec)
            throws ASN1Exception,
                   java.io.IOException
Specified by:
decode in interface ASN1Type
Specified by:
decode in class ASN1AbstractType
Throws:
ASN1Exception
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object