java.util.prefs
Class TransientPreferences
java.lang.Object
|
+--java.util.prefs.Preferences
|
+--java.util.prefs.AbstractPreferences
|
+--java.util.prefs.TransientPreferences
- public class TransientPreferences
- extends AbstractPreferences
This specialization of AbstractPreferences provides a means of holding
transient
contextual settings to pass from one program entity to another, such as
between isolates.
There is no connection between transient preferences and the backing store
used by regular
preferences; however, export/import
to and from XML is supported. Export of transient preferences to XML is
via the inherited exportNode
method, but import is via an additional constructor.
Here are some code fragments demonstrating TransientPreferences usage:
// Pass a few context values to a new isolate
TransientPreferences ctx = new TransientPreferences();
ctx.put("workPath", "inventory.update");
ctx.put("workClass", "restock");
Isolate newIsolate = Isolate( ... ctx, ...);
// Merge above preferences with existing one and save it to XML
ctx.merge(existingCtx);
ctx.export(new FileOutputStream("batchupdate_prefs.xml");
// Retrieve preferences from a stream, customize and use
TransientPreferences ictx = new TransientPreferences(new
FileInputStream("some_prefs.xml"));
ictx.remove("historyFlag");
Isolate myIsolate = Isolate( ... ictx, ...);
- Since:
- 1.5
|
Method Summary |
void |
merge(TransientPreferences source)
Merges in a tree of preferences, replacing existing nodes and/or values
with the same name. |
| Methods inherited from class java.util.prefs.AbstractPreferences |
absolutePath, addNodeChangeListener, addPreferenceChangeListener, childrenNames, clear, exportNode, exportSubtree, flush, get, getBoolean, getByteArray, getDouble, getFloat, getInt, getLong, isUserNode, keys, name, node, nodeExists, parent, put, putBoolean, putByteArray, putDouble, putFloat, putInt, putLong, remove, removeNode, removeNodeChangeListener, removePreferenceChangeListener, sync, toString |
TransientPreferences
public TransientPreferences()
- Constructs an empty context.
TransientPreferences
public TransientPreferences(TransientPreferences base)
- Constructs a new context with the same initial contents as given base.
- Parameters:
base - the existing TransientPreferences object to copy
TransientPreferences
public TransientPreferences(InputStream is)
throws IOException,
InvalidPreferencesFormatException
- Constructs a new context from preferences XML form
- Parameters:
is - the input stream from which to read the XML document.
- Throws:
IOException - if reading from the specified output stream
results in an IOException
InvalidPreferencesFormatException - if data on input stream does
not constitute a valid XML document with the mandated document type
merge
public void merge(TransientPreferences source)
- Merges in a tree of preferences, replacing existing nodes and/or values
with the same name.
- Parameters:
source - the preferences object to merge