jess
Class Variable

java.lang.Object
  extended byjess.Value
      extended byjess.Variable
All Implemented Interfaces:
java.io.Serializable

public class Variable
extends Value
implements java.io.Serializable

A class to represent a Jess variable. It is 'self-resolving' using Context.

(C) 2005 Sandia National Laboratories

See Also:
Serialized Form

Constructor Summary
Variable(java.lang.String name, int type)
          Create a Variable.
 
Method Summary
 Fact factValue(Context c)
          Resolves the variable, then returns the value as a Fact
 double floatValue(Context c)
          Resolves the variable, then returns the value as a float
 int intValue(Context c)
          Resolves the variable, then returns the value as an int
 java.lang.Object javaObjectValue(Context c)
          Resolves the variable, then returns the value as an Java object.
 ValueVector listValue(Context c)
          Resolves the variable, then returns the value as a list
 double numericValue(Context c)
          Resolves the variable, then returns the value as a float
 Value resolveValue(Context c)
          Will resolve the variable (return the value it represents.)
 java.lang.String stringValue(Context c)
          Resolves the variable, then returns the value as a string
 java.lang.String symbolValue(Context c)
          Resolves the variable, then returns the value as a symbol
 java.lang.String variableValue(Context c)
          Returns the name of this variable
 
Methods inherited from class jess.Value
atomValue, equals, equals, equalsStar, externalAddressValue, funcallValue, functionValue, hashCode, isLexeme, isNumeric, longValue, toString, toStringWithParens, type
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

public Variable(java.lang.String name,
                int type)
         throws JessException
Create a Variable.

Parameters:
name - the name of the variable
type - RU.VARIABLE or RU.MULTIVARIABLE
Throws:
JessException - if the type is invalid
Method Detail

resolveValue

public Value resolveValue(Context c)
                   throws JessException
Will resolve the variable (return the value it represents.)

Overrides:
resolveValue in class Value
Parameters:
c - an evaluation context. Cannot be null!
Returns:
the value of this variable
Throws:
JessException - if the variable is undefined.
See Also:
Variable, Funcall

javaObjectValue

public final java.lang.Object javaObjectValue(Context c)
                                       throws JessException
Resolves the variable, then returns the value as an Java object.

Overrides:
javaObjectValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the Java object
Throws:
JessException - if this value does not contain a Java object

factValue

public final Fact factValue(Context c)
                     throws JessException
Resolves the variable, then returns the value as a Fact

Overrides:
factValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the fact
Throws:
JessException - if this value does not contain a fact

listValue

public final ValueVector listValue(Context c)
                            throws JessException
Resolves the variable, then returns the value as a list

Overrides:
listValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the list
Throws:
JessException - if something goes wrong during value resolution

intValue

public final int intValue(Context c)
                   throws JessException
Resolves the variable, then returns the value as an int

Overrides:
intValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the number as an int
Throws:
JessException - if this value does not contain any kind of number

floatValue

public final double floatValue(Context c)
                        throws JessException
Resolves the variable, then returns the value as a float

Overrides:
floatValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the number as a double
Throws:
JessException - if this value does not contain any kind of number.

numericValue

public final double numericValue(Context c)
                          throws JessException
Resolves the variable, then returns the value as a float

Overrides:
numericValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the number as a double
Throws:
JessException - if this value does not contain any kind of number

symbolValue

public final java.lang.String symbolValue(Context c)
                                   throws JessException
Resolves the variable, then returns the value as a symbol

Overrides:
symbolValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the symbol
Throws:
JessException - if this value does not contain any kind of String

variableValue

public final java.lang.String variableValue(Context c)
Returns the name of this variable

Overrides:
variableValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the name of the variable

stringValue

public final java.lang.String stringValue(Context c)
                                   throws JessException
Resolves the variable, then returns the value as a string

Overrides:
stringValue in class Value
Parameters:
c - the execution context used to resolve the value
Returns:
the string
Throws:
JessException - if this value does not contain any kind of String.

© 2006 Sandia Corporation