Package org.jline.reader.impl.history
Class DefaultHistory
java.lang.Object
org.jline.reader.impl.history.DefaultHistory
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.jline.reader.History
History.Entry -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidaddHistoryLine(Path path, String line) protected voidaddHistoryLine(Path path, String line, boolean checkDuplicates) voidAppend history to the file.voidattach(LineReader reader) Initialize the history for the given reader.protected DefaultHistory.EntryImplcreateEntry(int index, Instant time, String line) Create a history entry.current()Return the content of the current buffer.intfirst()get(int index) intindex()protected voidinternalAdd(Instant time, String line) protected voidinternalAdd(Instant time, String line, boolean checkDuplicates) booleanisEmpty()iterator(int index) intlast()voidload()Load history.protected booleanmatchPatterns(String patterns, String line) booleanmoveTo(int index) Move to the specified index in the historyvoidMove to the end of the history buffer.booleanMoves the history index to the first entry.booleanThis 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.voidpurge()Purge history.voidRead history from the file.voidReset index after removevoidsave()Save history.intsize()toString()protected voidtrimHistory(Path path, int max) voidWrite history to the file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:HistoryInitialize the history for the given reader. -
load
Description copied from interface:HistoryLoad history.- Specified by:
loadin interfaceHistory- Throws:
IOException- if a problem occurs
-
read
Description copied from interface:HistoryRead history from the file. If checkDuplicates istrueonly the events that are not contained within the internal list are added.- Specified by:
readin 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:HistoryPurge history.- Specified by:
purgein interfaceHistory- Throws:
IOException- if a problem occurs
-
write
Description copied from interface:HistoryWrite history to the file. If incremental only the events that are new since the last incremental operation to the file are added.- Specified by:
writein interfaceHistory- Parameters:
file- History fileincremental- If true incremental write operation is performed.- Throws:
IOException- if a problem occurs
-
append
Description copied from interface:HistoryAppend history to the file. If incremental only the events that are new since the last incremental operation to the file are added.- Specified by:
appendin interfaceHistory- Parameters:
file- History fileincremental- If true incremental append operation is performed.- Throws:
IOException- if a problem occurs
-
save
Description copied from interface:HistorySave history.- Specified by:
savein 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
-
isEmpty
-
index
-
first
-
last
-
get
-
add
-
matchPatterns
-
internalAdd
-
internalAdd
-
iterator
-
spliterator
- Specified by:
spliteratorin interfaceIterable<History.Entry>
-
resetIndex
public void resetIndex()Description copied from interface:HistoryReset index after remove- Specified by:
resetIndexin interfaceHistory
-
moveToLast
public boolean moveToLast()This moves the history to the last entry. This entry is one position before the moveToEnd() position.- Specified by:
moveToLastin interfaceHistory- Returns:
- Returns false if there were no history iterator or the history index was already at the last entry.
-
moveTo
-
moveToFirst
public boolean moveToFirst()Moves the history index to the first entry.- Specified by:
moveToFirstin interfaceHistory- Returns:
- Return false if there are no iterator in the history or if the history is already at the beginning.
-
moveToEnd
-
current
-
previous
-
next
-
toString
-