Package jline.console.history
Class MemoryHistory
java.lang.Object
jline.console.history.MemoryHistory
- All Implemented Interfaces:
Iterable<History.Entry>
,History
- Direct Known Subclasses:
FileHistory
Non-persistent
History
.- Since:
- 2.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private static class
Nested classes/interfaces inherited from interface jline.console.history.History
History.Entry
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
static final int
private boolean
private int
private final LinkedList<CharSequence>
private int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(CharSequence item) void
clear()
current()
Return the content of the current buffer.entries()
entries
(int index) get
(int index) int
int
index()
protected void
internalAdd
(CharSequence item) boolean
boolean
isEmpty()
boolean
iterator()
private void
boolean
moveTo
(int index) Move to the specified index in the historyvoid
Move to the end of the history buffer.boolean
Moves the history index to the first entry.boolean
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.remove
(int i) Remove the history element at the given index.Remove the first element from history.Remove the last element from historyvoid
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()
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_MAX_SIZE
public static final int DEFAULT_MAX_SIZE- See Also:
-
items
-
maxSize
private int maxSize -
ignoreDuplicates
private boolean ignoreDuplicates -
autoTrim
private boolean autoTrim -
offset
private int offset -
index
private int index
-
-
Constructor Details
-
MemoryHistory
public MemoryHistory()
-
-
Method Details
-
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() -
isEmpty
public boolean isEmpty() -
index
public int index() -
clear
public void clear() -
get
-
set
Description copied from interface:History
Set the history item at the given index to the given CharSequence. -
add
-
remove
Description copied from interface:History
Remove the history element at the given index. -
removeFirst
Description copied from interface:History
Remove the first element from history.- Specified by:
removeFirst
in interfaceHistory
- Returns:
- the removed element
-
removeLast
Description copied from interface:History
Remove the last element from history- Specified by:
removeLast
in interfaceHistory
- Returns:
- the removed element
-
internalAdd
-
replace
-
maybeResize
private void maybeResize() -
entries
-
entries
-
iterator
- Specified by:
iterator
in interfaceHistory
- Specified by:
iterator
in interfaceIterable<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
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
-