NASA World Wind

gov.nasa.worldwind.util
Class WWXML

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

public class WWXML
extends Object

A collection of static methods use for opening, reading and otherwise working with XML files.


Constructor Summary
WWXML()
           
 
Method Summary
static Element appendBoolean(Element context, String path, boolean value)
          Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value.
static Element appendDouble(Element context, String path, double value)
          Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value.
static Element appendElement(Element context, String name)
          Append a new element with a specified name to a context element.
static Element appendElementPath(Element context, String path)
          Append a heirarcy of new elements with a path to a context element.
static Element appendInteger(Element context, String path, int value)
          Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value.
static Element appendLatLon(Element context, String path, LatLon ll)
          Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a LatLon.
static Element appendLong(Element context, String path, long value)
          Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value.
static Element appendScreenCredit(Element context, String path, ScreenCredit screenCredit)
          Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a ScreenCredit.
static Element appendSector(Element context, String path, Sector sector)
          Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a Sector.
static Element appendSectorResolutionLimit(Element context, String path, LevelSet.SectorResolution sectorResolution)
          Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a LevelSet.SectorResolutionLimit.
static Element appendText(Element context, String path, String string)
          Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value.
static Element[] appendTextArray(Element context, String path, String[] strings)
          For each non-null string in a specified array, appends a heirarcy of new elements with a path to a context element, ending with a text element with a specified value.
static Element appendTimeInMillis(Element context, String path, long timeInMillis)
          Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a time in milliseconds.
static String byteOrderAsText(String byteOrder)
          Returns the string text for a specified byte order constant.
static void checkAndAppendBooleanElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendDoubleElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendIntegerlement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendLatLonElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendLongElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendScreenCreditElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendSectorElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendSectorResolutionElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendTextArrayElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendTextElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndAppendTimeElement(AVList params, String paramKey, Element context, String path)
          Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.
