Project JXTA

net.jxta.impl.shell.bin.history
Class HistoryQueue

java.lang.Object
  |
  +--net.jxta.impl.shell.bin.history.HistoryQueue

public class HistoryQueue
extends java.lang.Object


Field Summary
protected static int MAX_HISTORY
          The maximum number of commands
 
Constructor Summary
HistoryQueue()
          Create a new history queue
HistoryQueue(java.lang.String[] exclude)
          Create a new history queue
 
Method Summary
 void addCommand(java.lang.String cmd)
          Adds a new command to the queue.
If the queue has already reached MAX_HISTORY, the element at index 0 is discarded.
 java.lang.String getCommand(int index)
          Gets the command at index, if there is an element at index.
 java.lang.String getNextCommand()
          Returns the command immediately preceeding the previous command
 java.lang.String getPreviousCommand()
          Returns the command immediately succedding the previous command THIS needs help !!
 java.lang.String printHistory()
          Prints the available commands to a String.
 void removeLastCommand()
          Removes the last command added to the queue
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_HISTORY

protected static final int MAX_HISTORY
The maximum number of commands
Constructor Detail

HistoryQueue

public HistoryQueue()
Create a new history queue

HistoryQueue

public HistoryQueue(java.lang.String[] exclude)
Create a new history queue
Parameters:
exclude - the commands to not add to the queue (that are the usually Cursor up and down events )
Method Detail

addCommand

public void addCommand(java.lang.String cmd)
Adds a new command to the queue.
If the queue has already reached MAX_HISTORY, the element at index 0 is discarded.
Parameters:
cmd - the command to add

removeLastCommand

public void removeLastCommand()
Removes the last command added to the queue

getNextCommand

public java.lang.String getNextCommand()
Returns the command immediately preceeding the previous command

getPreviousCommand

public java.lang.String getPreviousCommand()
Returns the command immediately succedding the previous command THIS needs help !!

getCommand

public java.lang.String getCommand(int index)
Gets the command at index, if there is an element at index. Otherwise, an empty string is returned
Returns:
the command at index, if there is an element at index or an empty string, if index is out of range

printHistory

public java.lang.String printHistory()
Prints the available commands to a String. If no commands are available, we return and empty string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Project JXTA