jess
Class Variable

java.lang.Object
  |
  +--jess.Value
        |
        +--jess.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) 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.
 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, 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 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.)
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

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
Following copied from class: jess.Value
Returns:
The external address object
Throws:
JessException - If this value does not contain an 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
Following copied from class: jess.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
Following copied from class: jess.Value
Returns:
The list
Throws:
JessException - If this value does not contain a list

intValue

public final int intValue(Context c)
                   throws JessException
Resolves the variable, then returns the value as an int
Overrides:
intValue in class Value
Following copied from class: jess.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
Following copied from class: jess.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
Following copied from class: jess.Value
Returns:
The number as a double
Throws:
JessException - If this value does not contain any kind of number

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
Following copied from class: jess.Value
Returns:
The atom
Throws:
JessException - If this value does not contain any kind of String

variableValue

public final java.lang.String variableValue(Context c)
                                     throws JessException
Returns the name of this variable
Overrides:
variableValue in class Value
Following copied from class: jess.Value
Returns:
The name of the variable
Throws:
JessException - If this value does not contain a 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
Following copied from class: jess.Value
Returns:
The string
Throws:
JessException - If this value does not contain any kind of String

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