NASA World Wind

gov.nasa.worldwind.util
Class RestorableSupport

java.lang.Object
  extended by gov.nasa.worldwind.util.RestorableSupport

public class RestorableSupport
extends Object

RestorableSupport provides convenient read and write access to restorable state located in a simple XML document format. This document is rooted by the 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.

See Also:
Restorable

Nested Class Summary
static class RestorableSupport.StateObject
          An interface to the stateObject elements in an XML state document, as defined by RestorableSupport.
 
Method Summary
 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 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 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 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.
 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.
 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.
 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.
 ArrayList<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.
 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.
 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)
           
 ArrayList<LatLon> getStateValueAsLatLonList(RestorableSupport.StateObject context, String name)
           
 ArrayList<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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

addStateObject

public RestorableSupport.StateObject addStateObject(RestorableSupport.StateObject context,
                                                    String name)
Adds a new StateObject with the specified 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.

Parameters:
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.
Returns:
the new StateObject instance.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

addStateObject

public RestorableSupport.StateObject addStateObject(String name)
Adds a new StateObject with the specified 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.

Parameters:
name - the new StateObject's name.
Returns:
the new StateObject instance.
Throws:
IllegalArgumentException - If name is null.

addStateValueAsBoolean

public void addStateValueAsBoolean(RestorableSupport.StateObject context,
                                   String name,
                                   boolean booleanValue)
Adds a new StateObject with the specified 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.

Parameters:
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.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

addStateValueAsBoolean

public void addStateValueAsBoolean(String name,
                                   boolean booleanValue)
Adds a new StateObject with the specified 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.

Parameters:
name - the new StateObject's name.
booleanValue - the new StateObject's Boolean value.
Throws:
IllegalArgumentException - If name is null.

addStateValueAsColor

public void addStateValueAsColor(RestorableSupport.StateObject context,
                                 String name,
                                 Color color)

addStateValueAsColor

public void addStateValueAsColor(String name,
                                 Color color)

addStateValueAsDouble

public void addStateValueAsDouble(RestorableSupport.StateObject context,
                                  String name,
                                  double doubleValue)
Adds a new StateObject with the specified 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.

Parameters:
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.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

addStateValueAsDouble

public void addStateValueAsDouble(String name,
                                  double doubleValue)
Adds a new StateObject with the specified 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.

Parameters:
name - the new StateObject's name.
doubleValue - the new StateObject's Double value.
Throws:
IllegalArgumentException - If name is null.

addStateValueAsInteger

public void addStateValueAsInteger(RestorableSupport.StateObject context,
                                   String name,
                                   int intValue)
Adds a new StateObject with the specified 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.

Parameters:
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.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

addStateValueAsInteger

public void addStateValueAsInteger(String name,
                                   int intValue)
Adds a new StateObject with the specified 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.

Parameters:
name - the new StateObject's name.
intValue - the new StateObject's Integer value.
Throws:
IllegalArgumentException - If name is null.

addStateValueAsLatLon

public void addStateValueAsLatLon(RestorableSupport.StateObject context,
                                  String name,
                                  LatLon location)

addStateValueAsLatLon

public void addStateValueAsLatLon(String name,
                                  LatLon location)

addStateValueAsLatLonList

public void addStateValueAsLatLonList(RestorableSupport.StateObject context,
                                      String name,
                                      Iterable<? extends LatLon> locations)

addStateValueAsPosition

public void addStateValueAsPosition(RestorableSupport.StateObject context,
                                    String name,
                                    Position position)

addStateValueAsPosition

public void addStateValueAsPosition(String name,
                                    Position position)

addStateValueAsSector

public void addStateValueAsSector(RestorableSupport.StateObject context,
                                  String name,
                                  Sector sector)

addStateValueAsSector

public void addStateValueAsSector(String name,
                                  Sector sector)

addStateValueAsString

public void addStateValueAsString(RestorableSupport.StateObject context,
                                  String name,
                                  String value)
Adds a new StateObject with the specified 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.

Parameters:
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.
Throws:
IllegalArgumentException - If either name or value is null, or if context is not null and does not belong to this RestorableSupport.

addStateValueAsString

public void addStateValueAsString(RestorableSupport.StateObject context,
                                  String name,
                                  String value,
                                  boolean escapeValue)
Adds a new StateObject with the specified 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.

Parameters:
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.
Throws:
IllegalArgumentException - If either name or value is null, or if context is not null and does not belong to this RestorableSupport.

addStateValueAsString

public void addStateValueAsString(String name,
                                  String value)
Adds a new StateObject with the specified 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.

Parameters:
name - the new StateObject's name.
value - the new StateObject's String value.
Throws:
IllegalArgumentException - If either name or value is null.

addStateValueAsString

public void addStateValueAsString(String name,
                                  String value,
                                  boolean escapeValue)
Adds a new StateObject with the specified 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.

Parameters:
name - the new StateObject's name.
value - the new StateObject's String value.
escapeValue - whether to escape the String value or not.
Throws:
IllegalArgumentException - If either name or value is null.