static void checkAndSetBooleanParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetDoubleParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetIntegerParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetLatLonParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetLongParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetScreenCreditParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetSectorParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetSectorResolutionParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetStringArrayParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetStringParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetTimeParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetTimeParamAsInteger(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static void checkAndSetUniqueStringsParam(Element context, AVList params, String paramKey, String paramName, XPath xpath)
          Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression.
static String checkOGCException(Document doc)
           
static DocumentBuilder createDocumentBuilder(boolean isNamespaceAware)
          Create a DOM builder.
static Transformer createTransformer()
          Create a XML transformer.
static String dataTypeAsText(String dataType)
          Returns the string text for a specified data type constant.
static String extractOGCServiceException(ByteBuffer buffer)
           
static String fixGetMapString(String gms)
           
static Boolean getBoolean(Element context, String path, XPath xpath)
          Returns the Boolean value of an element identified by an XPath expression.
static Double getDouble(Element context, String path, XPath xpath)
          Returns the Double value of an element identified by an XPath expression.
static Element getElement(Element context, String path, XPath xpath)
          Returns the element identified by an XPath expression.
static Element[] getElements(Element context, String path, XPath xpath)
          Returns all elements identified by an XPath expression.
static Integer getInteger(Element context, String path, XPath xpath)
          Returns the Integer value of an element identified by an XPath expression.
static LatLon getLatLon(Element context, String path, XPath xpath)
          Returns the LatLon value of an element identified by an XPath expression.
static Long getLong(Element context, String path, XPath xpath)
          Returns the Long value of an element identified by an XPath expression.
static ScreenCredit getScreenCredit(Element context, String path, XPath xpath)
          Returns the ScreenCredit value of an element identified by an XPath expression.
static Sector getSector(Element context, String path, XPath xpath)
          Returns the Sector value of an element identified by an XPath expression.
static LevelSet.SectorResolution getSectorResolutionLimit(Element context, String path, XPath xpath)
          Returns the LevelSet.SectorResolution value of an element identified by an XPath expression.
static String getText(Element context, String path)
          Returns the text of the element identified by an XPath expression.
static String getText(Element context, String path, XPath xpath)
          Returns the text of the element identified by an XPath expression.
static String[] getTextArray(Element context, String path, XPath xpath)
          Returns the text of all elements identified by an XPath expression.
static Long getTimeInMillis(Element context, String path, XPath xpath)
          Returns the time in milliseconds of an element identified by an XPath expression.
static Element[] getUniqueElements(Element context, String path, String uniqueTag, XPath xpath)
          Returns the unique elements identified by an XPath expression and a sub-expression.
static String[] getUniqueText(Element context, String path, XPath xpath)
          Returns the text of all unique elements identified by an XPath expression.
static XPath makeXPath()
          Shortcut method to create an XPath.
static Document openDocumentFile(String filePath, Class c)
          Opens an XML file given the file's location in the file system or on the classpath.
static Document openDocumentStream(InputStream inputStream)
          Opens an XML document given an input stream.
static Document openDocumentURL(URL url)
          Opens an XML document given a generic URL reference.
static String parseByteOrder(String s)
          Returns the byte order constant for a specified string.
static String parseDataType(String s)
          Returns the data type constant for a specified string.
static void saveDocumentToFile(Document doc, String filePath)
          Writes an XML document to a location in the file system.
static void saveDocumentToStream(Document doc, OutputStream outputStream)
          Writes an XML document to a specified outputstream stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WWXML

public WWXML()
Method Detail

appendBoolean

public static Element appendBoolean(Element context,
                                    String path,
                                    boolean value)
Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
value - the text element value.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendDouble

public static Element appendDouble(Element context,
                                   String path,
                                   double value)
Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
value - the text element value.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendElement

public static Element appendElement(Element context,
                                    String name)
Append a new element with a specified name to a context element. If the element name is null or empty, this returns the context element, and does not make any modifications to the context.

Parameters:
context - the context on which to append a new element.
name - the new element name to append.
Returns:
the new element appended to the context, or the context if the element name is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendElementPath

public static Element appendElementPath(Element context,
                                        String path)
Append a heirarcy of new elements with a path to a context element. The path is treated as a list of descendant elements which created and appended to the context. Each new element in the path is delimited by the "/" character. For example, the path "A/B/C" appends A to context, B to A, and C to B. If the path is null or empty, this returns the context element, and does not make any modifications to the context. If any element name in the path is empty, that element is skipped.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendInteger

public static Element appendInteger(Element context,
                                    String path,
                                    int value)
Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
value - the text element value.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendLatLon

public static Element appendLatLon(Element context,
                                   String path,
                                   LatLon ll)
Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a LatLon. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
ll - the LatLon value to create.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendLong

public static Element appendLong(Element context,
                                 String path,
                                 long value)
Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
value - the text element value.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendScreenCredit

public static Element appendScreenCredit(Element context,
                                         String path,
                                         ScreenCredit screenCredit)
Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a ScreenCredit. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
screenCredit - the ScreenCredit value to create.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendSector

public static Element appendSector(Element context,
                                   String path,
                                   Sector sector)
Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a Sector. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
sector - the Sector value to create.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendSectorResolutionLimit

public static Element appendSectorResolutionLimit(Element context,
                                                  String path,
                                                  LevelSet.SectorResolution sectorResolution)
Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a LevelSet.SectorResolutionLimit. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
sectorResolution - the LevelSet.SectorResolutionLimit value to create.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendText

public static Element appendText(Element context,
                                 String path,
                                 String string)
Append a heirarcy of new elements with a path to a context element, ending with a text element with a specified value. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
string - the text element value.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

appendTextArray

public static Element[] appendTextArray(Element context,
                                        String path,
                                        String[] strings)
For each non-null string in a specified array, appends a heirarcy of new elements with a path to a context element, ending with a text element with a specified value. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
strings - the text element values.
Returns:
array of new elements appended to the context.
Throws:
IllegalArgumentException - if the context is null.

appendTimeInMillis

public static Element appendTimeInMillis(Element context,
                                         String path,
                                         long timeInMillis)
Append a heirarcy of new elements with a path to a context element, ending with an element formatted as a time in milliseconds. Elements are added to the context as in appendElementPath(org.w3c.dom.Element, String), except that a terminating text element is appended to the last element.

Parameters:
context - the context on which to append new elements.
path - the element path to append.
timeInMillis - the time value in milliseconds to create.
Returns:
the new element appended to the context, or the context if the element path is null or empty.
Throws:
IllegalArgumentException - if the context is null.

byteOrderAsText

public static String byteOrderAsText(String byteOrder)
Returns the string text for a specified byte order constant. This performs a mapping between text and an AVKey constant:
TextConstant
LittleEndianAVKey.LITTLE_ENDIAN
BigEndianAVKey.BIG_ENDIAN

Parameters:
byteOrder - the byte order constant to encode as a string.
Returns:
a string representing the byte order constant, or null if the byte order constant is not recognized.
Throws:
IllegalArgumentException - if the byte order is null.

checkAndAppendBooleanElement

public static void checkAndAppendBooleanElement(AVList params,
                                                String paramKey,
                                                Element context,
                                                String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendDoubleElement

public static void checkAndAppendDoubleElement(AVList params,
                                               String paramKey,
                                               Element context,
                                               String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendIntegerlement

public static void checkAndAppendIntegerlement(AVList params,
                                               String paramKey,
                                               Element context,
                                               String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendLatLonElement

public static void checkAndAppendLatLonElement(AVList params,
                                               String paramKey,
                                               Element context,
                                               String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendLongElement

public static void checkAndAppendLongElement(AVList params,
                                             String paramKey,
                                             Element context,
                                             String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendScreenCreditElement

public static void checkAndAppendScreenCreditElement(AVList params,
                                                     String paramKey,
                                                     Element context,
                                                     String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendSectorElement

public static void checkAndAppendSectorElement(AVList params,
                                               String paramKey,
                                               Element context,
                                               String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendSectorResolutionElement

public static void checkAndAppendSectorResolutionElement(AVList params,
                                                         String paramKey,
                                                         Element context,
                                                         String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendTextArrayElement

public static void checkAndAppendTextArrayElement(AVList params,
                                                  String paramKey,
                                                  Element context,
                                                  String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendTextElement

public static void checkAndAppendTextElement(AVList params,
                                             String paramKey,
                                             Element context,
                                             String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndAppendTimeElement

public static void checkAndAppendTimeElement(AVList params,
                                             String paramKey,
                                             Element context,
                                             String path)
Checks a parameter list for a specified key and if present attempts to append new elements represeting the parameter to a specified context.

Parameters:
context - the context on which to append new elements.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
path - the element path to append.
Throws:
IllegalArgumentException - if either the parameter list parameter key, or context are null.

checkAndSetBooleanParam

public static void checkAndSetBooleanParam(Element context,
                                           AVList params,
                                           String paramKey,
                                           String paramName,
                                           XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetDoubleParam

public static void checkAndSetDoubleParam(Element context,
                                          AVList params,
                                          String paramKey,
                                          String paramName,
                                          XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetIntegerParam

public static void checkAndSetIntegerParam(Element context,
                                           AVList params,
                                           String paramKey,
                                           String paramName,
                                           XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetLatLonParam

public static void checkAndSetLatLonParam(Element context,
                                          AVList params,
                                          String paramKey,
                                          String paramName,
                                          XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetLongParam

public static void checkAndSetLongParam(Element context,
                                        AVList params,
                                        String paramKey,
                                        String paramName,
                                        XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetScreenCreditParam

public static void checkAndSetScreenCreditParam(Element context,
                                                AVList params,
                                                String paramKey,
                                                String paramName,
                                                XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetSectorParam

public static void checkAndSetSectorParam(Element context,
                                          AVList params,
                                          String paramKey,
                                          String paramName,
                                          XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetSectorResolutionParam

public static void checkAndSetSectorResolutionParam(Element context,
                                                    AVList params,
                                                    String paramKey,
                                                    String paramName,
                                                    XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetStringArrayParam

public static void checkAndSetStringArrayParam(Element context,
                                               AVList params,
                                               String paramKey,
                                               String paramName,
                                               XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetStringParam

public static void checkAndSetStringParam(Element context,
                                          AVList params,
                                          String paramKey,
                                          String paramName,
                                          XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetTimeParam

public static void checkAndSetTimeParam(Element context,
                                        AVList params,
                                        String paramKey,
                                        String paramName,
                                        XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetTimeParamAsInteger

public static void checkAndSetTimeParamAsInteger(Element context,
                                                 AVList params,
                                                 String paramKey,
                                                 String paramName,
                                                 XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkAndSetUniqueStringsParam

public static void checkAndSetUniqueStringsParam(Element context,
                                                 AVList params,
                                                 String paramKey,
                                                 String paramName,
                                                 XPath xpath)
Checks a parameter list for a specified key and if not present attempts to find a value for the key from an element matched by an XPath expression. If found, the key and value are added to the parameter list.

Parameters:
context - the context from which to start the XPath search.
params - the parameter list.
paramKey - the key used to identify the paramater in the parameter list.
paramName - the Xpath expression identifying the parameter value within the specified context.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Throws:
IllegalArgumentException - if either the context, parameter list, parameter key or parameter name are null.

checkOGCException

public static String checkOGCException(Document doc)

createDocumentBuilder

public static DocumentBuilder createDocumentBuilder(boolean isNamespaceAware)
Create a DOM builder.

Parameters:
isNamespaceAware - true if the builder is to be namespace aware, otherwise false.
Returns:
a DocumentBuilder.
Throws:
WWRuntimeException - if an error occurs.

createTransformer

public static Transformer createTransformer()
Create a XML transformer.

Returns:
a Transformer
Throws:
WWRuntimeException - if an error occurs.

dataTypeAsText

public static String dataTypeAsText(String dataType)
Returns the string text for a specified data type constant. This performs a mapping between text and an AVKey constant:
TextConstant
Float32AVKey.FLOAT32
Int32AVKey.INT32
Int16AVKey.INT16
Int8AVKey.INT8

Parameters:
dataType - the data type constant to encode as a string.
Returns:
a string representing the data type constant, or null if the data type constant is not recognized.
Throws:
IllegalArgumentException - if the data type is null.

extractOGCServiceException

public static String extractOGCServiceException(ByteBuffer buffer)

fixGetMapString

public static String fixGetMapString(String gms)

getBoolean

public static Boolean getBoolean(Element context,
                                 String path,
                                 XPath xpath)
Returns the Boolean value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a Boolean.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getDouble

public static Double getDouble(Element context,
                               String path,
                               XPath xpath)
Returns the Double value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a Double.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getElement

public static Element getElement(Element context,
                                 String path,
                                 XPath xpath)
Returns the element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the element matching the XPath expression, or null if no element matches.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getElements

public static Element[] getElements(Element context,
                                    String path,
                                    XPath xpath)
Returns all elements identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
an array containing the elements matching the XPath expression.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getInteger

public static Integer getInteger(Element context,
                                 String path,
                                 XPath xpath)
Returns the Integer value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a Integer.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getLatLon

public static LatLon getLatLon(Element context,
                               String path,
                               XPath xpath)
Returns the LatLon value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression. If null, indicates that the context is the LatLon element itself. If non-null, the context is searched for a LatLon element using the expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a LatLon.
Throws:
IllegalArgumentException - if the context is null.

getLong

public static Long getLong(Element context,
                           String path,
                           XPath xpath)
Returns the Long value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a Integer.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getScreenCredit

public static ScreenCredit getScreenCredit(Element context,
                                           String path,
                                           XPath xpath)
Returns the ScreenCredit value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression. If null, indicates that the context is the ScreenCredit element itself. If non-null, the context is searched for a ScreenCredit element using the expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a ScreenCredit.
Throws:
IllegalArgumentException - if the context is null.

getSector

public static Sector getSector(Element context,
                               String path,
                               XPath xpath)
Returns the Sector value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression. If null, indicates that the context is the Sector element itself. If non-null, the context is searched for a Sector element using the expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a Sector.
Throws:
IllegalArgumentException - if the context is null.

getSectorResolutionLimit

public static LevelSet.SectorResolution getSectorResolutionLimit(Element context,
                                                                 String path,
                                                                 XPath xpath)
Returns the LevelSet.SectorResolution value of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression. If null, indicates that the context is the SectorResolution element itself. If non-null, the context is searched for a SectorResolution element using the expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a LevelSet.SectorResolution.
Throws:
IllegalArgumentException - if the context is null.

getText

public static String getText(Element context,
                             String path)
Returns the text of the element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
Returns:
the text of an element matching the XPath expression, or null if no match is found.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getText

public static String getText(Element context,
                             String path,
                             XPath xpath)
Returns the text of the element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the text of an element matching the XPath expression, or null if no match is found.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getTextArray

public static String[] getTextArray(Element context,
                                    String path,
                                    XPath xpath)
Returns the text of all elements identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
an array containing the text of each element matching the XPath expression.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

getTimeInMillis

public static Long getTimeInMillis(Element context,
                                   String path,
                                   XPath xpath)
Returns the time in milliseconds of an element identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression. If null, indicates that the context is the Time element itself. If non-null, the context is searched for a Time element using the expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
the value of an element matching the XPath expression, or null if no match is found or the match does not contain a LatLon.
Throws:
IllegalArgumentException - if the context is null.

getUniqueElements

public static Element[] getUniqueElements(Element context,
                                          String path,
                                          String uniqueTag,
                                          XPath xpath)
Returns the unique elements identified by an XPath expression and a sub-expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
uniqueTag - an XPath expression to match with the elements matched with the above expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
an array containing the unique elements matching the XPath expression and subexpression. If multiple elements have the same content only the first one found is returned. Returns null if no matching element is found.
Throws:
IllegalArgumentException - if either the context, XPath expression or XPath sub-expression are null.

getUniqueText

public static String[] getUniqueText(Element context,
                                     String path,
                                     XPath xpath)
Returns the text of all unique elements identified by an XPath expression.

Parameters:
context - the context from which to start the XPath search.
path - the XPath expression.
xpath - an XPath object to use for the search. This allows the caller to re-use XPath objects when performing multiple searches. May be null.
Returns:
an array containing the text of each element matching the XPath expression and containing unique text. If multiple elements contain the same text only the first one found is returned. Returns null if no matching element is found.
Throws:
IllegalArgumentException - if the context or XPath expression are null.

makeXPath

public static XPath makeXPath()
Shortcut method to create an XPath.

Returns:
a new XPath.

openDocumentFile

public static Document openDocumentFile(String filePath,
                                        Class c)
Opens an XML file given the file's location in the file system or on the classpath.

Parameters:
filePath - the path to the file. Must be an absolute path or a path relative to a location in the classpath.
c - the class that is used to find a path relative to the classpath.
Returns:
a DOM for the file.
Throws:
IllegalArgumentException - if the file path is null.
WWRuntimeException - if an exception or error occurs while opening and parsing the file. The causing exception is included in this exception's Throwable.initCause(Throwable) .

openDocumentStream

public static Document openDocumentStream(InputStream inputStream)
Opens an XML document given an input stream.

Parameters:
inputStream - the document as an input stream.
Returns:
a DOM for the stream content.
Throws:
IllegalArgumentException - if the input stream is null.
WWRuntimeException - if an exception or error occurs while parsing the stream. The causing exception is included in this exception's Throwable.initCause(Throwable)

openDocumentURL

public static Document openDocumentURL(URL url)
Opens an XML document given a generic URL reference.

Parameters:
url - the URL to the document.
Returns:
a DOM for the URL.
Throws:
IllegalArgumentException - if the url is null.
WWRuntimeException - if an exception or error occurs while opening and parsing the url. The causing exception is included in this exception's Throwable.initCause(Throwable) .

parseByteOrder

public static String parseByteOrder(String s)
Returns the byte order constant for a specified string. This performs a mapping between text and an AVKey constant:
TextConstant
LittleEndianAVKey.LITTLE_ENDIAN
BigEndianAVKey.BIG_ENDIAN

Parameters:
s - the string to parse as a byte order.
Returns:
a byte order constant, or null if the string text is not recognized.
Throws:
IllegalArgumentException - if the string is null.

parseDataType

public static String parseDataType(String s)
Returns the data type constant for a specified string. This performs a mapping between text and an AVKey constant:
TextConstant
Float32AVKey.FLOAT32
Int32AVKey.INT32
Int16AVKey.INT16
Int8AVKey.INT8

Parameters:
s - the string to parse as a data type.
Returns:
a data type constant, or null if the string text is not recognized.
Throws:
IllegalArgumentException - if the string is null.

saveDocumentToFile

public static void saveDocumentToFile(Document doc,
                                      String filePath)
Writes an XML document to a location in the file system.

Parameters:
doc - the DOM document to save.
filePath - the path to the file. Must be an absolute path in the file system.
Throws:
IllegalArgumentException - if either the document or file path is null.
WWRuntimeException - if an exception or error occurs while writing the document. The causing exception is included in this exception's Throwable.initCause(Throwable)

saveDocumentToStream

public static void saveDocumentToStream(Document doc,
                                        OutputStream outputStream)
Writes an XML document to a specified outputstream stream.

Parameters:
doc - the DOM document to save.
outputStream - the outputstream to save the document contents to.
Throws:
IllegalArgumentException - if either the document or input stream is null.
WWRuntimeException - if an exception or error occurs while writing the document. The causing exception is included in this exception's Throwable.initCause(Throwable)

NASA World Wind

Hosted by docs.bugaco.com