-
- All Superinterfaces:
Iterable<History.Entry>
- All Known Implementing Classes:
DefaultHistory
public interface History extends Iterable<History.Entry>
Console history.- Since:
- 2.3
- Author:
- Marc Prud'hommeaux, Jason Dillon
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceHistory.Entry
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidadd(String line)voidadd(Instant time, String line)voidappend(Path file, boolean incremental)Append history to the file.voidattach(LineReader reader)Initialize the history for the given reader.Stringcurrent()Return the content of the current buffer.intfirst()Stringget(int index)intindex()default booleanisEmpty()default booleanisPersistable(History.Entry entry)Check if an entry should be persisted or not.default ListIterator<History.Entry>iterator()ListIterator<History.Entry>iterator(int index)intlast()voidload()Load history.booleanmoveTo(int index)Move to the specified index in the historyvoidmoveToEnd()Move to the end of the history buffer.booleanmoveToFirst()Moves the history index to the first entry.booleanmoveToLast()This 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(Path file, boolean checkDuplicates)Read history from the file.voidresetIndex()Reset index after removedefault Iterator<History.Entry>reverseIterator()default Iterator<History.Entry>reverseIterator(int index)voidsave()Save history.intsize()voidwrite(Path file, boolean incremental)Write history to the file.-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
attach
void attach(LineReader reader)
Initialize the history for the given reader.- Parameters:
reader- the reader to attach to
-
load
void load() throws IOException
Load history.- Throws:
IOException- if a problem occurs
-
save
void save() throws IOException
Save history.- Throws:
IOException- if a problem occurs
-
write
void write(Path file, boolean incremental) throws IOException
Write history to the file. If incremental only the events that are new since the last incremental operation to the file are added.- Parameters:
file- History fileincremental- If true incremental write operation is performed.- Throws:
IOException- if a problem occurs
-
append
void append(Path file, boolean incremental) throws IOException
Append history to the file. If incremental only the events that are new since the last incremental operation to the file are added.- Parameters:
file- History fileincremental- If true incremental append operation is performed.- Throws:
IOException- if a problem occurs
-
read
void read(Path file, boolean checkDuplicates) throws IOException
Read history from the file. If checkDuplicates istrueonly the events that are not contained within the internal list are added.- Parameters:
file- History filecheckDuplicates- Iftrue, duplicate history entries will be discarded- Throws:
IOException- if a problem occurs
-
purge
void purge() throws IOExceptionPurge history.- Throws:
IOException- if a problem occurs
-
size
int size()
-
isEmpty
default boolean isEmpty()
-
index
int index()
-
first
int first()
-
last
int last()
-
get
String get(int index)
-
add
default void add(String line)
-
isPersistable
default boolean isPersistable(History.Entry entry)
Check if an entry should be persisted or not.- Parameters:
entry- the entry to check- Returns:
trueif the given entry should be persisted,falseotherwise
-
iterator
ListIterator<History.Entry> iterator(int index)
-
iterator
default ListIterator<History.Entry> iterator()
- Specified by:
iteratorin interfaceIterable<History.Entry>
-
reverseIterator
default Iterator<History.Entry> reverseIterator()
-
reverseIterator
default Iterator<History.Entry> reverseIterator(int index)
-
current
String current()
Return the content of the current buffer.- Returns:
- the content of the current buffer
-
previous
boolean previous()
Move the pointer to the previous element in the buffer.- Returns:
- true if we successfully went to the previous element
-
next
boolean next()
Move the pointer to the next element in the buffer.- Returns:
- true if we successfully went to the next element
-
moveToFirst
boolean moveToFirst()
Moves the history index to the first entry.- Returns:
- Return false if there are no iterator in the history or if the history is already at the beginning.
-
moveToLast
boolean moveToLast()
This moves the history to the last entry. This entry is one position before the moveToEnd() position.- Returns:
- Returns false if there were no history iterator or the history index was already at the last entry.
-
moveTo
boolean moveTo(int index)
Move to the specified index in the history- Parameters:
index- The index to move to.- Returns:
- Returns true if the index was moved.
-
moveToEnd
void moveToEnd()
Move to the end of the history buffer. This will be a blank entry, after all of the other iterator.
-
resetIndex
void resetIndex()
Reset index after remove
-
-