rcm.util
Class History

java.lang.Object
  |
  +--rcm.util.History

public class History
extends java.lang.Object


Field Summary
protected  int curr
           
static Debug debug
           
protected  int end
           
protected  java.lang.Object[] history
           
protected  int start
           
 
Constructor Summary
History(History h)
          Make a duplicate of another History.
History(int max)
          Make a History.
 
Method Summary
 void add(java.lang.Object obj)
          Add an object to the end of the history, moving the current point to it.
 java.lang.Object back()
          Move back one object in the history, if possible.
 java.util.Enumeration backElements()
          Get the objects BEFORE the current object.
 boolean canBack()
          Test whether back() will succeed.
 boolean canForward()
          Test whether forward() will succeed.
 void clear()
          Clear the history.
 boolean contains(java.lang.Object obj)
          Test whether history already contains an object.
 java.util.Enumeration elements()
          Get the objects in the history.
 void expand()
          Double the capacity of the history.
protected  void fireAdded(int i, int j)
           
protected  void fireChanged(int i, int j)
           
protected  void fireRemoved(int i, int j)
           
 java.lang.Object forward()
          Move forward one object in the history, if possible.
 java.util.Enumeration forwardElements()
          Get the objects AFTER the current object.
 java.lang.Object get()
          Get the current object of the history.
 boolean isEmpty()
          Test whether history is empty.
 boolean isFull()
          Test whether history is full.
 java.lang.Object peekBack()
          Get the object that would be returned by back(), without actually changing the current object.
 java.lang.Object peekForward()
          Get the object that would be returned by forward(), without actually changing the current object.
 void put(java.lang.Object obj)
          Add an object to the history after the current point (deleting all objects forward of this point).
 void replace(java.lang.Object obj)
          Replace the current object of the history.
 java.lang.Object toEnd()
          Move to last (newest) object in the history, if possible.
 java.lang.Object toStart()
          Move to first (oldest) object in the history, if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static Debug debug

history

protected java.lang.Object[] history

start

protected int start

end

protected int end

curr

protected int curr
Constructor Detail

History

public History(int max)
Make a History.

Parameters:
max - Maximum length of history

History

public History(History h)
Make a duplicate of another History.

Parameters:
h - History to copy
Method Detail

clear

public void clear()
Clear the history.


expand

public void expand()
Double the capacity of the history.


put

public void put(java.lang.Object obj)
Add an object to the history after the current point (deleting all objects forward of this point). If history overflows, the oldest object is thrown away.

Parameters:
obj - Object to add to history

add

public void add(java.lang.Object obj)
Add an object to the end of the history, moving the current point to it. If history overflows, the oldest object is thrown away.

Parameters:
obj - Object to add to history

get

public java.lang.Object get()
Get the current object of the history.

Returns:
current object of history, or null if history is empty.

peekBack

public java.lang.Object peekBack()
Get the object that would be returned by back(), without actually changing the current object.

Returns:
object before current object, or null if at beginning of history or history is empty.

peekForward

public java.lang.Object peekForward()
Get the object that would be returned by forward(), without actually changing the current object.

Returns:
object after current object, or null if at end of history or history is empty.

replace

public void replace(java.lang.Object obj)
Replace the current object of the history. The rest of the history is unaffected, and the current pointer stays where it is.

If the history is empty, then this call is equivalent to put(obj).

Parameters:
obj - object to substitute

back

public java.lang.Object back()
Move back one object in the history, if possible.

Returns:
previous object in the history, or null if at start.

forward

public java.lang.Object forward()
Move forward one object in the history, if possible.

Returns:
next object in the history, or null if at end of history.

toStart

public java.lang.Object toStart()
Move to first (oldest) object in the history, if possible.

Returns:
first object in the history, or null if history empty.

toEnd

public java.lang.Object toEnd()
Move to last (newest) object in the history, if possible.

Returns:
last object in the history, or null if history empty.

canBack

public boolean canBack()
Test whether back() will succeed.

Returns:
true if and only if there are objects before the current object

canForward

public boolean canForward()
Test whether forward() will succeed.

Returns:
true if and only if there are objects after the current object

isEmpty

public boolean isEmpty()
Test whether history is empty.

Returns:
true if and only if history contains no objects

isFull

public boolean isFull()
Test whether history is full.

Returns:
true if and only if history contains max objects

contains

public boolean contains(java.lang.Object obj)
Test whether history already contains an object.

Parameters:
obj - Object to search for
Returns:
true if and only if history contains an object that equals() obj

elements

public java.util.Enumeration elements()
Get the objects in the history.


forwardElements

public java.util.Enumeration forwardElements()
Get the objects AFTER the current object.


backElements

public java.util.Enumeration backElements()
Get the objects BEFORE the current object.


fireRemoved

protected void fireRemoved(int i,
                           int j)

fireAdded

protected void fireAdded(int i,
                         int j)

fireChanged

protected void fireChanged(int i,
                           int j)