Package com.oss.asn1
Class DecimalReal
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractReal
com.oss.asn1.DecimalReal
- All Implemented Interfaces:
com.oss.asn1.Comparable
,Serializable
,Cloneable
The DecimalReal class represents the ASN.1 REAL type with the DECIMAL
directive.
- Since:
- ASN.1/Java 1.0-beta A
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DecimalReal
The constant used to specify the ASN.1 REAL value, MINUS-INFINITY.static final DecimalReal
The constant used to specify the ASN.1 REAL value, NOT-A-NUMBER.static final DecimalReal
The constant used to specify the ASN.1 REAL value, PLUS-INFINITY.Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.DecimalReal
(double value) Construct from a double.DecimalReal
(float value) Construct from a float.DecimalReal
(String value) Construct from a String. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone 'this' object.final int
compareTo
(DecimalReal that) Compare 'this' object to a DecimalReal object by comparing their correspondent double values to see whether the double value of 'this' object is less than, equal to, or greater than the one of 'that' object.final int
Compare 'this' object to a MixedReal object by comparing their correspondent double values to see whether the double value of 'this' object is less than, equal to, or greater than the one of 'that' object.final int
Compare 'this' object to a Real object to determine whether the contents of 'this' object is less than, equal to, or greater than the contents of 'that' object.final String
Get the value of 'this' object as a string in NR3 format.void
delete()
Destroy the instance of the AbstractData.final double
Get the value of 'this' object as a double.final boolean
equalTo
(DecimalReal that) Compare 'this' object to 'that' object to see if their contents are the same.final boolean
Compare 'this' object to 'that' object to see if their contents are the same.final boolean
Compare 'this' object to 'that' object to see if their contents are the same.final float
Get the value of 'this' object as a float.int
getBase()
Returns the base of the real number.int
hashCode()
Returns a hash code for this objectboolean
isNaN()
Detect if the current value is NaN (NOT-A-NUMBER).boolean
Detect if the current value is -INFINITY.boolean
Detect if the current value is negative zero (-0).boolean
Detect if the current value is +INFINITY.boolean
isZero()
Detect if the current value is zero (0).final void
setValue
(double value) Set the value of 'this' object from a double value.final void
setValue
(float value) Set the value of 'this' object from a float value.final void
Set the value of 'this' object by converting the input String value into a double.Methods inherited from class com.oss.asn1.AbstractData
equals, isEncodable, isPDU, isValid, toString, toString
-
Field Details
-
PLUS_INFINITY
The constant used to specify the ASN.1 REAL value, PLUS-INFINITY. -
MINUS_INFINITY
The constant used to specify the ASN.1 REAL value, MINUS-INFINITY. -
NOT_A_NUMBER
The constant used to specify the ASN.1 REAL value, NOT-A-NUMBER.
-
-
Constructor Details
-
DecimalReal
public DecimalReal()The default constructor. -
DecimalReal
Construct from a String.- Parameters:
value
- the String value to set 'this' object to.
-
DecimalReal
public DecimalReal(double value) Construct from a double.- Parameters:
value
- the double value to set 'this' object to.
-
DecimalReal
public DecimalReal(float value) Construct from a float.- Parameters:
value
- the float value to set 'this' object to.
-
-
Method Details
-
setValue
public final void setValue(float value) Set the value of 'this' object from a float value.- Parameters:
value
- the value to set 'this' object to.
-
setValue
public final void setValue(double value) Set the value of 'this' object from a double value.- Parameters:
value
- the double value to set 'this' object to.
-
setValue
Set the value of 'this' object by converting the input String value into a double.- Parameters:
value
- the String value to set 'this' object to.
-
floatValue
public final float floatValue()Get the value of 'this' object as a float.- Returns:
- value of 'this' object as a float.
-
doubleValue
public final double doubleValue()Get the value of 'this' object as a double.- Returns:
- value of 'this' object as a double.
-
decimalValue
Get the value of 'this' object as a string in NR3 format. The NR3 format is defined in the ISO 6093:1985.- Returns:
- value of 'this' object as a string in NR3 format.
-
isZero
public boolean isZero()Detect if the current value is zero (0).- Returns:
- true if the current value is zero.
- Since:
- ASN.1/Java 7.0
-
isNegativeZero
public boolean isNegativeZero()Detect if the current value is negative zero (-0).- Returns:
- true if the current value is zero.
- Since:
- ASN.1/Java 7.0
-
isPositiveInfinity
public boolean isPositiveInfinity()Detect if the current value is +INFINITY.- Returns:
- true if the current value is +INFINITY.
- Since:
- ASN.1/Java 7.0
-
isNegativeInfinity
public boolean isNegativeInfinity()Detect if the current value is -INFINITY.- Returns:
- true if the current value is -INFINITY.
- Since:
- ASN.1/Java 7.0
-
isNaN
public boolean isNaN()Detect if the current value is NaN (NOT-A-NUMBER).- Returns:
- true if the current value is NaN.
- Since:
- ASN.1/Java 7.0
-
equalTo
Compare 'this' object to 'that' object to see if their contents are the same.- Parameters:
that
- the Real object to compare 'this' object to.- Returns:
- true if the contents of both objects are the same.
-
equalTo
Compare 'this' object to 'that' object to see if their contents are the same.- Parameters:
that
- the DecimalReal object to compare 'this' object to.- Returns:
- true if the contents of both objects are the same.
-
equalTo
Compare 'this' object to 'that' object to see if their contents are the same.- Parameters:
that
- the MixedReal object to compare 'this' object to.- Returns:
- true if contents of both objects are the same.
-
compareTo
Compare 'this' object to a Real object to determine whether the contents of 'this' object is less than, equal to, or greater than the contents of 'that' object.- Parameters:
that
- Real object that is compared with 'this' object- Returns:
- LESS_THAN, EQUALS, or GREATER_THAN to express the result of the comparison.
- Throws:
NullPointerException
- thrown when 'that' is null.
-
compareTo
Compare 'this' object to a DecimalReal object by comparing their correspondent double values to see whether the double value of 'this' object is less than, equal to, or greater than the one of 'that' object.- Parameters:
that
- DecimalReal object that is compared with 'this' object- Returns:
- LESS_THAN if the double value of 'this' is less than
the double value of the DecimalReal object.
EQUALS if the double value of 'this' equals to the
double value of the DecimalReal object
GREATER_THAN if the double value of 'this' is greater than
the double value of the DecimalReal object. - Throws:
NullPointerException
- is thrown when 'that' is null.
-
compareTo
Compare 'this' object to a MixedReal object by comparing their correspondent double values to see whether the double value of 'this' object is less than, equal to, or greater than the one of 'that' object.- Parameters:
that
- MixedReal object that is compared with 'this' object- Returns:
- LESS_THAN (-1) if the double value of 'this' is less than the double value of the MixedReal object. EQUALS (0) if the double value of 'this' equals to the double value of the MixedReal object GREATER_THAN (1) if the double value of 'this' is greater than the double value of the MixedReal object.
- Throws:
NullPointerException
- if 'that' is null.
-
clone
Clone 'this' object.- Overrides:
clone
in classAbstractData
- Returns:
- a deep copy of 'this' object.
-
delete
public void delete()Destroy the instance of the AbstractData. The contract of this method is to facilitate garbage collection by explicit destruction of the data that is no longer needed.- Overrides:
delete
in classAbstractData
-
getBase
public int getBase()Returns the base of the real number.- Specified by:
getBase
in classAbstractReal
- Returns:
- the base of the real number - 2 for binary real or 10 for decimal real
-
hashCode
public int hashCode()Returns a hash code for this object- Overrides:
hashCode
in classAbstractData
- Returns:
- a hash code for this object
-