edu.iu.cnets.klatsch.misc
Class History

java.lang.Object
  extended by edu.iu.cnets.klatsch.misc.History

public class History
extends java.lang.Object

This class encapsulates the idea of a history of previous lines of input, which is useful to both the line editor and the GUI.


Field Summary
(package private)  int current
          the current pointer within the history
static int DEFAULT_SIZE
          the default history size
(package private)  java.util.List<java.lang.String> ls
          the previous lines of input
(package private)  int maxLines
          the maximum number of lines to retain
 
Constructor Summary
History()
          Initialize a new history of the default size.
History(int size)
          Initialize a new history of the given size.
 
Method Summary
 void add(java.lang.String line)
          Adds a new line to the history.
 java.lang.String get()
          Gets the current line in the history.
 void next()
          Moves the current pointer to the next position.
 void prev()
          Moves the current pointer to the previous position.
 void reset()
          Resets the position of the current pointer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

public static final int DEFAULT_SIZE
the default history size

See Also:
Constant Field Values

ls

java.util.List<java.lang.String> ls
the previous lines of input


maxLines

int maxLines
the maximum number of lines to retain


current

int current
the current pointer within the history

Constructor Detail

History

public History()
Initialize a new history of the default size.


History

public History(int size)
Initialize a new history of the given size.

Method Detail

add

public void add(java.lang.String line)
Adds a new line to the history.

Parameters:
line - the line to add

get

public java.lang.String get()
Gets the current line in the history.

Returns:
the line currently pointed to

next

public void next()
Moves the current pointer to the next position.


prev

public void prev()
Moves the current pointer to the previous position.


reset

public void reset()
Resets the position of the current pointer.