jess
Class BindingValue

java.lang.Object
  extended by jess.Value
      extended by jess.BindingValue
All Implemented Interfaces:
java.io.Serializable

public class BindingValue
extends Value
implements java.io.Serializable

A class to represent a location within a rule LHS, used internally. It is 'self-resolving' using Context. You shouldn't need to use this directly except to implement an Accelerator.

(C) 2007 Sandia National Laboratories

See Also:
Serialized Form

Method Summary
 boolean equals(Value o)
          This overrides the overloaded equals() in Value.
 Fact factValue(Context c)
          Returns the contents of this value, as a fact.
 double floatValue(Context c)
          Returns the contents of this value, as a double.
 int getFactNumber()
          Returns the fact index within a Rete Token.
 java.lang.String getName()
          Returns the name of the variable.
 int getSlotIndex()
          Returns the slot index within a fact.
 int getSubIndex()
          Returns the index within a multifield.
 int getType()
          Returns the type of the binding.
 int hashCode()
          Return a hashcode for the object.
 int intValue(Context c)
          Returns the contents of this value, as an int.
 java.lang.Object javaObjectValue(Context c)
          Returns the contents of this value, as a Java object.
 ValueVector listValue(Context c)
          Returns the contents of this value, as a list.
 double numericValue(Context c)
          Returns the contents of this value, as a number.
 void resetFactNumber()
          Sets the fact number associated with this binding to 0.
 Value resolveValue(Context c)
          Returns the value of the bound variable by extracting it from a Token stored in the execution context.
 java.lang.String stringValue(Context c)
          Returns the contents of this value, as a String.
 java.lang.String symbolValue(Context c)
          Returns the contents of this value, as a symbol.
 java.lang.String toString()
          Return a pretty-print version of this value, without adding parens to any lists.
 java.lang.String variableValue(Context c)
          Returns the contents of this value, as a String (a variable name).
 
Methods inherited from class jess.Value
atomValue, equals, equalsStar, externalAddressValue, funcallValue, functionValue, isLexeme, isLiteral, isNumeric, isVariable, longValue, toStringWithParens, type
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

resetFactNumber

public void resetFactNumber()
Sets the fact number associated with this binding to 0.


getName

public java.lang.String getName()
Returns the name of the variable.

Returns:
the variable name

getFactNumber

public int getFactNumber()
Returns the fact index within a Rete Token.

Returns:
the fact index

getSlotIndex

public int getSlotIndex()
Returns the slot index within a fact.

Returns:
the slot index

getSubIndex

public int getSubIndex()
Returns the index within a multifield.

Returns:
the subindex, or -1 if none

getType

public int getType()
Returns the type of the binding.

Returns:
the binding type

resolveValue

public Value resolveValue(Context c)
                   throws JessException
Returns the value of the bound variable by extracting it from a Token stored in the execution context.

Overrides:
resolveValue in class Value
Parameters:
c - an execution context containing a token
Returns:
the value of the variable
Throws:
JessException - if anything goes wrong
See Also:
Variable, Funcall

javaObjectValue

public final java.lang.Object javaObjectValue(Context c)
                                       throws JessException
Description copied from class: Value
Returns the contents of this value, as a 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
Description copied from class: Value
Returns the contents of this 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
Description copied from class: Value
Returns the contents of this 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 this value does not contain a list

intValue

public final int intValue(Context c)
                   throws JessException
Description copied from class: Value
Returns the contents of this 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
Description copied from class: Value
Returns the contents of this value, as a double.

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
Description copied from class: Value
Returns the contents of this value, as a number.

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
Description copied from class: Value
Returns the contents of this 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)
Description copied from class: Value
Returns the contents of this value, as a String (a variable name).

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
Description copied from class: Value
Returns the contents of this 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.

toString

public java.lang.String toString()
Description copied from class: Value
Return a pretty-print version of this value, without adding parens to any lists.

Overrides:
toString in class Value
Returns:
the formatted string

hashCode

public int hashCode()
Description copied from class: Value
Return a hashcode for the object.

Overrides:
hashCode in class Value
Returns:
the hashcode

equals

public boolean equals(Value o)
This overrides the overloaded equals() in Value.

Overrides:
equals in class Value
Parameters:
o - a Value to compare to
Returns:
true if the two Values are equal

© 2013 Sandia Corporation