jline

Class History

public class History extends Object

A command history buffer.

Author: Marc Prud'hommeaux

Constructor Summary
History()
Construstor: initialize a blank history.
History(File historyFile)
Construstor: initialize History object the the specified File for storage.
Method Summary
voidaddToHistory(String buffer)
Add the specified buffer to the end of the history.
voidclear()
Clear the history buffer
Stringcurrent()
Return the content of the current buffer.
voidflushBuffer()
Flush the entire history buffer to the output PrintWriter.
intgetCurrentIndex()
Returns the current history index.
ListgetHistoryList()
Returns an immutable list of the history buffer.
intgetMaxSize()
Get the maximum size that the history buffer will store.
PrintWritergetOutput()
Returns the PrintWriter that is used to store history elements.
voidload(InputStream in)
Load the history buffer from the specified InputStream.
voidload(Reader reader)
Load the history buffer from the specified Reader.
voidmoveToEnd()
Move to the end of the history buffer.
booleanmoveToFirstEntry()
Moves the history index to the first entry.
booleanmoveToLastEntry()
This moves the history to the last entry.
booleannext()
Move the pointer to the next element in the buffer.
booleanprevious()
Move the pointer to the previous element in the buffer.
voidsetHistoryFile(File historyFile)
voidsetMaxSize(int maxSize)
Set the maximum size that the history buffer will store.
voidsetOutput(PrintWriter output)
The output to which all history elements will be written (or null of history is not saved to a buffer).
intsize()
StringtoString()
Returns the standard AbstractCollection#toString representation of the history list.

Constructor Detail

History

public History()
Construstor: initialize a blank history.

History

public History(File historyFile)
Construstor: initialize History object the the specified File for storage.

Method Detail

addToHistory

public void addToHistory(String buffer)
Add the specified buffer to the end of the history. The pointer is set to the end of the history buffer.

clear

public void clear()
Clear the history buffer

current

public String current()
Return the content of the current buffer.

flushBuffer

public void flushBuffer()
Flush the entire history buffer to the output PrintWriter.

getCurrentIndex

public int getCurrentIndex()
Returns the current history index.

getHistoryList

public List getHistoryList()
Returns an immutable list of the history buffer.

getMaxSize

public int getMaxSize()
Get the maximum size that the history buffer will store.

getOutput

public PrintWriter getOutput()
Returns the PrintWriter that is used to store history elements.

load

public void load(InputStream in)
Load the history buffer from the specified InputStream.

load

public void load(Reader reader)
Load the history buffer from the specified Reader.

moveToEnd

public void moveToEnd()
Move to the end of the history buffer. This will be a blank entry, after all of the other entries.

moveToFirstEntry

public boolean moveToFirstEntry()
Moves the history index to the first entry.

Returns: Return false if there are no entries in the history or if the history is already at the beginning.

moveToLastEntry

public boolean moveToLastEntry()
This moves the history to the last entry. This entry is one position before the moveToEnd() position.

Returns: Returns false if there were no history entries or the history index was already at the last entry.

next

public boolean next()
Move the pointer to the next element in the buffer.

Returns: true if we successfully went to the next element

previous

public boolean previous()
Move the pointer to the previous element in the buffer.

Returns: true if we successfully went to the previous element

setHistoryFile

public void setHistoryFile(File historyFile)

setMaxSize

public void setMaxSize(int maxSize)
Set the maximum size that the history buffer will store.

setOutput

public void setOutput(PrintWriter output)
The output to which all history elements will be written (or null of history is not saved to a buffer).

size

public int size()

toString

public String toString()
Returns the standard AbstractCollection#toString representation of the history list.
Copyright © 2002-2010 null. All Rights Reserved.