com.realtime.crossfire.jxclient.settings
Class CommandHistory

java.lang.Object
  extended by com.realtime.crossfire.jxclient.settings.CommandHistory

public class CommandHistory
extends java.lang.Object

Manages a list of previously entered commands.


Field Summary
private  int commandIndex
          The current command index.
private  java.util.List<java.lang.String> commands
          The commands.
private static int HISTORY_SIZE
          The maximum number of commands to store.
 
Constructor Summary
CommandHistory(java.lang.String ident)
          Creates a new instance.
 
Method Summary
 void addCommand(java.lang.String command)
          Adds a new command.
 java.lang.String down()
          Returns the next command.
private  void removeCommand(java.lang.String command)
          Removes a command.
private  void trimToMaxSize()
          Cut off old entries if more than HISTORY_SIZE commands are present.
 java.lang.String up()
          Returns the previous command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandIndex

private int commandIndex
The current command index.


commands

@NotNull
private final java.util.List<java.lang.String> commands
The commands.


HISTORY_SIZE

private static final int HISTORY_SIZE
The maximum number of commands to store.

See Also:
Constant Field Values
Constructor Detail

CommandHistory

public CommandHistory(@NotNull
                      java.lang.String ident)
Creates a new instance.

Parameters:
ident - the identification string for backing up to file
Method Detail

addCommand

public void addCommand(@NotNull
                       java.lang.String command)
Adds a new command.

Parameters:
command - the command to add

down

@Nullable
public java.lang.String down()
Returns the next command.

Returns:
the next command or null if no previous command exists

removeCommand

private void removeCommand(@NotNull
                           java.lang.String command)
Removes a command.

Parameters:
command - the command to remove

trimToMaxSize

private void trimToMaxSize()
Cut off old entries if more than HISTORY_SIZE commands are present.


up

@Nullable
public java.lang.String up()
Returns the previous command.

Returns:
the previous command or null if no previous command exists