jline.console.history
Class MemoryHistory

java.lang.Object
  extended by jline.console.history.MemoryHistory
All Implemented Interfaces:
Iterable<History.Entry>, History
Direct Known Subclasses:
FileHistory

public class MemoryHistory
extends Object
implements History

Non-persistent History.

Since:
2.3
Author:
Marc Prud'hommeaux, Jason Dillon

Nested Class Summary
 
Nested classes/interfaces inherited from interface jline.console.history.History
History.Entry
 
Field Summary
static int DEFAULT_MAX_SIZE
           
 
Constructor Summary
MemoryHistory()
           
 
Method Summary
 void add(CharSequence item)
           
 void clear()
           
 CharSequence current()
          Return the content of the current buffer.
 ListIterator<History.Entry> entries()
           
 ListIterator<History.Entry> entries(int index)
           
 CharSequence get(int index)
           
 int getMaxSize()
           
 int index()
           
protected  void internalAdd(CharSequence item)
           
 boolean isAutoTrim()
           
 boolean isEmpty()
           
 boolean isIgnoreDuplicates()
           
 Iterator<History.Entry> iterator()
           
 boolean moveTo(int index)
          Move to the specified index in the history
 void moveToEnd()
          Move to the end of the history buffer.
 boolean moveToFirst()
          Moves the history index to the first entry.
 boolean moveToLast()
          This moves the history to the last entry.
 boolean next()
          Move the pointer to the next element in the buffer.
 boolean previous()
          Move the pointer to the previous element in the buffer.
 CharSequence remove(int i)
          Remove the history element at the given index.
 CharSequence removeFirst()
          Remove the first element from history.
 CharSequence removeLast()
          Remove the last element from history
 void replace(CharSequence item)
           
 void set(int index, CharSequence item)
          Set the history item at the given index to the given CharSequence.
 void setAutoTrim(boolean flag)
           
 void setIgnoreDuplicates(boolean flag)
           
 void setMaxSize(int maxSize)
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_SIZE

public static final int DEFAULT_MAX_SIZE
See Also:
Constant Field Values
Constructor Detail

MemoryHistory

public MemoryHistory()
Method Detail

setMaxSize

public void setMaxSize(int maxSize)

getMaxSize

public int getMaxSize()

isIgnoreDuplicates

public boolean isIgnoreDuplicates()

setIgnoreDuplicates

public void setIgnoreDuplicates(boolean flag)

isAutoTrim

public boolean isAutoTrim()

setAutoTrim

public void setAutoTrim(boolean flag)

size

public int size()
Specified by:
size in interface History

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface History

index

public int index()
Specified by:
index in interface History

clear

public void clear()
Specified by:
clear in interface History

get

public CharSequence get(int index)
Specified by:
get in interface History

set

public void set(int index,
                CharSequence item)
Description copied from interface: History
Set the history item at the given index to the given CharSequence.

Specified by:
set in interface History
Parameters:
index - the index of the history offset
item - the new item

add

public void add(CharSequence item)
Specified by:
add in interface History

remove

public CharSequence remove(int i)
Description copied from interface: History
Remove the history element at the given index.

Specified by:
remove in interface History
Parameters:
i - the index of the element to remove
Returns:
the removed element

removeFirst

public CharSequence removeFirst()
Description copied from interface: History
Remove the first element from history.

Specified by:
removeFirst in interface History
Returns:
the removed element

removeLast

public CharSequence removeLast()
Description copied from interface: History
Remove the last element from history

Specified by:
removeLast in interface History
Returns:
the removed element

internalAdd

protected void internalAdd(CharSequence item)

replace

public void replace(CharSequence item)
Specified by:
replace in interface History

entries

public ListIterator<History.Entry> entries(int index)
Specified by:
entries in interface History

entries

public ListIterator<History.Entry> entries()
Specified by:
entries in interface History

iterator

public Iterator<History.Entry> iterator()
Specified by:
iterator in interface Iterable<History.Entry>
Specified by:
iterator in interface History

moveToLast

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

Specified by:
moveToLast in interface History
Returns:
Returns false if there were no history entries or the history index was already at the last entry.

moveTo

public boolean moveTo(int index)
Move to the specified index in the history

Specified by:
moveTo in interface History
Parameters:
index -
Returns:

moveToFirst

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

Specified by:
moveToFirst in interface History
Returns:
Return false if there are no entries in the history or if the history is already at the beginning.

moveToEnd

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

Specified by:
moveToEnd in interface History

current

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

Specified by:
current in interface History

previous

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

Specified by:
previous in interface History
Returns:
true if we successfully went to the previous element

next

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

Specified by:
next in interface History
Returns:
true if we successfully went to the next element

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.