de.matthiasmann.twl.model
Class PersistentMRUListModel<T extends java.io.Serializable>

java.lang.Object
  extended by de.matthiasmann.twl.model.SimpleMRUListModel<T>
      extended by de.matthiasmann.twl.model.PersistentMRUListModel<T>
Type Parameters:
T - the data type stored in this MRU model
All Implemented Interfaces:
ListModel<T>, MRUListModel<T>

public class PersistentMRUListModel<T extends java.io.Serializable>
extends SimpleMRUListModel<T>

A persistent MRU list model. Entries are stored compressed (deflate) using serialization and putByteArray except Strings which use put

See Also:
Deflater, Preferences.putByteArray(java.lang.String, byte[]), Preferences.put(java.lang.String, java.lang.String)

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.model.ListModel
ListModel.ChangeListener
 
Field Summary
 
Fields inherited from class de.matthiasmann.twl.model.SimpleMRUListModel
entries, listeners, maxEntries
 
Constructor Summary
PersistentMRUListModel(int maxEntries, java.lang.Class<T> clazz, java.util.prefs.Preferences prefs, java.lang.String prefKey)
           
 
Method Summary
 void addEntry(T entry)
          Adds an entry to this MRU model.
protected  T deserialize(byte[] data)
           
protected  java.lang.String keyForIndex(int idx)
           
protected  java.lang.String keyForNumEntries()
           
protected  void saveEntries()
           
protected  byte[] serialize(T obj)
           
 
Methods inherited from class de.matthiasmann.twl.model.SimpleMRUListModel
addChangeListener, doDeleteEntry, getEntry, getEntryTooltip, getMaxEntries, getNumEntries, matchPrefix, removeChangeListener, removeEntry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentMRUListModel

public PersistentMRUListModel(int maxEntries,
                              java.lang.Class<T> clazz,
                              java.util.prefs.Preferences prefs,
                              java.lang.String prefKey)
Method Detail

addEntry

public void addEntry(T entry)
Description copied from interface: MRUListModel
Adds an entry to this MRU model. If the entry is already in the MRU list, then it is moved to the from.

Specified by:
addEntry in interface MRUListModel<T extends java.io.Serializable>
Overrides:
addEntry in class SimpleMRUListModel<T extends java.io.Serializable>
Parameters:
entry - the entry
See Also:
Object.equals(java.lang.Object)

saveEntries

protected void saveEntries()
Overrides:
saveEntries in class SimpleMRUListModel<T extends java.io.Serializable>

serialize

protected byte[] serialize(T obj)

deserialize

protected T deserialize(byte[] data)

keyForIndex

protected java.lang.String keyForIndex(int idx)

keyForNumEntries

protected java.lang.String keyForNumEntries()