gov.nasa.gsfc.drl.rtstps.core
Class Convert

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.Convert

public final class Convert
extends java.lang.Object

This class contains some static conversion utility methods to convert XML element attributes to useable values.


Constructor Summary
Convert()
           
 
Method Summary
static boolean toBoolean(org.w3c.dom.Element element, java.lang.String key, boolean defaultValue)
          Convert an XML element's attribute value to a boolean.
static int toHexInteger(org.w3c.dom.Element element, java.lang.String key, int defaultValue)
          Convert an XML element's attribute value to an integer.
static int toInteger(org.w3c.dom.Element element, java.lang.String key, int defaultValue)
          Convert an XML element's attribute value to an integer.
static int toInteger(org.w3c.dom.Element element, java.lang.String key, int defaultValue, int minimum)
          Convert an XML element's attribute value to an integer.
static int toInteger(org.w3c.dom.Element element, java.lang.String key, int defaultValue, int minimum, int maximum)
          Convert an XML element's attribute value to an integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Convert

public Convert()
Method Detail

toInteger

public static int toInteger(org.w3c.dom.Element element,
                            java.lang.String key,
                            int defaultValue)
                     throws RtStpsException
Convert an XML element's attribute value to an integer.

Parameters:
element - The XML element
key - The attribute name (key=value)
defaultValue - The returned value if the attribute was not specified with the element.
Returns:
The integer value (key=value) or the default value if the attribute was not specified.
Throws:
RtStpsException - If the value could not be converted to an integer.

toInteger

public static int toInteger(org.w3c.dom.Element element,
                            java.lang.String key,
                            int defaultValue,
                            int minimum)
                     throws RtStpsException
Convert an XML element's attribute value to an integer. The value must be greater than or equal to a minimum.

Parameters:
element - The XML element
key - The attribute name (key=value)
defaultValue - The returned value if the attribute was not specified with the element. minimum The minimum integer value the value can take.
Returns:
The integer value (key=value) or the default value if the attribute was not specified.
Throws:
RtStpsException - If the value could not be converted to an integer, or the value is less than the minimum.

toInteger

public static int toInteger(org.w3c.dom.Element element,
                            java.lang.String key,
                            int defaultValue,
                            int minimum,
                            int maximum)
                     throws RtStpsException
Convert an XML element's attribute value to an integer. The value must be greater than or equal to a minimum and less than or equal to a maximum.

Parameters:
element - The XML element
key - The attribute name (key=value)
defaultValue - The returned value if the attribute was not specified with the element. minimum The minimum integer value the value can take. maximum The maximum integer value the value can take.
Returns:
The integer value (key=value) or the default value if the attribute was not specified.
Throws:
RtStpsException - If the value could not be converted to an integer, or the value is less than the minimum, or the value is greater than the maximum.

toHexInteger

public static int toHexInteger(org.w3c.dom.Element element,
                               java.lang.String key,
                               int defaultValue)
                        throws RtStpsException
Convert an XML element's attribute value to an integer. It assumes the string is in hexadecimal format.

Parameters:
element - The XML element
key - The attribute name (key=value)
defaultValue - The returned value if the attribute was not specified with the element.
Returns:
The integer value (key=value) or the default value if the attribute was not specified.
Throws:
RtStpsException - If the value could not be converted to an integer.

toBoolean

public static boolean toBoolean(org.w3c.dom.Element element,
                                java.lang.String key,
                                boolean defaultValue)
                         throws RtStpsException
Convert an XML element's attribute value to a boolean. It assumes the string is either "true" or "false".

Parameters:
element - The XML element
key - The attribute name (key=value)
defaultValue - The returned value if the attribute was not specified with the element.
Returns:
The boolean value (key=value) or the default value if the attribute was not specified.
Throws:
RtStpsException - If the value could not be converted to a boolean.