|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlapisx.util.History
A History is a list of objects with a current object. One application of History is a browser history, in which the objects are web pages and one page is currently displayed.
A History has a finite maximum size. When adding an object would exceed
the maximum size, the oldest object is removed. The maximum size can
be increased with expand()
.
Field Summary | |
protected int |
curr
Index of current object. |
protected int |
end
Index after newest object in history. |
protected Object[] |
history
Array of history objects, arranged as circular queue. |
protected int |
start
Index of oldest object in history. |
Constructor Summary | |
History(History h)
Make a duplicate of another History. |
|
History(int max)
Make a History. |
Method Summary | |
void |
add(Object obj)
Add an object to the end of the history, moving the current point to it. |
Object |
back()
Move back one object in the history, if possible. |
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(Object obj)
Test whether history already contains an object. |
Enumeration |
elements()
Get the objects in the history. |
void |
expand()
Double the capacity of the history. |
protected void |
fireAdded(int i,
int j)
Called when new elements are added at history[i..j]. |
protected void |
fireChanged(int i,
int j)
Called when elements at history[i..j] are replaced. |
protected void |
fireRemoved(int i,
int j)
Called when history[i..j] is removed. |
Object |
forward()
Move forward one object in the history, if possible. |
Enumeration |
forwardElements()
Get the objects AFTER the current object. |
Object |
get()
Get the current object of the history. |
boolean |
isEmpty()
Test whether history is empty. |
boolean |
isFull()
Test whether history is full. |
void |
jumpTo(Object obj)
Set the current object of the history. |
Object |
peekBack()
Get the object that would be returned by back(), without actually changing the current object. |
Object |
peekForward()
Get the object that would be returned by forward(), without actually changing the current object. |
void |
put(Object obj)
Add an object to the history after the current point (deleting all objects forward of this point). |
void |
replace(Object obj)
Replace the current object of the history. |
int |
size()
Get number of objects currently in history. |
Object |
toEnd()
Move to last (newest) object in the history, if possible. |
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 |
protected Object[] history
protected int start
protected int end
protected int curr
Constructor Detail |
public History(int max)
max
- Maximum length of historypublic History(History h)
h
- History to copyMethod Detail |
public void clear()
public void expand()
public void put(Object obj)
obj
- Object to add to historypublic void add(Object obj)
obj
- Object to add to historypublic Object get()
public void jumpTo(Object obj)
obj
- Object that should be the new current object.
NoSuchElementException
- if this doesn't contain obj.public Object peekBack()
public Object peekForward()
public void replace(Object obj)
If the history is empty, then this call is equivalent to put(obj).
obj
- object to substitutepublic Object back()
public Object forward()
public Object toStart()
public Object toEnd()
public boolean canBack()
public boolean canForward()
public int size()
public boolean isEmpty()
public boolean isFull()
public boolean contains(Object obj)
obj
- Object to search for
public Enumeration elements()
public Enumeration forwardElements()
public Enumeration backElements()
protected void fireRemoved(int i, int j)
i
- index of first removed elementj
- index of last removed elementprotected void fireAdded(int i, int j)
i
- index of first added elementj
- index of last added elementprotected void fireChanged(int i, int j)
i
- index of first changed elementj
- index of last changed element
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |