JACK 5.4 Application Interface

aos.jack.util.cursor
Class ArrayCursor

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

public class ArrayCursor
extends Cursor

ArrayCursor is a class that can be used to bind logical variables to the values of an array.


Field Summary
 
Fields inherited from class aos.jack.jak.cursor.Cursor
FALSE, falseCursor, TRUE, trueCursor, UNKNOWN
 
Constructor Summary
ArrayCursor(java.lang.Object[] a, Variable v)
          Constructs an ArrayCursor with the given array and Variable
ArrayCursor(java.lang.Object[] a, Variable v, int s, int e)
          Constructs an ArrayCursor with the given array and Variable, and a subarray to iterate through.
 
Method Summary
 void finished()
          This informs the cursor that it is not going to be used again.
 boolean isTriggered()
          Returns false.
 Cursor negate()
          This is called to negate the value of the cursor.
 boolean next()
          Binds the Variable to the next value in the array (or subarray)
 void register(java.util.Observer o)
           
 Cursor reset(aos.jack.jak.core.Generator g, int index)
          Resets the cursor.
 void undo()
          Undo tells the cursor to backtrack anything it has done.
 boolean unRegister(java.util.Observer o)
           
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayCursor

public ArrayCursor(java.lang.Object[] a,
                   Variable v)
Constructs an ArrayCursor with the given array and Variable

Parameters:
a - The array to iterate through.
v - A Variable to bind to the values of the array.

ArrayCursor

public ArrayCursor(java.lang.Object[] a,
                   Variable v,
                   int s,
                   int e)
Constructs an ArrayCursor with the given array and Variable, and a subarray to iterate through.

Parameters:
a - The array to iterate through
v - A logical variable to bind to each element
s - The start of a region to iterate through in the array
e - The end of a region to iterate through in the array
Method Detail

next

public boolean next()
Binds the Variable to the next value in the array (or subarray)

Specified by:
next in class Cursor
Returns:
true while there are more elements to bind to, false otherwise.

reset

public Cursor reset(aos.jack.jak.core.Generator g,
                    int index)
Description copied from class: Cursor
Resets the cursor. This is normally done by either undoing the last action or finishing the current cursor and returning a new one.

Overrides:
reset in class Cursor
Parameters:
g - The generator that generates an equivalent cursor
index - The index of the equivalent cursor in the generator.
Returns:
The reset cursor, or an equivalent one.

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

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 Cursor

isTriggered

public boolean isTriggered()
Returns false.

Overrides:
isTriggered in class Cursor

register

public void register(java.util.Observer o)
Overrides:
register in class Cursor

unRegister

public boolean unRegister(java.util.Observer o)
Overrides:
unRegister in class Cursor

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