|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.extension.gui.dock.preference.PreferenceStorage
public class PreferenceStorage
A preference storage is a container storing the values of artificial preferences of one or more PreferenceModel
s.
Clients can use store(PreferenceModel)
to transfer values from model to storage, or
load(PreferenceModel, boolean)
to transfer values from storage to model. Further mode the entire storage
can be persistently written to a file using one of the write-methods
. It can later be loaded
using one of the read-methods
.
The static read-methods
and the static write-methods
can be used to write and read the contents of a PreferenceModel
directly.
Constructor Summary | |
---|---|
PreferenceStorage()
Creates a new preference storage with some default factories set. |
Method Summary | |
---|---|
void |
addFactory(Path type,
PreferenceFactory<?> factory)
Adds a new factory to this storage, the factory will be responsible to write or read some kind of preferences. |
void |
clear()
Removes all preferences from this storage |
void |
load(PreferenceModel model,
boolean missingToNull)
Gets through all the preferences of model and changes
their values according to the values stored in this storage. |
void |
read(DataInputStream in)
Reads the contents of this storage from a stream. |
static void |
read(PreferenceModel model,
DataInputStream in)
Reads preferences from in and transfers them into model . |
static void |
readXML(PreferenceModel model,
XElement element)
Reads some preferences from element and stores them in
model . |
void |
readXML(XElement element)
Reads the contents of this storage from element . |
void |
store(PreferenceModel model)
Stores all the preferences of model in this storage. |
void |
write(DataOutputStream out)
Writes all values currently stored in this storage to out . |
static void |
write(PreferenceModel model,
DataOutputStream out)
Writes the current preferences of model into out . |
static void |
writeXML(PreferenceModel model,
XElement element)
Writes the preferences of model into element . |
void |
writeXML(XElement element)
Writes the contents of this storage into element , adds
new elements to element but does
not change the attributes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PreferenceStorage()
Method Detail |
---|
public static void write(PreferenceModel model, DataOutputStream out) throws IOException
model
into out
.
model
- the model to storeout
- the stream to write into
IOException
- if the stream is not writeablepublic static void read(PreferenceModel model, DataInputStream in) throws IOException
in
and transfers them into model
.
Missing preferences will be replaced by null
.
model
- the model to write into.in
- the stream to read from
IOException
- if the stream cannot be readpublic static void writeXML(PreferenceModel model, XElement element)
model
into element
. This
method will add new children to element
but not change
its attributes.
model
- the model to storeelement
- the element to write intopublic static void readXML(PreferenceModel model, XElement element)
element
and stores them in
model
.
model
- the model to write intoelement
- the element to read
XException
- if element
is incorrectpublic void addFactory(Path type, PreferenceFactory<?> factory)
type
, then the old factory will be replaced by
factory
type
- the type of values factory
handles, this path
is most times just the name of some class. Node: there is a set of
standard paths defined in Path
factory
- the new factorypublic void store(PreferenceModel model)
model
in this storage. This
storage uses the paths
of the
preferences to store each value individually. If there is already a value
for some path, then that value gets replaced.
model
- the model to read outpublic void load(PreferenceModel model, boolean missingToNull)
model
and changes
their values according to the values stored in this storage.
missingToNull
- whether missing values should be set to null
. If
not set, then missing values remain just unchanged.model
- the model to write intopublic void write(DataOutputStream out) throws IOException
out
.
out
- the stream to write into
IOException
- if the stream is not writable or if there is a
factory missing for some typepublic void read(DataInputStream in) throws IOException
in
- the stream to read from
IOException
- if in
can't be readpublic void writeXML(XElement element)
element
, adds
new elements
to element
but does
not change the attributes. If a factory for some element is missing,
then this element will not be stored.
element
- the element to write intopublic void readXML(XElement element)
element
. Note that this
method does not clear the storage, if there are values in this storage that are not
in element
, then these values remain. If there is a
PreferenceFactory
missing for some type, then this value will silently
be left out.
element
- the element to read from
XException
- if element
is not correctpublic void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |