Package com.oss.asn1

Class Real

All Implemented Interfaces:
com.oss.asn1.Comparable, Serializable, Cloneable

public class Real extends AbstractReal
The Real class represents the ASN.1 REAL type.
Since:
ASN.1/Java 1.0-beta A
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Real
    The constant used to specify the ASN.1 REAL value, MINUS-INFINITY.
    static final Real
    The constant used to specify the ASN.1 REAL value, NOT-A-NUMBER.
    static final Real
    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

    Constructors
    Constructor
    Description
    The default constructor.
    Real(double value)
    Construct from a double.
    Real(float value)
    Construct from a float.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    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 another 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 another 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 another object.
    final String
    Get the value of 'this' object as a string in NR3 format.
    final double
    Get the value of 'this' object as a double.
    final boolean
    Compare 'this' object to another object to see if their contents are the same.
    final boolean
    Compare 'this' object to another object to see if their contents are the same.
    final boolean
    equalTo(Real that)
    Compare 'this' object to another object to see if their contents are the same.
    final float
    Get the value of 'this' object as a float.
    int
    Returns the base of the real number.
    int
    Returns a hash code for this object
    boolean
    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
    Detect if the current value is zero (0).
    final void
    setValue(double value)
    Set the value of 'this' object to a double value.
    final void
    setValue(float value)
    Set the value of 'this' object to 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

    clone, delete, equals, isEncodable, isPDU, isValid, toString, toString

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • PLUS_INFINITY

      public static final Real PLUS_INFINITY
      The constant used to specify the ASN.1 REAL value, PLUS-INFINITY.
    • MINUS_INFINITY

      public static final Real MINUS_INFINITY
      The constant used to specify the ASN.1 REAL value, MINUS-INFINITY.
    • NOT_A_NUMBER

      public static final Real NOT_A_NUMBER
      The constant used to specify the ASN.1 REAL value, NOT-A-NUMBER.
  • Constructor Details

    • Real

      public Real()
      The default constructor.
    • Real

      public Real(float value)
      Construct from a float.
      Parameters:
      value - the float value to set 'this' object to.
    • Real

      public Real(double value)
      Construct from a double.
      Parameters:
      value - the double value to set 'this' object to.
  • Method Details

    • setValue

      public final void setValue(float value)
      Set the value of 'this' object to 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 to a double value.
      Parameters:
      value - the double value to set 'this' object to.
    • setValue

      public final void setValue(String value)
      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

      public final String decimalValue()
      Get the value of 'this' object as a string in NR3 format.
      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

      public final boolean equalTo(Real that)
      Compare 'this' object to another object to see if their contents are the same.
      Parameters:
      that - the Real object to compare 'this' object to.
      Returns:
      true if contents of both objects are the same.
    • equalTo

      public final boolean equalTo(DecimalReal that)
      Compare 'this' object to another object to see if their contents are the same.
      Parameters:
      that - the DecimalReal object to compare 'this' object to.
      Returns:
      true if contents of both objects are the same.
    • equalTo

      public final boolean equalTo(MixedReal that)
      Compare 'this' object to another 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

      public final int compareTo(Real that)
      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 another object.
      Parameters:
      that - Real object that is compared with 'this' object
      Returns:
      LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
      Throws:
      NullPointerException - thrown when 'that' is null.
    • compareTo

      public 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 another object.
      Parameters:
      that - DecimalReal object that is compared with 'this' object
      Returns:
      LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
      Throws:
      NullPointerException - thrown when 'that' is null.
    • compareTo

      public final int compareTo(MixedReal that)
      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 another object.
      Parameters:
      that - MixedReal object that is compared with 'this' object
      Returns:
      LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
      Throws:
      NullPointerException - thrown when 'that' is null.
    • getBase

      public int getBase()
      Returns the base of the real number.
      Specified by:
      getBase in class AbstractReal
      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 class AbstractData
      Returns:
      a hash code for this object