jess
Class Token

java.lang.Object
  |
  +--jess.Token

public class Token
extends java.lang.Object
implements java.io.Serializable

A Token is the fundamental unit of communication in the Rete network. Each Token represents one or more facts and an indication of whether those facts are being asserted or being retracted.

Only Accelerator implementors will use this class.

(C) 1997 Ernest J. Friedman-Hill and Sandia National Laboratories

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

Method Summary
 boolean dataEquals(Token t)
          Compare the data in this token to another token.
 boolean equals(java.lang.Object o)
          Compare this token to another object.
 Fact fact(int i)
          Return a fact from this token
 int hashCode()
          Use the sortcode, based on the contained facts, as the hashcode.
 int size()
          Returns the number of facts in this token
 Fact topFact()
          Return the last fact in the Token (the "most recent" one.)
 java.lang.String toString()
          Return a string (useful for debugging) describing this token.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

topFact

public final Fact topFact()
Return the last fact in the Token (the "most recent" one.)
Returns:
The fact

fact

public final Fact fact(int i)
Return a fact from this token
Parameters:
i - The index (0-based) of the fact to retrieve. More recent (later) facts have larger indexes.
Returns:
The fact

size

public final int size()
Returns the number of facts in this token
Returns:
The size

dataEquals

public final boolean dataEquals(Token t)
Compare the data in this token to another token. The tokens are assumed to be of the same size (same number of facts). We also assume (new assumption!) that we can compare facts by id. This, I think, has been a valid assumption for some time, but we haven't been taking advantage of it.
Parameters:
t - Another token to compare to
Returns:
True if the tokens represent the same list of facts (tags are irrelevant)

equals

public boolean equals(java.lang.Object o)
Compare this token to another object.
Parameters:
o - Another object to compare to
Returns:
True if the object is a Token and dataEquals returns true.
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Return a string (useful for debugging) describing this token.
Returns:
The formatted String
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Use the sortcode, based on the contained facts, as the hashcode.
Returns:
A semi-unique identifier
Overrides:
hashCode in class java.lang.Object

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