decodeColor

public static Color decodeColor(String encodedString)
Returns the Color described by the String encodedString. This understands Colors encoded with a call to encodeColor(java.awt.Color). If encodedString cannot be decoded, this method returns null.

Parameters:
encodedString - String to decode.
Returns:
Color decoded from the specified encodedString, or null if the String cannot be decoded.
Throws:
IllegalArgumentException - If encodedString is null.

encodeColor

public static String encodeColor(Color color)
Returns a String encoding of the specified color. The Color can be restored with a call to decodeColor(String).

Parameters:
color - Color to encode.
Returns:
String encoding of the specified color.
Throws:
IllegalArgumentException - If color is null.

getAllStateObjects

public RestorableSupport.StateObject[] getAllStateObjects(RestorableSupport.StateObject context)
Returns all StateObjects directly beneath the a context StateObject. If context is not null, this method returns all the StateObjects directly below the specified context. Otherwise, this method returns all the StateObjects directly beneath the document root.

Parameters:
context - StateObject context to search, or null to search the document root.
Returns:
an array of the StateObject instances, which has zero length if none exist.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getAllStateObjects

public RestorableSupport.StateObject[] getAllStateObjects(RestorableSupport.StateObject context,
                                                          String name)
Returns all StateObjects with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
an array of the StateObject instances, which has zero length if none exist.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getAllStateObjects

public RestorableSupport.StateObject[] getAllStateObjects(String name)
Returns any StateObjects directly beneath the document root that have the specified name. If no StateObjects with that name exist, this method returns a valid StateObject array with zero length.

Parameters:
name - the StateObject name to search for.
Returns:
an array of the StateObject instances, which has zero length if none exist.
Throws:
IllegalArgumentException - If name is null.

getDocumentElementTagName

public String getDocumentElementTagName()
Returns the String that represents the document element name.

Returns:
String for the document element name.

getStateAsXml

public String getStateAsXml()
Returns an XML document string describing this RestorableSupport's current set of state objects. If this RestorableSupport cannot be converted, this method returns null.

Returns:
an XML state document string.

getStateObject

public RestorableSupport.StateObject getStateObject(RestorableSupport.StateObject context,
                                                    String name)
Returns the StateObject with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
the StateObject instance, or null if none exists.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getStateObject

public RestorableSupport.StateObject getStateObject(String name)
Returns the StateObject with the specified name. This searches the StateObjects directly beneath the document root. If no StateObject with that name exists, this method returns null.

Parameters:
name - the StateObject name to search for.
Returns:
the StateObject instance, or null if none exists.
Throws:
IllegalArgumentException - If name is null.

getStateObjectAsBoolean

