de.infinityloop.upcast.upl.val
Class UPLNumeric

java.lang.Object
  extended by de.infinityloop.upcast.upl.val.UPLValue
      extended by de.infinityloop.upcast.upl.val.UPLNumeric

public class UPLNumeric
extends UPLValue


Field Summary
 
Fields inherited from class de.infinityloop.upcast.upl.val.UPLValue
isBreakValue, isEmptyReturnValue, isReturnValue, isValid, kTYPE_BOOL, kTYPE_COLOR, kTYPE_ID, kTYPE_LIST, kTYPE_NULL, kTYPE_NUMERIC, kTYPE_STRING, kTYPE_UNKNOWN, kTYPE_VALUE, kTYPE_VOID, type
 
Constructor Summary
UPLNumeric()
          Constructs a new Numeric.
UPLNumeric(double value)
          Constructs a Numeric with power 0, i.e. it is simply a number.
UPLNumeric(double value, int pow)
          Constructs a new Numeric.
UPLNumeric(java.lang.String inText)
          Constructs a new Numeric.
 
Method Summary
 UPLValue add(UPLValue v)
           
 UPLValue affirmate()
          unary +.
static UPLNumeric castToNumeric(UPLValue from)
           
 int compareTo(int compareType, UPLNumeric to)
           
 int compareTo(int compareType, UPLValue to)
           
 UPLValue decrement()
          unary decrement.
 UPLValue div(UPLValue v)
           
 java.lang.String getAsString()
          Returns a string representation of this Numeric.
 java.lang.String getAsUPL()
           
 boolean getBooleanValue()
          The boolean value of an UPLValue.
 java.lang.String getDebugString()
           
 int getPow()
          Returns the power of the Numeric.
 double getValue()
          Returns the value of the Numeric.
 java.lang.String getValueAsString()
           
 long getValueRounded()
           
 UPLValue increment()
          unary increment.
 UPLValue mod(UPLValue v)
           
 UPLValue negate()
          Calculates the negative of this Numeric.
 void setPow(int i)
          Sets the power of the Numeric.
 void setValue(double d)
          Sets the value of the Numeric.
 void setValue(java.lang.String d)
          Sets the value of the Numeric.
 UPLValue sub(UPLValue v)
           
 UPLValue times(UPLValue v)
           
 
Methods inherited from class de.infinityloop.upcast.upl.val.UPLValue
castValueToType, equals, eval, getType, getType, getTypeName, getTypeName, isBreakValue, isEmptyReturnValue, isReturnValue, isValid, not, setBreakValue, setEmptyReturnValue, setReturnValue, setValid, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UPLNumeric

public UPLNumeric()
Constructs a new Numeric. The value and the power are set to 0.


UPLNumeric

public UPLNumeric(double value)
Constructs a Numeric with power 0, i.e. it is simply a number.

Parameters:
value -

UPLNumeric

public UPLNumeric(double value,
                  int pow)
Constructs a new Numeric.

Parameters:
value - the value of the Numeric
pow - the power of the Numeric

UPLNumeric

public UPLNumeric(java.lang.String inText)
Constructs a new Numeric. The parameter must be a length (e.g. "10mm", "12pt"). The power of this Numeric is 1 (for a length).

Parameters:
inText - the text based on which the value for this Numeric is set
Method Detail

castToNumeric

public static UPLNumeric castToNumeric(UPLValue from)
                                throws UPLValueException
Throws:
UPLValueException

add

public UPLValue add(UPLValue v)
             throws UPLValueException
Overrides:
add in class UPLValue
Throws:
UPLValueException

sub

public UPLValue sub(UPLValue v)
             throws UPLValueException
Overrides:
sub in class UPLValue
Throws:
UPLValueException

times

public UPLValue times(UPLValue v)
               throws UPLValueException
Overrides:
times in class UPLValue
Throws:
UPLValueException

div

public UPLValue div(UPLValue v)
             throws UPLValueException
Overrides:
div in class UPLValue
Throws:
UPLValueException

mod

public UPLValue mod(UPLValue v)
             throws UPLValueException
Overrides:
mod in class UPLValue
Throws:
UPLValueException

compareTo

public int compareTo(int compareType,
                     UPLValue to)
              throws UPLValueException
Specified by:
compareTo in class UPLValue
Throws:
UPLValueException

compareTo

public int compareTo(int compareType,
                     UPLNumeric to)
              throws UPLValueException
Throws:
UPLValueException

getBooleanValue

public boolean getBooleanValue()
Description copied from class: UPLValue
The boolean value of an UPLValue.

Specified by:
getBooleanValue in class UPLValue
Returns:
true if the value is != 0 (independently of the power)
See Also:
UPLValue.getBooleanValue()

affirmate

public UPLValue affirmate()
                   throws UPLValueException
unary +.

Overrides:
affirmate in class UPLValue
Returns:
Throws:
UPLValueException
See Also:
UPLValue.affirmate()

negate

public UPLValue negate()
Calculates the negative of this Numeric.

Overrides:
negate in class UPLValue
Returns:
the negative of this Numeric

increment

public UPLValue increment()
Description copied from class: UPLValue
unary increment.

Overrides:
increment in class UPLValue
Returns:

decrement

public UPLValue decrement()
Description copied from class: UPLValue
unary decrement.

Overrides:
decrement in class UPLValue
Returns:

getPow

public int getPow()
Returns the power of the Numeric.

Returns:
the power of the Numeric

getValue

public double getValue()
Returns the value of the Numeric.

Returns:
the value of the Numeric

getValueRounded

public long getValueRounded()

getValueAsString

public java.lang.String getValueAsString()

setPow

public void setPow(int i)
Sets the power of the Numeric.

Parameters:
i - the power of the Numeric

setValue

public void setValue(double d)
Sets the value of the Numeric.

Parameters:
d - the value of the Numeric

setValue

public void setValue(java.lang.String d)
              throws UPLValueException
Sets the value of the Numeric.

Parameters:
d - the value of the Numeric
Throws:
UPLValueException

getAsString

public java.lang.String getAsString()
Returns a string representation of this Numeric.

Specified by:
getAsString in class UPLValue
Returns:
a string representation of this Numeric

getAsUPL

public java.lang.String getAsUPL()
Specified by:
getAsUPL in class UPLValue

getDebugString

public java.lang.String getDebugString()
Specified by:
getDebugString in class UPLValue