A
- the objects used by ModeManager
to store informationB
- the independent objects used by this ModeSettings
to store informationpublic class ModeSettings<A,B>
extends java.lang.Object
ModeManager
and its Mode
s. The properties
can be stored persistently and do not depend on any existing object (like for example the Mode
s).Constructor and Description |
---|
ModeSettings(ModeSettingsConverter<A,B> converter)
Creates a new setting
|
Modifier and Type | Method and Description |
---|---|
void |
add(Mode<A> mode)
Adds the settings of
mode to this. |
void |
add(ModeSetting<A> mode)
Adds the settings
mode to this. |
void |
add(java.lang.String id,
Path current,
java.util.Map<Path,A> properties,
java.util.Collection<Path> history)
Adds a new set of properties to this setting.
|
void |
addFactory(ModeSettingFactory<A> factory)
Adds a factory to this setting.
|
ModeSettingsConverter<A,B> |
getConverter()
Gets the converter that is used to transform internal and external
properties.
|
Path |
getCurrent(int index)
Gets the current mode of the index'th set.
|
Path[] |
getHistory(int index)
Gets the history of the index'th set.
|
java.lang.String |
getId(int index)
Gets the unique id of the index'th set.
|
java.util.Map<Path,A> |
getProperties(int index)
Gets the converted properties of the index'th set.
|
ModeSetting<A> |
getSettings(Path modeId)
Gets the settings which belong to a
Mode with unique
identifier modeId . |
int |
indexOf(java.lang.String id)
Gets the index of the entry with identifier
id . |
void |
read(java.io.DataInputStream in)
Clears all properties of this setting and then reads new properties
from
in . |
void |
readXML(XElement element)
Clears all properties of this setting and then reads new properties
from
element . |
protected void |
rescueSettings(java.io.DataInputStream in,
Version version)
Called if some setting with version < 1.0.8 is found.
|
protected void |
rescueSettings(XElement element)
Called if some setting does not have the "modes" entry, the assumption is that
only old settings are missing this entry.
|
protected Path |
resuceMode(java.lang.String identifier)
Called if a single identifier of a mode is found as was used in
version 1.0.7 and below.
|
int |
size()
Gets the number of sets this setting stores.
|
void |
write(java.io.DataOutputStream out)
Writes all properties of this setting into
out . |
void |
writeXML(XElement element)
Writes the contents of this setting in xml format.
|
public ModeSettings(ModeSettingsConverter<A,B> converter)
converter
- the converter to read and write propertiespublic ModeSettingsConverter<A,B> getConverter()
null
public void addFactory(ModeSettingFactory<A> factory)
ModeSetting
s.factory
- the new factory, not null
public void add(java.lang.String id, Path current, java.util.Map<Path,A> properties, java.util.Collection<Path> history)
id
- the unique identifier of this set of propertiescurrent
- the current mode of the set, can be null
properties
- the properties, will be copied by this methodhistory
- older modes of the setting, will be copied by this methodpublic void add(Mode<A> mode)
mode
to this.mode
- the mode whose settings are to be storedpublic void add(ModeSetting<A> mode)
mode
to this.mode
- the properties to storepublic int size()
public int indexOf(java.lang.String id)
id
.id
- the identifier of a dockablepublic java.lang.String getId(int index)
index
- the index of the setpublic Path getCurrent(int index)
index
- the index of the setpublic Path[] getHistory(int index)
index
- the index of the setpublic java.util.Map<Path,A> getProperties(int index)
index
- the index of the setpublic ModeSetting<A> getSettings(Path modeId)
Mode
with unique
identifier modeId
.modeId
- the unique identifier of some modenull
if not foundpublic void write(java.io.DataOutputStream out) throws java.io.IOException
out
.out
- the stream to write intojava.io.IOException
- if an I/O-error occursprotected void rescueSettings(java.io.DataInputStream in, Version version) throws java.io.IOException
in
- the stream to read fromversion
- the version that was foundjava.io.IOException
- in case of an errorprotected void rescueSettings(XElement element)
element
- the entry that has to be rescuedXException
- in case of an error related to a wrongly read attributeprotected Path resuceMode(java.lang.String identifier)
identifier
- the single identifiernull
public void read(java.io.DataInputStream in) throws java.io.IOException
in
.in
- the stream to read fromjava.io.IOException
- if an I/O-error occurspublic void writeXML(XElement element)
element
- the element to write into, the attributes of
element will not be changed.readXML(XElement)
public void readXML(XElement element)
element
.element
- the element from which the properties should be readwriteXML(XElement)