jess
Class Variable

java.lang.Object
  |
  +--jess.Value
        |
        +--jess.Variable

public class Variable
extends Value
implements java.io.Serializable

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

(C) 1998 E.J. Friedman-Hill and the Sandia Corporation

Author:
Ernest J. Friedman-Hill
See Also:
Serialized Form

Constructor Summary
Variable(java.lang.String name, int type)
          Create a Variable
 
Method Summary
 java.lang.String atomValue(Context c)
          Resolves the variable, then returns the value as an atom
 java.lang.Object externalAddressValue(Context c)
          Resolves the variable, then returns the value as an external address.
 int factIDValue(Context c)
          Resolves the variable, then returns the value as a fact-ID
 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
 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 variableValue(Context c)
          Returns the name of this variable
 
Methods inherited from class jess.Value
equals, equals, equalsStar, funcallValue, hashCode, intArrayValue, 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 nameof 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.)
Parameters:
c - An evaluation context. Cannot be null!
Returns:
The value of this variable
Throws:
JessException - If the variable is undefined
Overrides:
resolveValue in class Value

externalAddressValue

public final java.lang.Object externalAddressValue(Context c)
                                            throws JessException
Resolves the variable, then returns the value as an external address.
Overrides:
externalAddressValue in class Value

factValue

public final Fact factValue(Context c)
                     throws JessException
Resolves the variable, then returns the value as a Fact
Overrides:
factValue in class Value

listValue

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

intValue

public final int intValue(Context c)
                   throws JessException
Resolves the variable, then returns the value as an int
Overrides:
intValue in class Value

floatValue

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

numericValue

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

atomValue

public final java.lang.String atomValue(Context c)
                                 throws JessException
Resolves the variable, then returns the value as an atom
Overrides:
atomValue in class Value

variableValue

public final java.lang.String variableValue(Context c)
                                     throws JessException
Returns the name of this variable
Overrides:
variableValue in class Value

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

factIDValue

public final int factIDValue(Context c)
                      throws JessException
Resolves the variable, then returns the value as a fact-ID
Overrides:
factIDValue in class Value

© 1997 E.J. Friedman-Hill and Sandia Corporation