edu.iu.cnets.klatsch.lang
Class Value

java.lang.Object
  extended by edu.iu.cnets.klatsch.lang.Value
Direct Known Subclasses:
VBoolean, VClosure, VDictionary, VEdge, VEvent, VFeed, VGraph, VList, VNode, VNull, VNumber, VPane, VPrimitive, VProperty, VQueue, VStack, VStream, VString

public abstract class Value
extends java.lang.Object

This is the base class of all values, which are generated by the evaluation of Expression objects.


Constructor Summary
Value()
           
 
Method Summary
(package private) static void require(boolean test)
          Takes a test that we need to be true of an argument and ensures that it is.
static void requireCount(Value[] args, int minCount, int maxCount)
          Requires the given array of arguments to have between minCount and maxCount elements.
 Value requireType(java.lang.Class<?>... type)
          Requires this value to be a member of one of the given subclasses.
 java.lang.String toJson()
          Returns a JSON representation of this value.
abstract  java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Value

public Value()
Method Detail

toString

public abstract java.lang.String toString()
Overrides:
toString in class java.lang.Object

require

static void require(boolean test)
             throws EvaluationException
Takes a test that we need to be true of an argument and ensures that it is.

Parameters:
test - the results of the test
Throws:
EvaluationException - if the test failed

requireCount

public static void requireCount(Value[] args,
                                int minCount,
                                int maxCount)
                         throws EvaluationException
Requires the given array of arguments to have between minCount and maxCount elements. This is a convenience method for method and primitive definitions.

Parameters:
args - the array of arguments
minCount - the minimum number of arguments
maxCount - the maximum number of arguments
Throws:
EvaluationException - if the count is bad

requireType

public Value requireType(java.lang.Class<?>... type)
                  throws EvaluationException
Requires this value to be a member of one of the given subclasses. We return ourselves to support call chaining.

Parameters:
type - the classes we must be a member of
Returns:
this
Throws:
EvaluationException - if the types don't match

toJson

public java.lang.String toJson()
Returns a JSON representation of this value. Not all values will have a useful JSON representation (especially streams and closures), so we include a non-useful representation here as the default behavior.

Returns:
the JSON representation