public class IdToFileMap
extends java.lang.Object
This is essentially a thin wrapper around a supplied getter and putter method; in the PuffinPlot Swing application, these are supplied by a java.util.prefs.Preferences object, and the IdToFileMap is used to keep track of the last-used directory for various Open File dialogs.
Constructor and Description |
---|
IdToFileMap(java.util.function.UnaryOperator<java.lang.String> getter,
java.util.function.BiConsumer<java.lang.String,java.lang.String> putter)
Creates a new IdToFileMap, which wwill store and retrieve mappings
using the supplied getter and putter.
|
Modifier and Type | Method and Description |
---|---|
java.io.File |
get(java.lang.String identifier)
Return the directory associated with an identifier.
|
java.lang.String |
getString(java.lang.String identifier)
Return the directory associated with an identifier, as a string.
|
void |
put(java.lang.String identifier,
java.io.File directory)
Set the directory associated with an identifier.
|
public IdToFileMap(java.util.function.UnaryOperator<java.lang.String> getter, java.util.function.BiConsumer<java.lang.String,java.lang.String> putter)
getter
- a getter method which returns a value for a provided
key. For a non-existent key, it should return an empty string.putter
- a fuction which takes a key and a value, and stores
the value under the given key.public java.io.File get(java.lang.String identifier)
identifier
- an identifierpublic java.lang.String getString(java.lang.String identifier)
identifier
- an identifierpublic void put(java.lang.String identifier, java.io.File directory)
identifier
- an identifier (non-null)directory
- the associated directory (non-null)