jline.console.history
Class FileHistory

java.lang.Object
  extended by jline.console.history.MemoryHistory
      extended by jline.console.history.FileHistory
All Implemented Interfaces:
java.io.Flushable, java.lang.Iterable<History.Entry>, History, PersistentHistory

public class FileHistory
extends MemoryHistory
implements PersistentHistory, java.io.Flushable

History using a file for persistent backing.

Implementers should install shutdown hook to call flush() to save history to disk.

Since:
2.0
Author:
Jason Dillon

Nested Class Summary
 
Nested classes/interfaces inherited from interface jline.console.history.History
History.Entry
 
Field Summary
 
Fields inherited from class jline.console.history.MemoryHistory
DEFAULT_MAX_SIZE
 
Constructor Summary
FileHistory(java.io.File file)
           
 
Method Summary
 void flush()
          Flush all items to persistent storage.
 java.io.File getFile()
           
 void load(java.io.File file)
           
 void load(java.io.InputStream input)
           
 void load(java.io.Reader reader)
           
 void purge()
          Purge persistent storage and History.clear().
 
Methods inherited from class jline.console.history.MemoryHistory
add, clear, current, entries, entries, get, getMaxSize, index, isAutoTrim, isEmpty, isIgnoreDuplicates, iterator, moveTo, moveToEnd, moveToFirst, moveToLast, next, previous, replace, setAutoTrim, setIgnoreDuplicates, setMaxSize, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jline.console.history.History
add, clear, current, entries, entries, get, index, isEmpty, iterator, moveTo, moveToEnd, moveToFirst, moveToLast, next, previous, replace, size
 

Constructor Detail

FileHistory

public FileHistory(java.io.File file)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getFile

public java.io.File getFile()

load

public void load(java.io.File file)
          throws java.io.IOException
Throws:
java.io.IOException

load

public void load(java.io.InputStream input)
          throws java.io.IOException
Throws:
java.io.IOException

load

public void load(java.io.Reader reader)
          throws java.io.IOException
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from interface: PersistentHistory
Flush all items to persistent storage.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in interface PersistentHistory
Throws:
java.io.IOException - Flush failed

purge

public void purge()
           throws java.io.IOException
Description copied from interface: PersistentHistory
Purge persistent storage and History.clear().

Specified by:
purge in interface PersistentHistory
Throws:
java.io.IOException - Purge failed


Copyright © 2008-2011 Sonatype. All Rights Reserved.