ch.panter.li.bi.asn
Class AsnIntegralNumberImpl

java.lang.Object
  extended by ch.panter.li.bi.asn.AsnIntegralNumberImpl
All Implemented Interfaces:
AsnIntegralNumber, Comparable<Object>

public final class AsnIntegralNumberImpl
extends Object
implements AsnIntegralNumber


Constructor Summary
AsnIntegralNumberImpl()
           
AsnIntegralNumberImpl(AsnIntegralNumber copy)
           
AsnIntegralNumberImpl(BigInteger value)
           
AsnIntegralNumberImpl(int value)
           
AsnIntegralNumberImpl(long value)
           
 
Method Summary
 int compareTo(Object compare)
           
 boolean equals(Object compare)
           
 Number getValue()
          The value bits of this instance as an abstract number (Integer, Long, BigInteger).
 int getValueAsInt()
          The value of this instance as a java int.
 Number getValueLarge()
          The value bits of this instance as an abstract number (Long, BigInteger).
 int hashCode()
           
 boolean hasSameNumericalValue(Number compare)
          Determines whether this instances value matches the one of the given number.
 boolean isValueAnInt()
          Determines whether the value of this tag can be represented in a java int.
 void setValueAsInt(int value)
          Sets the new value to the given value and resets any previously set bits.
 void setValueLarge(BigInteger valueLarge)
          Sets the new value to the given abstract number.
 void setValueLarge(Long valueLarge)
          Sets the new value to the given abstract number.
 String toHexString()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AsnIntegralNumberImpl

public AsnIntegralNumberImpl()

AsnIntegralNumberImpl

public AsnIntegralNumberImpl(int value)

AsnIntegralNumberImpl

public AsnIntegralNumberImpl(long value)

AsnIntegralNumberImpl

public AsnIntegralNumberImpl(BigInteger value)

AsnIntegralNumberImpl

public AsnIntegralNumberImpl(AsnIntegralNumber copy)
Method Detail

getValue

public final Number getValue()
Description copied from interface: AsnIntegralNumber
The value bits of this instance as an abstract number (Integer, Long, BigInteger). Always safe to call, independent of the result of isValueAnInt().

Specified by:
getValue in interface AsnIntegralNumber
Returns:
the value bits of this instance as an abstract number

hasSameNumericalValue

public final boolean hasSameNumericalValue(Number compare)
Description copied from interface: AsnIntegralNumber
Determines whether this instances value matches the one of the given number.

Specified by:
hasSameNumericalValue in interface AsnIntegralNumber
Parameters:
compare - the value to compare our value to
Returns:
true if the two numbers represent the same numerical value, false otherwise

isValueAnInt

public final boolean isValueAnInt()
Description copied from interface: AsnIntegralNumber
Determines whether the value of this tag can be represented in a java int. Depending on the result of this method one of the getValueAsInt() or getValueBits() must be used to access the value.

Specified by:
isValueAnInt in interface AsnIntegralNumber
Returns:
true if it is safe to call getValueAsInt(), false if getValueBits() must be used.

getValueAsInt

public final int getValueAsInt()
Description copied from interface: AsnIntegralNumber
The value of this instance as a java int. May only be called if isValueAnInt() returned true.

Specified by:
getValueAsInt in interface AsnIntegralNumber
Returns:
the value of this instance as a java int

setValueAsInt

public final void setValueAsInt(int value)
Sets the new value to the given value and resets any previously set bits.

Parameters:
value - the new value to set
Throws:
IllegalArgumentException - in case the given number is below zero

getValueLarge

public final Number getValueLarge()
Description copied from interface: AsnIntegralNumber
The value bits of this instance as an abstract number (Long, BigInteger). May only be called if isValueAnInt() returned false.

Specified by:
getValueLarge in interface AsnIntegralNumber
Returns:
the value bits of this instance as an abstract number

setValueLarge

public final void setValueLarge(Long valueLarge)
Sets the new value to the given abstract number. Reverts to java int if the value represented in the given number fits into a java int value.

Parameters:
valueLarge - the new value to set
Throws:
IllegalArgumentException - in case the given number is null or below zero

setValueLarge

public final void setValueLarge(BigInteger valueLarge)
Sets the new value to the given abstract number. Reverts to java int (long) if the value represented in the given number fits into a java int (long) value.

Parameters:
valueLarge - the new value to set
Throws:
IllegalArgumentException - in case the given number is null or below zero

compareTo

public int compareTo(Object compare)
Specified by:
compareTo in interface Comparable<Object>

equals

public final boolean equals(Object compare)
Overrides:
equals in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toHexString

public String toHexString()


Copyright 2007-2007 SourceForge. All Rights Reserved.