JACK 5.4 Application Interface

aos.jack.jak.beliefset
Class ClosedWorldCursor

java.lang.Object
  extended byaos.jack.jak.util.Watchable
      extended byaos.jack.jak.cursor.Cursor
          extended byaos.jack.jak.beliefset.BeliefSetCursor
              extended byaos.jack.jak.beliefset.ClosedWorldCursor
All Implemented Interfaces:
ObservableInt

public abstract class ClosedWorldCursor
extends BeliefSetCursor

A Cursor that can be used over a ClosedWorld beliefset. A concrete subclass of this cursor will be automatically generated for beliefsets which extend ClosedWorld.


Field Summary
 
Fields inherited from class aos.jack.jak.cursor.Cursor
FALSE, falseCursor, TRUE, trueCursor, UNKNOWN
 
Constructor Summary
ClosedWorldCursor()
           
 
Method Summary
protected  void finalize()
           
 void finished()
          This informs the cursor that it is not going to be used again.
protected  ClosedWorld getBeliefset()
           
protected  int getIndex()
           
 Tuple getMatched()
          Return the tuple that has been successfully matched at last next(), null otherwise.
 int[] getMatchedContext()
          Return the context information required by restoreNextContext() to repeat the last sucessful match by next(), null if failed.
protected  int getTableLocation()
           
protected  int getTableNumber()
           
 void init(int ind, BeliefSet db)
           
 Cursor negate()
          This is called to negate the value of the cursor.
 boolean next()
          This method is called to provide a next binding by this cursor.
 void removeAll()
          Retracts all tuples subsequently matching the cursor.
 void restoreNextContext(int[] matchparams)
          Restore parameters for next() to match a specific tuple at a certain location.
protected  void setBeliefset(ClosedWorld bs)
           
protected  void setIndex(int i)
           
protected  void setTableLocation(int i)
           
protected  void setTableNumber(int i)
           
 java.lang.String toString()
           
 void undo()
          Undo tells the cursor to backtrack anything it has done.
 
Methods inherited from class aos.jack.jak.beliefset.BeliefSetCursor
getBs, getChoicePoint, hash, isKeyGround, isTriggered, match, register, retractAll, unRegister
 
Methods inherited from class aos.jack.jak.cursor.Cursor
reset
 
Methods inherited from class aos.jack.jak.util.Watchable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClosedWorldCursor

public ClosedWorldCursor()
Method Detail

init

public void init(int ind,
                 BeliefSet db)
Overrides:
init in class BeliefSetCursor

negate

public Cursor negate()
Description copied from class: Cursor
This is called to negate the value of the cursor. By default it simply stores the fact that it has been negated. Some cursors may do more such as create a new cursor for the negated query. After the call the original cursor is lost so unless this call returns the old cursor, it will be discarded.

Overrides:
negate in class Cursor

next

public boolean next()
Description copied from class: Cursor
This method is called to provide a next binding by this cursor. The first call provides the first binding, and successive calls provide successive bindings, until the binding alternatives are exhausted. The method returns true when it provides a binding, and false when it cannot provide a new alternative binding. Expected behaviour is that cursors will return while there are more bindings and from then on false until a call to reset(). This is very important especially when you consider an expression such as:
     db.query($x) && isWhatIWant($x) && db1.query($x, $y)
 
If the isWhatIWant() cursor simply tests its input and returns true for appropriate values then this expression would not work as expected and may go into an infinite loop.
For example if the beliefset had:
                db(1)
                db(2)
                db(3)

                db1(3,3)
 
and isWhatIWant() returned true on odd numbers. Then the correct behaviour would be one result with $x=3 $y=3. However if isWhatIWant.next() always returns true on odd numbers then: $x is bound to 1,
isWhatIWant(1).next() is true
db1(1, $y) fails, backtracks
isWhatIWant(1).next() is true
db1(1, $y) fails, backtracks
etc...

Specified by:
next in class Cursor

toString

public java.lang.String toString()

getMatched

public Tuple getMatched()
Description copied from class: BeliefSetCursor
Return the tuple that has been successfully matched at last next(), null otherwise.

Specified by:
getMatched in class BeliefSetCursor

getMatchedContext

public int[] getMatchedContext()
Description copied from class: BeliefSetCursor
Return the context information required by restoreNextContext() to repeat the last sucessful match by next(), null if failed.

Specified by:
getMatchedContext in class BeliefSetCursor

restoreNextContext

public void restoreNextContext(int[] matchparams)
Restore parameters for next() to match a specific tuple at a certain location. NOTE: WE ARE TRUSTING THE INPUT PARAMETERS! should become an opaque object

Specified by:
restoreNextContext in class BeliefSetCursor

removeAll

public void removeAll()
Retracts all tuples subsequently matching the cursor.

Specified by:
removeAll in class BeliefSetCursor

undo

public void undo()
Description copied from class: Cursor
Undo tells the cursor to backtrack anything it has done. It is a subset of the reset() functionality since it does not reinitialize the cursor. The only requirement is that any bindings made by the cursor are undone. The state of the cursor after the call is undefined. Most implementations will fail if next() is called after undo() without an intervening call to reset().

Overrides:
undo in class Cursor

finished

public void finished()
Description copied from class: Cursor
This informs the cursor that it is not going to be used again. This is typically used to clean up data strutures and to remove itself from any notification paths.

Overrides:
finished in class BeliefSetCursor

finalize

protected void finalize()

setIndex

protected void setIndex(int i)

getIndex

protected int getIndex()

setTableNumber

protected void setTableNumber(int i)

getTableNumber

protected int getTableNumber()

setTableLocation

protected void setTableLocation(int i)

getTableLocation

protected int getTableLocation()

setBeliefset

protected void setBeliefset(ClosedWorld bs)

getBeliefset

protected ClosedWorld getBeliefset()

JACK 5.4 Application Interface

Copyright (C) 1999-2008, Agent Oriented Software Pty. Ltd.

US Government Restricted Rights
The JACK Modules and relevant Software Material have been developed entirely at private expense and are accordingly provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013 or subparagraph (c)(1) and (2) of the Commercial Computer Software Restricted Rights and 48 CFR 52.2270-19, as applicable.


Agent Oriented Software Pty. Ltd.     http://www.aosgrp.com
PO Box 639, Carlton South, Victoria 3053, Australia
Phone: +61 3 9349 5055, Fax: +61 3 9349 5088