public Boolean getStateObjectAsBoolean(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Boolean. The Boolean value returned is equivalent to passing the StateObject's String value to Boolean.valueOf.

Parameters:
stateObject - the StateObject that is converted to a Boolean.
Returns:
the value of the StateObject as a Boolean.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsColor

public Color getStateObjectAsColor(RestorableSupport.StateObject stateObject)

getStateObjectAsDouble

public Double getStateObjectAsDouble(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Double.

Parameters:
stateObject - the StateObject that is converted to a Double.
Returns:
the value of the StateObject as a Double.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsInteger

public Integer getStateObjectAsInteger(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as an Integer.

Parameters:
stateObject - the StateObject that is converted to an Integer.
Returns:
the value of the StateObject as an Integer.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsLatLon

public LatLon getStateObjectAsLatLon(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a LatLon.

Parameters:
stateObject - the StateObject that is converted to a LatLon.
Returns:
the value of the StateObject as a LatLon.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsLatLonList

public ArrayList<LatLon> getStateObjectAsLatLonList(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a List of LatLons.

Parameters:
stateObject - the StateObject that is converted to a List of LatLons.
Returns:
the value of the StateObject as a List of LatLons.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsLong

public Long getStateObjectAsLong(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Long.

Parameters:
stateObject - the StateObject that is converted to a Long.
Returns:
the value of the StateObject as a Long.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsPosition

public Position getStateObjectAsPosition(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Position.

Parameters:
stateObject - the StateObject that is converted to a Position.
Returns:
the value of the StateObject as a Position.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsSector

public Sector getStateObjectAsSector(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a Sector.

Parameters:
stateObject - the StateObject that is converted to a Sector.
Returns:
the value of the StateObject as a Sector.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectAsString

public String getStateObjectAsString(RestorableSupport.StateObject stateObject)
Returns the value of the StateObject as a String.

Parameters:
stateObject - the StateObject that is converted to a String.
Returns:
the value of the StateObject as a String.
Throws:
IllegalArgumentException - If stateObject is null, or does not belong to this RestorableSupport.

getStateObjectTagName

public String getStateObjectTagName()
Returns the String to be used for each state object's tag name. This tag name is used as a search parameter to find a state object, and is used as the tag name when a new state object is created. The default tag name is "stateObject".

Returns:
String to be used for each state object's tag name

getStateValueAsBoolean

public Boolean getStateValueAsBoolean(RestorableSupport.StateObject context,
                                      String name)
Returns the value of the StateObject with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
the value of the StateObject as a Boolean, or null if none exists.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getStateValueAsBoolean

public Boolean getStateValueAsBoolean(String name)
Returns the value of the StateObject with the specified 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.

Parameters:
name - the StateObject name to search for.
Returns:
the value of the StateObject as a Boolean, or null if none exists.
Throws:
IllegalArgumentException - If name is null.

getStateValueAsColor

public Color getStateValueAsColor(RestorableSupport.StateObject context,
                                  String name)

getStateValueAsDouble

public Double getStateValueAsDouble(RestorableSupport.StateObject context,
                                    String name)
Returns the value of the StateObject with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
the value of the StateObject as a Double, or null if none exists.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getStateValueAsDouble

public Double getStateValueAsDouble(String name)
Returns the value of the StateObject with the specified 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.

Parameters:
name - the StateObject name to search for.
Returns:
the value of the StateObject as a Double, or null if none exists.
Throws:
IllegalArgumentException - If name is null.

getStateValueAsInteger

public Integer getStateValueAsInteger(RestorableSupport.StateObject context,
                                      String name)
Returns the value of the StateObject with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
the value of the StateObject as an Integer, or null if none exists.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getStateValueAsInteger

public Integer getStateValueAsInteger(String name)
Returns the value of the StateObject with the specified 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.

Parameters:
name - the StateObject name to search for.
Returns:
the value of the StateObject as an Integer, or null if none exists.
Throws:
IllegalArgumentException - If name is null.

getStateValueAsLatLon

public LatLon getStateValueAsLatLon(RestorableSupport.StateObject context,
                                    String name)

getStateValueAsLatLon

public LatLon getStateValueAsLatLon(String name)

getStateValueAsLatLonList

public ArrayList<LatLon> getStateValueAsLatLonList(RestorableSupport.StateObject context,
                                                   String name)

getStateValueAsLatLonList

public ArrayList<LatLon> getStateValueAsLatLonList(String name)

getStateValueAsLong

public Long getStateValueAsLong(RestorableSupport.StateObject context,
                                String name)
Returns the value of the StateObject with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
the value of the StateObject as a Long, or null if none exists.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getStateValueAsLong

public Long getStateValueAsLong(String name)
Returns the value of the StateObject with the specified 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.

Parameters:
name - the StateObject name to search for.
Returns:
the value of the StateObject as a Long, or null if none exists.
Throws:
IllegalArgumentException - If name is null.

getStateValueAsPosition

public Position getStateValueAsPosition(RestorableSupport.StateObject context,
                                        String name)

getStateValueAsPosition

public Position getStateValueAsPosition(String name)

getStateValueAsSector

public Sector getStateValueAsSector(RestorableSupport.StateObject context,
                                    String name)

getStateValueAsSector

public Sector getStateValueAsSector(String name)

getStateValueAsString

public String getStateValueAsString(RestorableSupport.StateObject context,
                                    String name)
Returns the value of the StateObject with the specified 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.

Parameters:
context - StateObject context to search, or null to search the document root.
name - the StateObject name to search for.
Returns:
the value of the StateObject as a String, or null if none exists.
Throws:
IllegalArgumentException - If name is null, or if context is not null and does not belong to this RestorableSupport.

getStateValueAsString

public String getStateValueAsString(String name)
Returns the value of the StateObject with the specified 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.

Parameters:
name - the StateObject name to search for.
Returns:
the value of the StateObject as a String, or null if none exists.
Throws:
IllegalArgumentException - If name is null.

newRestorableSupport

public static RestorableSupport newRestorableSupport()
Creates a new RestorableSupport with no contents.

Returns:
a new, empty RestorableSupport instance.

newRestorableSupport

public static RestorableSupport newRestorableSupport(String documentElementName)
Creates a new RestorableSupport with no contents.

Parameters:
documentElementName - the name of the restorable state document element.
Returns:
a new, empty RestorableSupport instance.

parse

public static RestorableSupport parse(String stateInXml)
Creates a new RestorableSupport with the contents of the specified state document.

Parameters:
stateInXml - the XML document to parse for state.
Returns:
a new RestorableSupport instance with the specified state.
Throws:
IllegalArgumentException - If stateInXml is null, or the its contents are not a well formed XML document.

setStateObjectTagName

public void setStateObjectTagName(String stateObjectTagName)
Sets the String to be used for each state object's tag name. This tag name is used as a search parameter to find a state object, and is used as the tag name when a new state object is created. Setting this value does not retroactively set tag names for existing state objects. The default tag name is "stateObject".

Parameters:
stateObjectTagName - String to be used for each state object's tag name.
Throws:
IllegalArgumentException - If stateObjectTagName is null.

toString

public String toString()
Returns an XML document string describing this RestorableSupport's current set of state objects. Calling toString is equivalent to calling getStateAsXml.

Overrides:
toString in class Object
Returns:
an XML state document string.

NASA World Wind