public class RestorableSupport extends Object
restorableState
element. State is stored in
stateObject
elements. Each stateObject
element is identified by its name
attribute. The value of a stateObject
can either be simple text content, or nested
stateObject
elements.
For example, this document stores four states: the string "Hello World!", the largest value an unsigned byte can
hold, the value of PI to six digits, and a boolean "true".
<?xml version="1.0" encoding="UTF-8"?>
<restorableState>
<stateObject name="helloWorldString">Hello World!</stateObject>
<stateObject name="maxUnsignedByteValue">255</stateObject>
<stateObject name="pi">3.141592</stateObject>
<stateObject name="booleanTrue">true</stateObject>
</restorableState>
Callers can create a new RestorableSupport with no state content, or create a RestorableSupport from an
existing XML document string. Callers can then add state by name and value, and query state by name.
RestorableSupport provides convenience methods for addding and querying state values as Strings, Integers, Doubles,
and Booleans.Restorable
Modifier and Type | Class and Description |
---|---|
static class |
RestorableSupport.StateObject
An interface to the
stateObject elements in an XML state document, as defined by RestorableSupport . |
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_DOCUMENT_ELEMENT_TAG_NAME |
protected static String |
DEFAULT_STATE_OBJECT_TAG_NAME |
protected Document |
doc |
protected String |
stateObjectTagName |
protected XPath |
xpath |
Modifier | Constructor and Description |
---|---|
protected |
RestorableSupport(Document doc)
Creates a new RestorableSupport with no contents and using a specified
Document . |
Modifier and Type | Method and Description |
---|---|
RestorableSupport.StateObject |
addStateObject(RestorableSupport.StateObject context,
String name)
Adds a new StateObject with the specified
name . |
RestorableSupport.StateObject |
addStateObject(String name)
Adds a new StateObject with the specified
name . |
void |
addStateValueAsBoolean(RestorableSupport.StateObject context,
String name,
boolean booleanValue)
Adds a new StateObject with the specified
name and Boolean value . |
void |
addStateValueAsBoolean(String name,
boolean booleanValue)
Adds a new StateObject with the specified
name and Boolean value . |
void |
addStateValueAsColor(RestorableSupport.StateObject context,
String name,
Color color) |
void |
addStateValueAsColor(String name,
Color color) |
void |
addStateValueAsDouble(RestorableSupport.StateObject context,
String name,
double doubleValue)
Adds a new StateObject with the specified
name and Double value . |
void |
addStateValueAsDouble(String name,
double doubleValue)
Adds a new StateObject with the specified
name and Double value . |
void |
addStateValueAsImageSourceList(RestorableSupport.StateObject context,
String name,
Map<Integer,Object> imageSources,
int faceCount) |
void |
addStateValueAsImageSourceList(String name,
Map<Integer,Object> imageSources,
int faceCount) |
void |
addStateValueAsInteger(RestorableSupport.StateObject context,
String name,
int intValue)
Adds a new StateObject with the specified
name and Integer value . |
void |
addStateValueAsInteger(String name,
int intValue)
Adds a new StateObject with the specified
name and Integer value . |
void |
addStateValueAsLatLon(RestorableSupport.StateObject context,
String name,
LatLon location) |
void |
addStateValueAsLatLon(String name,
LatLon location) |
void |
addStateValueAsLatLonList(RestorableSupport.StateObject context,
String name,
Iterable<? extends LatLon> locations) |
void |
addStateValueAsOffsetPair(RestorableSupport.StateObject context,
String name,
float[] offsetPair) |
void |
addStateValueAsOffsets(RestorableSupport.StateObject context,
String name,
OffsetsList offsets) |
void |
addStateValueAsOffsets(String name,
OffsetsList offsets) |
void |
addStateValueAsOffsetsList(RestorableSupport.StateObject context,
String name,
Map<Integer,OffsetsList> offsets) |
void |
addStateValueAsPosition(RestorableSupport.StateObject context,
String name,
Position position) |
void |
addStateValueAsPosition(String name,
Position position) |
void |
addStateValueAsSector(RestorableSupport.StateObject context,
String name,
Sector sector) |
void |
addStateValueAsSector(String name,
Sector sector) |
void |
addStateValueAsString(RestorableSupport.StateObject context,
String name,
String value)
Adds a new StateObject with the specified
name and String value . |
void |
addStateValueAsString(RestorableSupport.StateObject context,
String name,
String value,
boolean escapeValue)
Adds a new StateObject with the specified
name and String value . |
void |
addStateValueAsString(String name,
String value)
Adds a new StateObject with the specified
name and String value . |
void |
addStateValueAsString(String name,
String value,
boolean escapeValue)
Adds a new StateObject with the specified
name and String value . |
static void |
adjustTitleAndDisplayName(AVList params) |
protected boolean |
containsElement(Element elem) |
protected static void |
createDocumentElement(Document doc,
String tagName) |
protected RestorableSupport.StateObject |
createStateObject(Element context,
String name,
String value) |
protected RestorableSupport.StateObject |
createStateObject(Element context,
String name,
String value,
boolean escapeValue) |
static Color |
decodeColor(String encodedString)
Returns the Color described by the String
encodedString . |
static String |
encodeColor(Color color)
Returns a String encoding of the specified
color . |
protected RestorableSupport.StateObject[] |
extractStateObjects(Element context) |
protected RestorableSupport.StateObject[] |
findAllStateObjects(Node context,
String name) |
protected RestorableSupport.StateObject |
findStateObject(Node context,
String name) |
RestorableSupport.StateObject[] |
getAllStateObjects(RestorableSupport.StateObject context)
Returns all StateObjects directly beneath the a context StateObject.
|
RestorableSupport.StateObject[] |
getAllStateObjects(RestorableSupport.StateObject context,
String name)
Returns all StateObjects with the specified
name . |
RestorableSupport.StateObject[] |
getAllStateObjects(String name)
Returns any StateObjects directly beneath the document root that have the specified
name . |
protected Element |
getDocumentElement() |
String |
getDocumentElementTagName()
Returns the String that represents the document element name.
|
String |
getStateAsXml()
Returns an XML document string describing this RestorableSupport's current set of state objects.
|
RestorableSupport.StateObject |
getStateObject(RestorableSupport.StateObject context,
String name)
Returns the StateObject with the specified
name . |
RestorableSupport.StateObject |
getStateObject(String name)
Returns the StateObject with the specified
name . |
Boolean |
getStateObjectAsBoolean(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Boolean.
|
Color |
getStateObjectAsColor(RestorableSupport.StateObject stateObject) |
Double |
getStateObjectAsDouble(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Double.
|
Float |
getStateObjectAsFloat(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Float.
|
HashMap<Integer,Object> |
getStateObjectAsImageSourceList(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a HashMap of
|
Integer |
getStateObjectAsInteger(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as an Integer.
|
LatLon |
getStateObjectAsLatLon(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a LatLon.
|
List<LatLon> |
getStateObjectAsLatLonList(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a List of LatLons.
|
Long |
getStateObjectAsLong(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Long.
|
float[] |
getStateObjectAsOffsetPair(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a float[].
|
OffsetsList |
getStateObjectAsOffsets(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a OffsetsList.
|
HashMap<Integer,OffsetsList> |
getStateObjectAsOffsetsList(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a HashMap of
|
Position |
getStateObjectAsPosition(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Position.
|
Sector |
getStateObjectAsSector(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Sector.
|
String |
getStateObjectAsString(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a String.
|
String |
getStateObjectTagName()
Returns the String to be used for each state object's tag name.
|
Boolean |
getStateValueAsBoolean(RestorableSupport.StateObject context,
String name)
Returns the value of the StateObject with the specified
name as a Boolean. |
Boolean |
getStateValueAsBoolean(String name)
Returns the value of the StateObject with the specified
name as a Boolean. |
Color |
getStateValueAsColor(RestorableSupport.StateObject context,
String name) |
Double |
getStateValueAsDouble(RestorableSupport.StateObject context,
String name)
Returns the value of the StateObject with the specified
name as a Double. |
Double |
getStateValueAsDouble(String name)
Returns the value of the StateObject with the specified
name as a Double. |
Float |
getStateValueAsFloat(RestorableSupport.StateObject context,
String name)
Returns the value of the StateObject with the specified
name as a Float. |
Float |
getStateValueAsFloat(String name)
Returns the value of the StateObject with the specified
name as a Float. |
HashMap<Integer,Object> |
getStateValueAsImageSourceList(RestorableSupport.StateObject context,
String name) |
HashMap<Integer,Object> |
getStateValueAsImageSourceList(String name) |
Integer |
getStateValueAsInteger(RestorableSupport.StateObject context,
String name)
Returns the value of the StateObject with the specified
name as an Integer. |
Integer |
getStateValueAsInteger(String name)
Returns the value of the StateObject with the specified
name as an Integer. |
LatLon |
getStateValueAsLatLon(RestorableSupport.StateObject context,
String name) |
LatLon |
getStateValueAsLatLon(String name) |
List<LatLon> |
getStateValueAsLatLonList(RestorableSupport.StateObject context,
String name) |
List<LatLon> |
getStateValueAsLatLonList(String name) |
Long |
getStateValueAsLong(RestorableSupport.StateObject context,
String name)
Returns the value of the StateObject with the specified
name as a Long. |
Long |
getStateValueAsLong(String name)
Returns the value of the StateObject with the specified
name as a Long. |
float[] |
getStateValueAsOffsetPair(RestorableSupport.StateObject context,
String name) |
float[] |
getStateValueAsOffsetPair(String name) |
OffsetsList |
getStateValueAsOffsets(RestorableSupport.StateObject context,
String name) |
OffsetsList |
getStateValueAsOffsets(String name) |
HashMap<Integer,OffsetsList> |
getStateValueAsOffsetsList(RestorableSupport.StateObject context,
String name) |
HashMap<Integer,OffsetsList> |
getStateValueAsOffsetsList(String name) |
Position |
getStateValueAsPosition(RestorableSupport.StateObject context,
String name) |
Position |
getStateValueAsPosition(String name) |
Sector |
getStateValueAsSector(RestorableSupport.StateObject context,
String name) |
Sector |
getStateValueAsSector(String name) |
String |
getStateValueAsString(RestorableSupport.StateObject context,
String name)
Returns the value of the StateObject with the specified
name as a String. |
String |
getStateValueAsString(String name)
Returns the value of the StateObject with the specified
name as a String. |
static RestorableSupport |
newRestorableSupport()
Creates a new RestorableSupport with no contents.
|
static RestorableSupport |
newRestorableSupport(String documentElementName)
Creates a new RestorableSupport with no contents.
|
static RestorableSupport |
parse(String stateInXml)
Creates a new RestorableSupport with the contents of the specified state document.
|
void |
setStateObjectTagName(String stateObjectTagName)
Sets the String to be used for each state object's tag name.
|
String |
toString()
Returns an XML document string describing this RestorableSupport's current set of state objects.
|
protected static final String DEFAULT_DOCUMENT_ELEMENT_TAG_NAME
protected static final String DEFAULT_STATE_OBJECT_TAG_NAME
protected Document doc
protected String stateObjectTagName
protected XPath xpath
protected RestorableSupport(Document doc)
Document
.doc
- the document to hold the restorable state.IllegalArgumentException
- if the document reference is null.public RestorableSupport.StateObject addStateObject(RestorableSupport.StateObject context, String name)
name
. If context
is not null, the new
StateObject is nested directly beneath the specified context
. Otherwise, the new StateObject is
placed directly beneath the document root. If a StateObject with this name already exists, a new one is still
created.context
- the StateObject under which the new StateObject is created, or null to place it under the document
root.name
- the new StateObject's name.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public RestorableSupport.StateObject addStateObject(String name)
name
. The new StateObject is placed directly beneath the
document root. If a StateObject with this name already exists, a new one is still created.name
- the new StateObject's name.IllegalArgumentException
- If name
is null.public void addStateValueAsBoolean(RestorableSupport.StateObject context, String name, boolean booleanValue)
name
and Boolean value
. If
context
is not null, the new StateObject is nested directly beneath the specified
context
. Otherwise, the new StateObject is placed directly beneath the document root. If a
StateObject with this name already exists, a new one is still created.context
- the StateObject context under which the new StateObject is created, or null to place it under
the document root.name
- the new StateObject's name.booleanValue
- the new StateObject's Boolean value.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public void addStateValueAsBoolean(String name, boolean booleanValue)
name
and Boolean value
. The new StateObject
is placed beneath the document root. If a StateObject with this name already exists, a new one is still created.name
- the new StateObject's name.booleanValue
- the new StateObject's Boolean value.IllegalArgumentException
- If name
is null.public void addStateValueAsColor(RestorableSupport.StateObject context, String name, Color color)
public void addStateValueAsDouble(RestorableSupport.StateObject context, String name, double doubleValue)
name
and Double value
. If
context
is not null, the new StateObject is nested directly beneath the specified
context
. Otherwise, the new StateObject is placed directly beneath the document root. If a
StateObject with this name already exists, a new one is still created.context
- the StateObject context under which the new StateObject is created, or null to place it under
the document root.name
- the new StateObject's name.doubleValue
- the new StateObject's Double value.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public void addStateValueAsDouble(String name, double doubleValue)
name
and Double value
. The new StateObject is
placed beneath the document root. If a StateObject with this name already exists, a new one is still created.name
- the new StateObject's name.doubleValue
- the new StateObject's Double value.IllegalArgumentException
- If name
is null.public void addStateValueAsImageSourceList(RestorableSupport.StateObject context, String name, Map<Integer,Object> imageSources, int faceCount)
public void addStateValueAsImageSourceList(String name, Map<Integer,Object> imageSources, int faceCount)
public void addStateValueAsInteger(RestorableSupport.StateObject context, String name, int intValue)
name
and Integer value
. If
context
is not null, the new StateObject is nested directly beneath the specified
context
. Otherwise, the new StateObject is placed directly beneath the document root. If a
StateObject with this name already exists, a new one is still created.context
- the StateObject context under which the new StateObject is created, or null to place it under the
document root.name
- the new StateObject's name.intValue
- the new StateObject's Integer value.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public void addStateValueAsInteger(String name, int intValue)
name
and Integer value
. The new StateObject
is placed beneath the document root. If a StateObject with this name already exists, a new one is still created.name
- the new StateObject's name.intValue
- the new StateObject's Integer value.IllegalArgumentException
- If name
is null.public void addStateValueAsLatLon(RestorableSupport.StateObject context, String name, LatLon location)
public void addStateValueAsLatLonList(RestorableSupport.StateObject context, String name, Iterable<? extends LatLon> locations)
public void addStateValueAsOffsetPair(RestorableSupport.StateObject context, String name, float[] offsetPair)
public void addStateValueAsOffsets(RestorableSupport.StateObject context, String name, OffsetsList offsets)
public void addStateValueAsOffsets(String name, OffsetsList offsets)
public void addStateValueAsOffsetsList(RestorableSupport.StateObject context, String name, Map<Integer,OffsetsList> offsets)
public void addStateValueAsPosition(RestorableSupport.StateObject context, String name, Position position)
public void addStateValueAsSector(RestorableSupport.StateObject context, String name, Sector sector)
public void addStateValueAsString(RestorableSupport.StateObject context, String name, String value)
name
and String value
. If
context
is not null, the new StateObject is nested directly beneath the specified
context
. Otherwise, the new StateObject is placed directly beneath the document root. If a
StateObject with this name already exists, a new one is still created.context
- the StateObject context under which the new StateObject is created, or null to place it under the
document root.name
- the new StateObject's name.value
- the new StateObject's String value.IllegalArgumentException
- If either name
or value
is null, or if
context
is not null and does not belong to this RestorableSupport.public void addStateValueAsString(RestorableSupport.StateObject context, String name, String value, boolean escapeValue)
name
and String value
. If
context
is not null, the new StateObject is nested directly beneath the specified
context
. Otherwise, the new StateObject is placed directly beneath the document root. If a
StateObject with this name already exists, a new one is still created. If escapeValue
is true, the
text in value
is escaped in a CDATA section. Otherwise, no special processing is performed on
value
. Once value
has been escaped and added, it can be extracted exactly like any
other String value.context
- the StateObject context under which the new StateObject is created, or null to place it under
the document root.name
- the new StateObject's name.value
- the new StateObject's String value.escapeValue
- whether to escape the String value
or not.IllegalArgumentException
- If either name
or value
is null, or if
context
is not null and does not belong to this RestorableSupport.public void addStateValueAsString(String name, String value)
name
and String value
. The new StateObject is
placed beneath the document root. If a StateObject with this name already exists, a new one is still created.name
- the new StateObject's name.value
- the new StateObject's String value.IllegalArgumentException
- If either name
or value
is null.public void addStateValueAsString(String name, String value, boolean escapeValue)
name
and String value
. The new StateObject is
placed beneath the document root. If a StateObject with this name already exists, a new one is still created. If
escapeValue
is true, the text in value
is escaped in a CDATA section. Otherwise, no
special processing is performed on value
. Once value
has been escaped and added, it can
be extracted exactly like any other String value.name
- the new StateObject's name.value
- the new StateObject's String value.escapeValue
- whether to escape the String value
or not.IllegalArgumentException
- If either name
or value
is null.public static void adjustTitleAndDisplayName(AVList params)
protected boolean containsElement(Element elem)
protected RestorableSupport.StateObject createStateObject(Element context, String name, String value)
protected RestorableSupport.StateObject createStateObject(Element context, String name, String value, boolean escapeValue)
public static Color decodeColor(String encodedString)
encodedString
. This understands Colors encoded with a call
to encodeColor(java.awt.Color)
. If encodedString
cannot be decoded, this method returns
null.encodedString
- String to decode.encodedString
, or null if the String cannot be decoded.IllegalArgumentException
- If encodedString
is null.public static String encodeColor(Color color)
color
. The Color can be restored with a call to decodeColor(String)
.color
- Color to encode.color
.IllegalArgumentException
- If color
is null.protected RestorableSupport.StateObject[] extractStateObjects(Element context)
protected RestorableSupport.StateObject[] findAllStateObjects(Node context, String name)
protected RestorableSupport.StateObject findStateObject(Node context, String name)
public RestorableSupport.StateObject[] getAllStateObjects(RestorableSupport.StateObject context)
context
. Otherwise, this method returns all the
StateObjects directly beneath the document root.context
- StateObject context to search, or null to search the document root.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public RestorableSupport.StateObject[] getAllStateObjects(RestorableSupport.StateObject context, String name)
name
. If context is not null, this method searches the
StateObjects directly below the specified context
. Otherwise, this method searches the StateObjects
directly beneath the document root. If no StateObjects with that name exist, this method returns a valid
StateObject array with zero length.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public RestorableSupport.StateObject[] getAllStateObjects(String name)
name
. If no
StateObjects with that name exist, this method returns a valid StateObject array with zero length.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.protected Element getDocumentElement()
public String getDocumentElementTagName()
public String getStateAsXml()
public RestorableSupport.StateObject getStateObject(RestorableSupport.StateObject context, String name)
name
. If context is not null, this method searches the
StateObjects directly below the specified context
. Otherwise, this method searches the StateObjects
directly beneath the document root. If no StateObject with that name exists, this method returns null.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public RestorableSupport.StateObject getStateObject(String name)
name
. This searches the StateObjects directly beneath the
document root. If no StateObject with that name exists, this method returns null.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public Boolean getStateObjectAsBoolean(RestorableSupport.StateObject stateObject)
Boolean.valueOf
.stateObject
- the StateObject that is converted to a Boolean.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public Color getStateObjectAsColor(RestorableSupport.StateObject stateObject)
public Double getStateObjectAsDouble(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a Double.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public Float getStateObjectAsFloat(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a Float.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public HashMap<Integer,Object> getStateObjectAsImageSourceList(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a HashMap of imageSources.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public Integer getStateObjectAsInteger(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to an Integer.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public LatLon getStateObjectAsLatLon(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a LatLon.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public List<LatLon> getStateObjectAsLatLonList(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a List of LatLons.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public Long getStateObjectAsLong(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a Long.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public float[] getStateObjectAsOffsetPair(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a float[].IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public OffsetsList getStateObjectAsOffsets(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a OffsetsList.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public HashMap<Integer,OffsetsList> getStateObjectAsOffsetsList(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a HashMap of OffsetsLists.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public Position getStateObjectAsPosition(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a Position.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public Sector getStateObjectAsSector(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a Sector.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public String getStateObjectAsString(RestorableSupport.StateObject stateObject)
stateObject
- the StateObject that is converted to a String.IllegalArgumentException
- If stateObject
is null, or does not belong to this
RestorableSupport.public String getStateObjectTagName()
public Boolean getStateValueAsBoolean(RestorableSupport.StateObject context, String name)
name
as a Boolean. If context is not null,
this method searches the StateObjects directly below the specified context
. Otherwise, this method
searches the StateObjects directly beneath the document root. If no StateObject with that name exists, this
method returns null. Otherwise, the Boolean value returned is equivalent to passing the StateObject's String
value to Boolean.valueOf
.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public Boolean getStateValueAsBoolean(String name)
name
as a Boolean. This method searches the
StateObjects directly beneath the document root. If no StateObject with that name exists, this method returns
null. Otherwise, the Boolean value returned is equivalent to passing the StateObject's String value to
Boolean.valueOf
.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public Color getStateValueAsColor(RestorableSupport.StateObject context, String name)
public Double getStateValueAsDouble(RestorableSupport.StateObject context, String name)
name
as a Double. If context is not null,
this method searches the StateObjects directly below the specified context
. Otherwise, this searches
the StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of
that StateObject is not a Double, this method returns null.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public Double getStateValueAsDouble(String name)
name
as a Double. This method searches the
StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of that
StateObject is not a Double, this method returns null.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public Float getStateValueAsFloat(RestorableSupport.StateObject context, String name)
name
as a Float. If context is not null,
this method searches the StateObjects directly below the specified context
. Otherwise, this searches
the StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of
that StateObject is not a Float, this method returns null.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public Float getStateValueAsFloat(String name)
name
as a Float. This method searches the
StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of that
StateObject is not a Float, this method returns null.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public HashMap<Integer,Object> getStateValueAsImageSourceList(RestorableSupport.StateObject context, String name)
public HashMap<Integer,Object> getStateValueAsImageSourceList(String name)
public Integer getStateValueAsInteger(RestorableSupport.StateObject context, String name)
name
as an Integer. If context is not null,
this method searches the StateObjects directly below the specified context
. Otherwise, this method
searches the StateObjects directly beneath the document root. If no StateObject with that name exists, or if the
value of that StateObject is not an Integer, this method returns null.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public Integer getStateValueAsInteger(String name)
name
as an Integer. This method searches the
StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of that
StateObject is not an Integer, this method returns null.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public LatLon getStateValueAsLatLon(RestorableSupport.StateObject context, String name)
public List<LatLon> getStateValueAsLatLonList(RestorableSupport.StateObject context, String name)
public Long getStateValueAsLong(RestorableSupport.StateObject context, String name)
name
as a Long. If context is not null, this
method searches the StateObjects directly below the specified context
. Otherwise, this method
searches the StateObjects directly beneath the document root. If no StateObject with that name exists, or if the
value of that StateObject is not a Double, this method returns null.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public Long getStateValueAsLong(String name)
name
as a Long. This searches the
StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of that
StateObject is not a Long, this method returns null.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public float[] getStateValueAsOffsetPair(RestorableSupport.StateObject context, String name)
public float[] getStateValueAsOffsetPair(String name)
public OffsetsList getStateValueAsOffsets(RestorableSupport.StateObject context, String name)
public OffsetsList getStateValueAsOffsets(String name)
public HashMap<Integer,OffsetsList> getStateValueAsOffsetsList(RestorableSupport.StateObject context, String name)
public HashMap<Integer,OffsetsList> getStateValueAsOffsetsList(String name)
public Position getStateValueAsPosition(RestorableSupport.StateObject context, String name)
public Sector getStateValueAsSector(RestorableSupport.StateObject context, String name)
public String getStateValueAsString(RestorableSupport.StateObject context, String name)
name
as a String. If context is not null,
this method searches the StateObjects directly below the specified context
. Otherwise, this method
searches the StateObjects directly beneath the document root. If no StateObject with that name exists, or if the
value of that StateObject is not a String, this method returns null.context
- StateObject context to search, or null to search the document root.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null, or if context
is not null and does
not belong to this RestorableSupport.public String getStateValueAsString(String name)
name
as a String. This method searches the
StateObjects directly beneath the document root. If no StateObject with that name exists, or if the value of that
StateObject is not a String, this method returns null.name
- the StateObject name to search for.IllegalArgumentException
- If name
is null.public static RestorableSupport newRestorableSupport()
public static RestorableSupport newRestorableSupport(String documentElementName)
documentElementName
- the name of the restorable state document element.IllegalArgumentException
- if the specified element name is null or empty.public static RestorableSupport parse(String stateInXml)
stateInXml
- the XML document to parse for state.IllegalArgumentException
- If stateInXml
is null, or the its contents are not a well formed
XML document.public void setStateObjectTagName(String stateObjectTagName)
stateObjectTagName
- String to be used for each state object's tag name.IllegalArgumentException
- If stateObjectTagName
is null.