jcaas.script_nodes
Class NumericValue

java.lang.Object
  extended by jcaas.script_nodes.NumericValue
All Implemented Interfaces:
java.lang.Comparable

public class NumericValue
extends java.lang.Object
implements java.lang.Comparable

This class represents a NUMERIC_VALUE in a script.


Field Summary
static int DOUBLE
           
static int INTEGER
           
 
Constructor Summary
NumericValue(double value)
          Construct a NumericValue given a double.
NumericValue(java.lang.Double doubleValue)
          Constructs a NumericValue given a Double.
NumericValue(int value)
          Construct a NumericValue given an int.
NumericValue(java.lang.Integer intValue)
          Constructs a NumericValue given an Integer.
 
Method Summary
static NumericValue add(NumericValue a, NumericValue b)
          Adds two NumericValues and returns the value as a NumericValue.
 int compareTo(java.lang.Object o)
           
static NumericValue divide(NumericValue a, NumericValue b)
          Divides two NumericValues and returns the value as a NumericValue.
 boolean equals(java.lang.Object o)
          Determines if two NumericValues are equal which occurs if they have the exact same value, but do not need to have the same type.
 java.lang.Double getDouble()
          Gives the double representation of this NumericValue.
 java.lang.Integer getInteger()
          Gives the integer representation of this NumericValue.
 int getType()
          Gives the type of this NumericValue.
 java.lang.Number getValue()
          Returns the value of this NumericValue as a Number instance.
static NumericValue multiply(NumericValue a, NumericValue b)
          Multiplies tow NumericValues and returns the value as a NumericValue.
static NumericValue subtract(NumericValue a, NumericValue b)
          Subtracts two NumericValues and returns the value as a NumericValue.
 java.lang.String toString()
          Gives the value as a string.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values
Constructor Detail

NumericValue

public NumericValue(java.lang.Integer intValue)
Constructs a NumericValue given an Integer.

Parameters:
intValue - the value of this NumericValue.

NumericValue

public NumericValue(java.lang.Double doubleValue)
Constructs a NumericValue given a Double.

Parameters:
doubleValue - the value of this NumericValue.

NumericValue

public NumericValue(double value)
Construct a NumericValue given a double.

Parameters:
value - the value of this NumericValue.

NumericValue

public NumericValue(int value)
Construct a NumericValue given an int.

Parameters:
value - the value of this NumericValue.
Method Detail

getType

public int getType()
Gives the type of this NumericValue.

Returns:

getInteger

public java.lang.Integer getInteger()
Gives the integer representation of this NumericValue.

Returns:

getDouble

public java.lang.Double getDouble()
Gives the double representation of this NumericValue.

Returns:

getValue

public java.lang.Number getValue()
Returns the value of this NumericValue as a Number instance.

Returns:

toString

public java.lang.String toString()
Gives the value as a string.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Determines if two NumericValues are equal which occurs if they have the exact same value, but do not need to have the same type.

Overrides:
equals in class java.lang.Object

add

public static NumericValue add(NumericValue a,
                               NumericValue b)
Adds two NumericValues and returns the value as a NumericValue.

Parameters:
a - NumericValue to be added to.
b - NumericValue to add.
Returns:
the result of the addition.

subtract

public static NumericValue subtract(NumericValue a,
                                    NumericValue b)
Subtracts two NumericValues and returns the value as a NumericValue.

Parameters:
a - NumericValue to subtract from.
b - NumericValue to subtract.
Returns:
the result of the subtraction.

divide

public static NumericValue divide(NumericValue a,
                                  NumericValue b)
Divides two NumericValues and returns the value as a NumericValue.

Parameters:
a - NumericValue to divide.
b - NumericValue to divide by.
Returns:
the result of the division.

multiply

public static NumericValue multiply(NumericValue a,
                                    NumericValue b)
Multiplies tow NumericValues and returns the value as a NumericValue.

Parameters:
a - NumericValue to multiply.
b - NumericValue to multiply by.
Returns:

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable