Package org.jline.reader.impl.history
Class DefaultHistory
java.lang.Object
org.jline.reader.impl.history.DefaultHistory
- All Implemented Interfaces:
Iterable<History.Entry>
,History
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jline.reader.History
History.Entry
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
addHistoryLine
(Path path, String line) protected void
addHistoryLine
(Path path, String line, boolean checkDuplicates) void
Append history to the file.void
attach
(LineReader reader) Initialize the history for the given reader.protected DefaultHistory.EntryImpl
createEntry
(int index, Instant time, String line) Create a history entry.current()
Return the content of the current buffer.int
first()
get
(int index) int
index()
protected void
internalAdd
(Instant time, String line) protected void
internalAdd
(Instant time, String line, boolean checkDuplicates) boolean
isEmpty()
iterator
(int index) int
last()
void
load()
Load history.protected boolean
matchPatterns
(String patterns, String line) 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.void
purge()
Purge history.void
Read history from the file.void
Reset index after removevoid
save()
Save history.int
size()
toString()
protected void
trimHistory
(Path path, int max) void
Write history to the file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jline.reader.History
add, isPersistable, iterator, reverseIterator, reverseIterator
-
Field Details
-
DEFAULT_HISTORY_SIZE
public static final int DEFAULT_HISTORY_SIZE- See Also:
-
DEFAULT_HISTORY_FILE_SIZE
public static final int DEFAULT_HISTORY_FILE_SIZE- See Also:
-
-
Constructor Details
-
DefaultHistory
public DefaultHistory() -
DefaultHistory
-
-
Method Details
-
attach
Description copied from interface:History
Initialize the history for the given reader. -
load
Description copied from interface:History
Load history.- Specified by:
load
in interfaceHistory
- Throws:
IOException
- if a problem occurs
-
read
Description copied from interface:History
Read history from the file. If checkDuplicates istrue
only the events that are not contained within the internal list are added.- Specified by:
read
in interfaceHistory
- Parameters:
file
- History filecheckDuplicates
- Iftrue
, duplicate history entries will be discarded- Throws:
IOException
- if a problem occurs
-
addHistoryLine
-
addHistoryLine
-
purge
Description copied from interface:History
Purge history.- Specified by:
purge
in interfaceHistory
- Throws:
IOException
- if a problem occurs
-
write
Description copied from interface:History
Write history to the file. If incremental only the events that are new since the last incremental operation to the file are added.- Specified by:
write
in interfaceHistory
- Parameters:
file
- History fileincremental
- If true incremental write operation is performed.- Throws:
IOException
- if a problem occurs
-
append
Description copied from interface:History
Append history to the file. If incremental only the events that are new since the last incremental operation to the file are added.- Specified by:
append
in interfaceHistory
- Parameters:
file
- History fileincremental
- If true incremental append operation is performed.- Throws:
IOException
- if a problem occurs
-
save
Description copied from interface:History
Save history.- Specified by:
save
in interfaceHistory
- Throws:
IOException
- if a problem occurs
-
trimHistory
- Throws:
IOException
-
createEntry
Create a history entry. Subclasses may override to use their own entry implementations.- Parameters:
index
- index of history entrytime
- entry creation timeline
- the entry text- Returns:
- entry object
-
size
public int size() -
isEmpty
public boolean isEmpty() -
index
public int index() -
first
public int first() -
last
public int last() -
get
-
add
-
matchPatterns
-
internalAdd
-
internalAdd
-
iterator
-
spliterator
- Specified by:
spliterator
in interfaceIterable<History.Entry>
-
resetIndex
public void resetIndex()Description copied from interface:History
Reset index after remove- Specified by:
resetIndex
in interfaceHistory
-
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 iterator 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 iterator 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 iterator. -
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
-