History using a file for persistent backing.
Implementers should install shutdown hook to call DefaultHistory#save
to save history to disk.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | |
| public static final int | |
| private Map | |
| private int | |
| private final LinkedList | |
| private int | |
| private LineReader |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| protected void | |
| protected void | |
| public void | append(Path file, boolean incremental)
Implements jdk. Append history to the file. |
| public void | attach(LineReader reader)
Implements jdk. Initialize the history for the given reader. |
| protected DefaultHistory. | Returns: entry objectindex of history entry index, Instant entry creation time time, String the entry text line)Create a history entry. |
| public String | current()
Implements jdk. Return the content of the current buffer. |
| private String | |
| pack-priv static List | |
| private static String | |
| public int | |
| private String | |
| public String | |
| private int | |
| private DefaultHistory. | |
| private int | |
| private Path | |
| private void | |
| public int | |
| protected void | |
| protected void | |
| private void | |
| private void | |
| public boolean | |
| private boolean | |
| public ListIterator | |
| public int | |
| public void | |
| protected boolean | |
| private void | |
| public boolean | moveTo(int index)
Implements jdk. Move to the specified index in the history |
| public void | moveToEnd()
Implements jdk. Move to the end of the history buffer. |
| public boolean | Returns: Return false if there are no iterator in the history or if the history is already at the beginning.Implements jdk. Moves the history index to the first entry. |
| public boolean | Returns: Returns false if there were no history iterator or the history index was already at the last entry.Implements jdk. This moves the history to the last entry. |
| public boolean | Returns: true if we successfully went to the next elementImplements jdk. Move the pointer to the next element in the buffer. |
| public boolean | Returns: true if we successfully went to the previous elementImplements jdk. Move the pointer to the previous element in the buffer. |
| public void | |
| public void | read(Path file, boolean checkDuplicates)
Implements jdk. Read history from the file. |
| public void | |
| public void | |
| private void | |
| private void | |
| private void | |
| public int | |
| public Spliterator | spliterator()
Overrides default java. Creates a |
| public String | |
| protected void | |
| pack-priv static String | |
| public void | write(Path file, boolean incremental)
Implements jdk. Write history to the file. |
| DEFAULT_HISTORY_FILE_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_HISTORY_FILE_SIZE | |
| DEFAULT_HISTORY_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_HISTORY_SIZE | |
| historyFiles | back to summary |
|---|---|
| private Map<String, DefaultHistory. | |
| index | back to summary |
|---|---|
| private int index | |
| items | back to summary |
|---|---|
| private final LinkedList<History. | |
| offset | back to summary |
|---|---|
| private int offset | |
| reader | back to summary |
|---|---|
| private LineReader reader | |
| DefaultHistory | back to summary |
|---|---|
| public DefaultHistory() | |
| DefaultHistory | back to summary |
|---|---|
public DefaultHistory(LineReader reader)
| |
| add | back to summary |
|---|---|
| public void add(Instant time, String line) Implements jdk.
| |
| addHistoryLine | back to summary |
|---|---|
| protected void addHistoryLine(Path path, String line) | |
| addHistoryLine | back to summary |
|---|---|
| protected void addHistoryLine(Path path, String line, boolean checkDuplicates) | |
| append | back to summary |
|---|---|
| public void append(Path file, boolean incremental) throws IOException Implements jdk. Doc from jdk. Append history to the file. If incremental only the events that are new since the last incremental operation to the file are added.
| |
| attach | back to summary |
|---|---|
| public void attach(LineReader reader) Implements jdk. Doc from jdk. Initialize the history for the given reader.
| |
| createEntry | back to summary |
|---|---|
| protected DefaultHistory. Create a history entry. Subclasses may override to use their own entry implementations.
| |
| current | back to summary |
|---|---|
| public String current() Implements jdk. Return the content of the current buffer. | |
| doHistoryFileDataKey | back to summary |
|---|---|
| private String doHistoryFileDataKey(Path path) | |
| doTrimHistory | back to summary |
|---|---|
| pack-priv static List | |
| escape | back to summary |
|---|---|
| private static String escape(String s) | |
| first | back to summary |
|---|---|
| public int first() Implements jdk. | |
| format | back to summary |
|---|---|
| private String format(History. | |
| get | back to summary |
|---|---|
| public String get(final int index) Implements jdk. | |
| getEntriesInFile | back to summary |
|---|---|
| private int getEntriesInFile(Path path) | |
| getHistoryFileData | back to summary |
|---|---|
| private DefaultHistory. | |
| getLastLoaded | back to summary |
|---|---|
| private int getLastLoaded(Path path) | |
| getPath | back to summary |
|---|---|
| private Path getPath() | |
| incEntriesInFile | back to summary |
|---|---|
| private void incEntriesInFile(Path path, int amount) | |
| index | back to summary |
|---|---|
| public int index() Implements jdk. | |
| internalAdd | back to summary |
|---|---|
| protected void internalAdd(Instant time, String line) | |
| internalAdd | back to summary |
|---|---|
| protected void internalAdd(Instant time, String line, boolean checkDuplicates) | |
| internalClear | back to summary |
|---|---|
| private void internalClear() | |
| internalWrite | back to summary |
|---|---|
| private void internalWrite(Path path, int from) throws IOException | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides default jdk. | |
| isLineReaderHistory | back to summary |
|---|---|
| private boolean isLineReaderHistory(Path path) throws IOException | |
| iterator | back to summary |
|---|---|
| public ListIterator Implements jdk. | |
| last | back to summary |
|---|---|
| public int last() Implements jdk. | |
| load | back to summary |
|---|---|
| public void load() throws IOException Implements jdk. Doc from jdk. Load history.
| |
| matchPatterns | back to summary |
|---|---|
| protected boolean matchPatterns(String patterns, String line) | |
| maybeResize | back to summary |
|---|---|
| private void maybeResize() | |
| moveTo | back to summary |
|---|---|
| public boolean moveTo(int index) Implements jdk. Move to the specified index in the history | |
| moveToEnd | back to summary |
|---|---|
| public void moveToEnd() Implements jdk. Move to the end of the history buffer. This will be a blank entry, after all of the other iterator. | |
| moveToFirst | back to summary |
|---|---|
| public boolean moveToFirst() Implements jdk. Moves the history index to the first entry.
| |
| moveToLast | back to summary |
|---|---|
| public boolean moveToLast() Implements jdk. This moves the history to the last entry. This entry is one position before the moveToEnd() position.
| |
| next | back to summary |
|---|---|
| public boolean next() Implements jdk. Move the pointer to the next element in the buffer.
| |
| previous | back to summary |
|---|---|
| public boolean previous() Implements jdk. Move the pointer to the previous element in the buffer.
| |
| purge | back to summary |
|---|---|
| public void purge() throws IOException Implements jdk. Doc from jdk. Purge history.
| |
| read | back to summary |
|---|---|
| public void read(Path file, boolean checkDuplicates) throws IOException Implements jdk. Doc from jdk. Read history from the file. If checkDuplicates is
| |
| resetIndex | back to summary |
|---|---|
| public void resetIndex() Implements jdk. Doc from jdk. Reset index after remove | |
| save | back to summary |
|---|---|
| public void save() throws IOException Implements jdk. Doc from jdk. Save history.
| |
| setEntriesInFile | back to summary |
|---|---|
| private void setEntriesInFile(Path path, int entriesInFile) | |
| setHistoryFileData | back to summary |
|---|---|
| private void setHistoryFileData(Path path, DefaultHistory. | |
| setLastLoaded | back to summary |
|---|---|
| private void setLastLoaded(Path path, int lastloaded) | |
| size | back to summary |
|---|---|
| public int size() Implements jdk. | |
| spliterator | back to summary |
|---|---|
| public Spliterator Overrides default java. Doc from java. Creates a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| trimHistory | back to summary |
|---|---|
| protected void trimHistory(Path path, int max) throws IOException | |
| unescape | back to summary |
|---|---|
| pack-priv static String unescape(String s) | |
| write | back to summary |
|---|---|
| public void write(Path file, boolean incremental) throws IOException Implements jdk. Doc from jdk. Write history to the file. If incremental only the events that are new since the last incremental operation to the file are added.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final String | |
| private final Instant |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public String | |
| public Instant | |
| public String |
| index | back to summary |
|---|---|
| private final int index | |
| line | back to summary |
|---|---|
| private final String line | |
| time | back to summary |
|---|---|
| private final Instant time | |
| EntryImpl | back to summary |
|---|---|
| public EntryImpl(int index, Instant time, String line) | |
| index | back to summary |
|---|---|
| public int index() Implements jdk. | |
| line | back to summary |
|---|---|
| public String line() Implements jdk. | |
| time | back to summary |
|---|---|
| public Instant time() Implements jdk. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public int | |
| public int | |
| public void | |
| public void | |
| public void |
| entriesInFile | back to summary |
|---|---|
| private int entriesInFile | |
| lastLoaded | back to summary |
|---|---|
| private int lastLoaded | |
| HistoryFileData | back to summary |
|---|---|
| public HistoryFileData() | |
| HistoryFileData | back to summary |
|---|---|
| public HistoryFileData(int lastLoaded, int entriesInFile) | |
| decLastLoaded | back to summary |
|---|---|
| public void decLastLoaded() | |
| getEntriesInFile | back to summary |
|---|---|
| public int getEntriesInFile() | |
| getLastLoaded | back to summary |
|---|---|
| public int getLastLoaded() | |
| incEntriesInFile | back to summary |
|---|---|
| public void incEntriesInFile(int amount) | |
| setEntriesInFile | back to summary |
|---|---|
| public void setEntriesInFile(int entriesInFile) | |
| setLastLoaded | back to summary |
|---|---|
| public void setLastLoaded(int lastLoaded) | |