Package jline.console.history
Class MemoryHistory
- java.lang.Object
-
- jline.console.history.MemoryHistory
-
- All Implemented Interfaces:
java.lang.Iterable<History.Entry>
,History
- Direct Known Subclasses:
FileHistory
public class MemoryHistory extends java.lang.Object implements History
Non-persistentHistory
.- 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
Fields Modifier and Type Field Description static int
DEFAULT_MAX_SIZE
-
Constructor Summary
Constructors Constructor Description MemoryHistory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.CharSequence item)
void
clear()
java.lang.CharSequence
current()
Return the content of the current buffer.java.util.ListIterator<History.Entry>
entries()
java.util.ListIterator<History.Entry>
entries(int index)
java.lang.CharSequence
get(int index)
int
getMaxSize()
int
index()
protected void
internalAdd(java.lang.CharSequence item)
boolean
isAutoTrim()
boolean
isEmpty()
boolean
isIgnoreDuplicates()
java.util.Iterator<History.Entry>
iterator()
boolean
moveTo(int index)
Move to the specified index in the historyvoid
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.java.lang.CharSequence
remove(int i)
Remove the history element at the given index.java.lang.CharSequence
removeFirst()
Remove the first element from history.java.lang.CharSequence
removeLast()
Remove the last element from historyvoid
replace(java.lang.CharSequence item)
void
set(int index, java.lang.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()
java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT_MAX_SIZE
public static final int DEFAULT_MAX_SIZE
- See Also:
- Constant Field Values
-
-
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)
-
set
public void set(int index, java.lang.CharSequence item)
Description copied from interface:History
Set the history item at the given index to the given CharSequence.
-
remove
public java.lang.CharSequence remove(int i)
Description copied from interface:History
Remove the history element at the given index.
-
removeFirst
public java.lang.CharSequence removeFirst()
Description copied from interface:History
Remove the first element from history.- Specified by:
removeFirst
in interfaceHistory
- Returns:
- the removed element
-
removeLast
public java.lang.CharSequence removeLast()
Description copied from interface:History
Remove the last element from history- Specified by:
removeLast
in interfaceHistory
- Returns:
- the removed element
-
internalAdd
protected void internalAdd(java.lang.CharSequence item)
-
replace
public void replace(java.lang.CharSequence item)
-
entries
public java.util.ListIterator<History.Entry> entries(int index)
-
entries
public java.util.ListIterator<History.Entry> entries()
-
iterator
public java.util.Iterator<History.Entry> iterator()
- Specified by:
iterator
in interfaceHistory
- Specified by:
iterator
in interfacejava.lang.Iterable<History.Entry>
-
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 interfaceHistory
- 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
-
moveToFirst
public boolean moveToFirst()
Moves the history index to the first entry.- Specified by:
moveToFirst
in interfaceHistory
- 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.
-
current
public java.lang.CharSequence current()
Return the content of the current buffer.
-
previous
public boolean previous()
Move the pointer to the previous element in the buffer.
-
next
public boolean next()
Move the pointer to the next element in the buffer.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-