edu.iu.cnets.klatsch.lang
Class VNumber

java.lang.Object
  extended by edu.iu.cnets.klatsch.lang.Value
      extended by edu.iu.cnets.klatsch.lang.VNumber

public class VNumber
extends Value

Both numeric and floating-point values are subsumed into this class.


Field Summary
 double val
          the value actually being stored
 
Constructor Summary
VNumber(double val)
          Initialize a new numeric value.
VNumber(java.lang.Double val)
          Initialize a new numeric value.
VNumber(int val)
          Initialize a new numeric value.
VNumber(java.lang.Integer val)
          Initialize a new numeric value.
 
Method Summary
 Value method_str(Value... args)
          n.str() : Convert the number to a string.
 VNumber requireRange(double min, double max)
          Require this number be in a particular range to avoid causing an error.
 java.lang.String toJson()
          Create a JSON represention of this number.
 java.lang.String toString()
          Convert this number to a string representation.
 
Methods inherited from class edu.iu.cnets.klatsch.lang.Value
require, requireCount, requireType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

val

public final double val
the value actually being stored

Constructor Detail

VNumber

public VNumber(double val)
Initialize a new numeric value.

Parameters:
val - the number

VNumber

public VNumber(java.lang.Double val)
Initialize a new numeric value.

Parameters:
val - the number

VNumber

public VNumber(int val)
Initialize a new numeric value.

Parameters:
val - the number

VNumber

public VNumber(java.lang.Integer val)
Initialize a new numeric value.

Parameters:
val - the number
Method Detail

requireRange

public VNumber requireRange(double min,
                            double max)
                     throws EvaluationException
Require this number be in a particular range to avoid causing an error. We return ourselves to permit chaining calls.

Parameters:
min - the minimum permissible value
max - the maximum permissible value
Returns:
this
Throws:
EvaluationException - if the value is out of range

toString

public java.lang.String toString()
Convert this number to a string representation.

Specified by:
toString in class Value
Returns:
the string

toJson

public java.lang.String toJson()
Create a JSON represention of this number.

Overrides:
toJson in class Value
Returns:
the JSON representation

method_str

public Value method_str(Value... args)
                 throws EvaluationException
n.str() : Convert the number to a string.

Throws:
EvaluationException