org.deegree.commons.xml
Class XMLAdapter

java.lang.Object
  extended by org.deegree.commons.xml.XMLAdapter
Direct Known Subclasses:
AbstractCSWRequestXMLAdapter, AbstractWFSRequestXMLAdapter, Capabilities100XMLAdapter, Capabilities111XMLAdapter, Capabilities130XMLAdapter, CoverageDescription100XMLAdapter, DataArray101XMLAdapter, DescribeProcessRequestXMLAdapter, DescribeProcessResponseXMLAdapter, EventTime100XMLAdapter, EventTime100XMLExporter, ExecuteResponseXMLWriter, GetCapabilitiesXMLAdapter, GML3GeometryValidator, GMLFeatureReader, ISOQPParsing, Observation100XMLAdapter, ObservationStoreXMLAdapter, Offering100XMLAdapter, OWSCommon100CapabilitiesAdapter, OWSCommon110CapabilitiesAdapter, OWSCommonXMLAdapter, ParseIdentificationInfo, QueryExpressionText, ServiceConfigurationXMLAdapter, ServiceConfigurationXMLAdapter, SoapHeaderXMLAdapter, StoredQueryDefinitionXMLAdapter, WCSRequest100XMLAdapter, WFS100CapabilitiesAdapter, XMLExceptionSerializer, XMLFileResource

public class XMLAdapter
extends Object

XMLAdapter is the common base class of all hand-written (i.e. not automatically generated) XML parsers and exporters in deegree. Classes that extend XMLAdapter provide the binding between a certain type of XML documents and their corresponding Java bean representation.

XMLAdapter tries to make the process of writing custom XML parsers as painless as possible. It provides the following functionality:

Technically, the XML handling is based on AXIOM (AXis Object Model).

Version:
$Revision: 31638 $, $Date: 2011-08-24 18:06:08 +0200 (Wed, 24 Aug 2011) $
Author:
Markus Schneider , last edited by: $Author: mschneider $

Field Summary
static String DEFAULT_URL
          Use this URL as SystemID only if the document content cannot be pinpointed to a URL - in this case it may not use any relative references!
protected static NamespaceBindings nsContext
          The context
protected  org.apache.axiom.om.OMElement rootElement
          Root element of the XML contents.
protected static String XLN_NS
          the xlink namespace
 
Constructor Summary
XMLAdapter()
          Creates a new XMLAdapter which is not bound to an XML element.
XMLAdapter(File file)
          Creates a new instance that loads its content from the given File.
XMLAdapter(InputStream in)
          Creates a new instance that loads its content from the given InputStream using the default url.
XMLAdapter(InputStream in, String systemId)
          Creates a new instance that loads its content from the given InputStream.
XMLAdapter(org.apache.axiom.om.OMDocument doc, String systemId)
          Creates a new instance that wraps the submitted XML document.
XMLAdapter(org.apache.axiom.om.OMElement rootElement)
          Creates a new XMLAdapter with the given OMElement as root element;
XMLAdapter(org.apache.axiom.om.OMElement rootElement, String systemId)
          Creates a new instance that wraps the given XML element.
XMLAdapter(StringReader reader)
          Creates a new instance that loads its content from the given StringReader using the default url.
XMLAdapter(StringReader reader, String systemId)
          Creates a new instance that loads its content from the given StringReader.
XMLAdapter(URL url)
          Creates a new instance that loads its content from the given URL.
XMLAdapter(XMLStreamReader xmlStream)
           
 
Method Summary
 Object evaluateXPath(XPath xpath, Object context)
           
 org.apache.axiom.om.OMElement getElement(org.apache.axiom.om.OMElement context, XPath xpath)
           
 List<org.apache.axiom.om.OMElement> getElements(org.apache.axiom.om.OMElement context, XPath xpath)
           
 NamespaceBindings getNamespaceContext(org.apache.axiom.om.OMElement element)
          Constructs a NamespaceContext from all active namespace bindings available in the scope of the given OMElement.
 Object getNode(org.apache.axiom.om.OMElement context, XPath xpath)
           
 BigInteger getNodeAsBigInt(org.apache.axiom.om.OMElement context, XPath xpath, BigInteger defaultValue)
           
 boolean getNodeAsBoolean(org.apache.axiom.om.OMElement context, XPath xpath, boolean defaultValue)
           
 double getNodeAsDouble(org.apache.axiom.om.OMElement context, XPath xpath, double defaultValue)
           
 float getNodeAsFloat(org.apache.axiom.om.OMElement context, XPath xpath, float defaultValue)
           
 int getNodeAsInt(org.apache.axiom.om.OMElement context, XPath xpath, int defaultValue)
           
 QName getNodeAsQName(org.apache.axiom.om.OMElement context, XPath xpath, QName defaultValue)
           
 String getNodeAsString(org.apache.axiom.om.OMElement context, XPath xpath, String defaultValue)
           
 URL getNodeAsURL(org.apache.axiom.om.OMElement context, XPath xpath, URL defaultValue)
           
 Version getNodeAsVersion(org.apache.axiom.om.OMElement context, XPath xpath, Version defaultValue)
           
 List getNodes(org.apache.axiom.om.OMElement context, XPath xpath)
           
 QName[] getNodesAsQNames(org.apache.axiom.om.OMElement contextNode, XPath xpath)
           
 String[] getNodesAsStrings(org.apache.axiom.om.OMElement contextNode, XPath xpath)
           
 org.apache.axiom.om.OMElement getRequiredElement(org.apache.axiom.om.OMElement context, XPath xpath)
           
 List<org.apache.axiom.om.OMElement> getRequiredElements(org.apache.axiom.om.OMElement context, XPath xpath)
           
 Object getRequiredNode(org.apache.axiom.om.OMElement context, XPath xpath)
           
 boolean getRequiredNodeAsBoolean(org.apache.axiom.om.OMElement context, XPath xpath)
           
 double getRequiredNodeAsDouble(org.apache.axiom.om.OMElement context, XPath xpath)
           
 float getRequiredNodeAsFloat(org.apache.axiom.om.OMElement context, XPath xpath)
           
 int getRequiredNodeAsInteger(org.apache.axiom.om.OMElement context, XPath xpath)
           
 QName getRequiredNodeAsQName(org.apache.axiom.om.OMElement context, XPath xpath)
           
 String getRequiredNodeAsString(org.apache.axiom.om.OMElement context, XPath xpath)
           
 URL getRequiredNodeAsURL(org.apache.axiom.om.OMElement context, XPath xpath)
           
 Version getRequiredNodeAsVersion(org.apache.axiom.om.OMElement context, XPath xpath)
           
 List getRequiredNodes(org.apache.axiom.om.OMElement context, XPath xpath)
           
 org.apache.axiom.om.OMElement getRootElement()
          Returns the root element, i.e. the XML element encapsulated by this XMLAdapter.
 Map<String,URL> getSchemas()
          Determines the namespace URIs and the bound schema URLs from the 'xsi:schemaLocation' attribute of the wrapped XML element.
 String getSystemId()
          Returns the systemId (the physical location of the wrapped XML content).
 boolean hasSchemas()
          Returns whether the wrapped XML element contains schema references.
 void load(InputStream resourceStream)
          Initializes this XMLAdapter with the content from the given InputStream and sets the system id to the DEFAULT_URL
 void load(InputStream istream, String systemId)
          Initializes this XMLAdapter with the content from the given InputStream.
 void load(StringReader reader)
          Initializes this XMLAdapter with the content from the given StringReader and sets the system id to the DEFAULT_URL
 void load(StringReader reader, String systemId)
          Initializes this XMLAdapter with the content from the given StringReader.
 void load(URL url)
          Initializes this XMLAdapter with the content from the given URL.
 void load(URL url, String httpBasicUser, String httpBasicPass)
          Same as #load(URL), but with http basic authentication
 void load(XMLStreamReader xmlStream)
          Initializes this XMLAdapter with the content from the given InputStream and sets the system id to the DEFAULT_URL
static void maybeWriteElement(XMLStreamWriter writer, String name, String text)
          Writes an element without namespace, only if text not null
static void maybeWriteElementNS(XMLStreamWriter writer, String ns, String name, String text)
          Writes an element with namespace, only if text not null
 boolean parseBoolean(String s)
          Parses the given String as an xsd:boolean value.
 double parseDouble(String s)
          Parses the given String as an xsd:double value.
 float parseFloat(String s)
          Parses the given String as an xsd:float value.
 int parseInt(String s)
          Parses the given String as an xsd:integer value.
 QName parseQName(String s, org.apache.axiom.om.OMElement element)
          Parses the given String as an xsd:QName value.
 SimpleLink parseSimpleLink(org.apache.axiom.om.OMElement element)
          Parses the submitted XML element as a SimpleLink.
 URL parseURL(String s)
          Parses the given String as an URL.
 URL resolve(String url)
          Resolves the given URL (which may be relative) against the SystemID of this XMLAdapter into an absolute URL.
 void setRootElement(org.apache.axiom.om.OMElement rootElement)
          Sets the root element, i.e. the XML element encapsulated by this XMLAdapter.
 void setSystemId(String systemId)
          Sets the systemId (the physical location of the wrapped XML content).
 String toString()
           
static void writeElement(XMLStreamWriter writer, String name, String text)
          Writes an element without namespace, and with an (optional) text
static void writeElement(XMLStreamWriter writer, String namespace, String elemName, String value)
          Write an element with simple text content into the XMLStream.
static void writeElement(XMLStreamWriter writer, String namespace, String elemName, String attrNS, String attrName, String attrValue)
          Write an element with a single attribute into the XMLStream.
static void writeElement(XMLStreamWriter writer, String namespace, String elemName, String value, String attrNS, String attribPRE, String attrName, String attrValue)
          Write an element with simple text content and an attribute into the XMLStream.
static void writeElement(XMLStreamWriter writer, XMLStreamReader inStream)
          Copies an XML element (including all attributes and subnodes) from an XMLStreamReader into the given XMLStreamWriter.
static void writeOptionalAttribute(XMLStreamWriter writer, String name, String value)
          Write an optional attribute at the current position of the writer.
static void writeOptionalElement(XMLStreamWriter writer, String namespace, String elemName, String value)
          Write an optional element with simple text content into the XMLStream.
static void writeOptionalNSAttribute(XMLStreamWriter writer, String namespace, String name, String value)
          Write an optional attribute at the current position of the writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nsContext

protected static final NamespaceBindings nsContext
The context


XLN_NS

protected static final String XLN_NS
the xlink namespace

See Also:
Constant Field Values

DEFAULT_URL

public static final String DEFAULT_URL
Use this URL as SystemID only if the document content cannot be pinpointed to a URL - in this case it may not use any relative references!

See Also:
Constant Field Values

rootElement

protected org.apache.axiom.om.OMElement rootElement
Root element of the XML contents.

Constructor Detail

XMLAdapter

public XMLAdapter()
Creates a new XMLAdapter which is not bound to an XML element.


XMLAdapter

public XMLAdapter(org.apache.axiom.om.OMElement rootElement)
Creates a new XMLAdapter with the given OMElement as root element;

Parameters:
rootElement - the root element of the xml adapter

XMLAdapter

public XMLAdapter(URL url)
           throws XMLProcessingException
Creates a new instance that loads its content from the given URL.

Parameters:
url - source of the xml content
Throws:
XMLProcessingException

XMLAdapter

public XMLAdapter(File file)
           throws XMLProcessingException
Creates a new instance that loads its content from the given File.

Parameters:
file - source of the xml content
Throws:
XMLProcessingException

XMLAdapter

public XMLAdapter(StringReader reader)
           throws XMLProcessingException
Creates a new instance that loads its content from the given StringReader using the default url.

Parameters:
reader - source of the xml content
Throws:
XMLProcessingException

XMLAdapter

public XMLAdapter(StringReader reader,
                  String systemId)
           throws XMLProcessingException
Creates a new instance that loads its content from the given StringReader.

Parameters:
reader - source of the xml content
systemId - this string should represent a URL that is related to the passed reader. If this URL is not available or unknown, the string should contain the value of XMLAdapter.DEFAULT_URL
Throws:
XMLProcessingException

XMLAdapter

public XMLAdapter(InputStream in)
           throws XMLProcessingException
Creates a new instance that loads its content from the given InputStream using the default url.

Parameters:
in - source of the xml content
Throws:
XMLProcessingException

XMLAdapter

public XMLAdapter(InputStream in,
                  String systemId)
           throws XMLProcessingException
Creates a new instance that loads its content from the given InputStream.

Parameters:
in - source of the xml content
systemId - this string should represent a URL that is related to the passed reader. If this URL is not available or unknown, the string should contain the value of XMLAdapter.DEFAULT_URL
Throws:
XMLProcessingException

XMLAdapter

public XMLAdapter(org.apache.axiom.om.OMDocument doc,
                  String systemId)
Creates a new instance that wraps the submitted XML document.

Parameters:
doc - xml content
systemId - the URL that is the source of the passed doc. If this URL is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL

XMLAdapter

public XMLAdapter(org.apache.axiom.om.OMElement rootElement,
                  String systemId)
Creates a new instance that wraps the given XML element.

Parameters:
rootElement - xml content
systemId - the URL that is the source of the passed doc. If this URL is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL

XMLAdapter

public XMLAdapter(XMLStreamReader xmlStream)
Method Detail

getSystemId

public String getSystemId()
Returns the systemId (the physical location of the wrapped XML content).

Returns:
the systemId

setSystemId

public void setSystemId(String systemId)
Sets the systemId (the physical location of the wrapped XML content).

Parameters:
systemId - systemId (physical location) to set

hasSchemas

public boolean hasSchemas()
Returns whether the wrapped XML element contains schema references.

Returns:
true, if the element contains schema references, false otherwise

getSchemas

public Map<String,URL> getSchemas()
                           throws XMLProcessingException
Determines the namespace URIs and the bound schema URLs from the 'xsi:schemaLocation' attribute of the wrapped XML element.

Returns:
keys are URIs (namespaces), values are URLs (schema locations)
Throws:
XMLProcessingException

load

public void load(URL url)
          throws XMLProcessingException
Initializes this XMLAdapter with the content from the given URL. Sets the SystemId, too.

Parameters:
url - source of the xml content
Throws:
XMLProcessingException

load

public void load(URL url,
                 String httpBasicUser,
                 String httpBasicPass)
          throws XMLProcessingException
Same as #load(URL), but with http basic authentication

Parameters:
url -
httpBasicUser -
httpBasicPass -
Throws:
XMLProcessingException

load

public void load(InputStream istream,
                 String systemId)
          throws XMLProcessingException
Initializes this XMLAdapter with the content from the given InputStream. Sets the SystemId, too.

Parameters:
istream - source of the xml content
systemId - cannot be null. This string should represent a URL that is related to the passed istream. If this URL is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL
Throws:
XMLProcessingException

load

public void load(XMLStreamReader xmlStream)
          throws XMLProcessingException
Initializes this XMLAdapter with the content from the given InputStream and sets the system id to the DEFAULT_URL

Parameters:
xmlStream - to load the xml from.
Throws:
XMLProcessingException

load

public void load(InputStream resourceStream)
          throws XMLProcessingException
Initializes this XMLAdapter with the content from the given InputStream and sets the system id to the DEFAULT_URL

Parameters:
resourceStream - to load the xml from.
Throws:
XMLProcessingException

load

public void load(StringReader reader,
                 String systemId)
          throws XMLProcessingException
Initializes this XMLAdapter with the content from the given StringReader. Sets the SystemId, too.

Parameters:
reader - source of the XML content
systemId - can not be null. This string should represent a URL that is related to the passed reader. If this URL is not available or unknown, the string should contain the value of XMLFragment.DEFAULT_URL
Throws:
XMLProcessingException

load

public void load(StringReader reader)
          throws XMLProcessingException
Initializes this XMLAdapter with the content from the given StringReader and sets the system id to the DEFAULT_URL

Parameters:
reader - to load the xml from.
Throws:
XMLProcessingException

setRootElement

public void setRootElement(org.apache.axiom.om.OMElement rootElement)
Sets the root element, i.e. the XML element encapsulated by this XMLAdapter.

Parameters:
rootElement - the root element

getRootElement

public org.apache.axiom.om.OMElement getRootElement()
Returns the root element, i.e. the XML element encapsulated by this XMLAdapter.

Returns:
the root element

resolve

public URL resolve(String url)
            throws MalformedURLException
Resolves the given URL (which may be relative) against the SystemID of this XMLAdapter into an absolute URL.

Parameters:
url - URL to be resolved (may be relative or absolute)
Returns:
the resolved URL
Throws:
MalformedURLException

evaluateXPath

public Object evaluateXPath(XPath xpath,
                            Object context)
                     throws XMLProcessingException
Throws:
XMLProcessingException

parseSimpleLink

public SimpleLink parseSimpleLink(org.apache.axiom.om.OMElement element)
                           throws XMLParsingException
Parses the submitted XML element as a SimpleLink.

Possible escaping of the attributes "xlink:href", "xlink:role" and "xlink:arcrole" is performed automatically.

Parameters:
element -
Returns:
the object representation of the element
Throws:
XMLParsingException

parseBoolean

public boolean parseBoolean(String s)
                     throws XMLParsingException
Parses the given String as an xsd:boolean value.

Parameters:
s - the String to be parsed
Returns:
corresponding boolean value
Throws:
XMLParsingException - if the given String is not a valid instance of xsd:boolean

parseDouble

public double parseDouble(String s)
                   throws XMLParsingException
Parses the given String as an xsd:double value.

Parameters:
s - the String to be parsed
Returns:
corresponding double value
Throws:
XMLParsingException - if the given String is not a valid instance of xsd:double

parseFloat

public float parseFloat(String s)
                 throws XMLParsingException
Parses the given String as an xsd:float value.

Parameters:
s - the String to be parsed
Returns:
corresponding float value
Throws:
XMLParsingException - if the given String is not a valid instance of xsd:float

parseInt

public int parseInt(String s)
             throws XMLParsingException
Parses the given String as an xsd:integer value.

Parameters:
s - the String to be parsed
Returns:
corresponding integer value
Throws:
XMLParsingException - if the given String is not a valid instance of xsd:integer

parseURL

public URL parseURL(String s)
             throws XMLParsingException
Parses the given String as an URL.

Parameters:
s - the String to be parsed
Returns:
corresponding URL value
Throws:
XMLParsingException - if the given String is not a valid URL

parseQName

public QName parseQName(String s,
                        org.apache.axiom.om.OMElement element)
                 throws XMLParsingException
Parses the given String as an xsd:QName value.

Parameters:
s - the String to be parsed
element - element that provides the namespace context (used to resolve the namespace prefix)
Returns:
corresponding QName value
Throws:
XMLParsingException - if the given String is not a valid instance of xsd:QName

getElement

public org.apache.axiom.om.OMElement getElement(org.apache.axiom.om.OMElement context,
                                                XPath xpath)
                                         throws XMLParsingException
Throws:
XMLParsingException

getElements

public List<org.apache.axiom.om.OMElement> getElements(org.apache.axiom.om.OMElement context,
                                                       XPath xpath)
                                                throws XMLParsingException
Throws:
XMLParsingException

getNode

public Object getNode(org.apache.axiom.om.OMElement context,
                      XPath xpath)
               throws XMLParsingException
Throws:
XMLParsingException

getNodeAsBoolean

public boolean getNodeAsBoolean(org.apache.axiom.om.OMElement context,
                                XPath xpath,
                                boolean defaultValue)
                         throws XMLParsingException
Throws:
XMLParsingException

getNodeAsDouble

public double getNodeAsDouble(org.apache.axiom.om.OMElement context,
                              XPath xpath,
                              double defaultValue)
                       throws XMLParsingException
Throws:
XMLParsingException

getNodeAsFloat

public float getNodeAsFloat(org.apache.axiom.om.OMElement context,
                            XPath xpath,
                            float defaultValue)
                     throws XMLParsingException
Throws:
XMLParsingException

getNodeAsBigInt

public BigInteger getNodeAsBigInt(org.apache.axiom.om.OMElement context,
                                  XPath xpath,
                                  BigInteger defaultValue)
                           throws XMLParsingException
Throws:
XMLParsingException

getNodeAsInt

public int getNodeAsInt(org.apache.axiom.om.OMElement context,
                        XPath xpath,
                        int defaultValue)
                 throws XMLParsingException
Throws:
XMLParsingException

getNodeAsURL

public URL getNodeAsURL(org.apache.axiom.om.OMElement context,
                        XPath xpath,
                        URL defaultValue)
                 throws XMLParsingException
Throws:
XMLParsingException

getNodeAsQName

public QName getNodeAsQName(org.apache.axiom.om.OMElement context,
                            XPath xpath,
                            QName defaultValue)
                     throws XMLParsingException
Throws:
XMLParsingException

getNodeAsString

public String getNodeAsString(org.apache.axiom.om.OMElement context,
                              XPath xpath,
                              String defaultValue)
                       throws XMLParsingException
Throws:
XMLParsingException

getNodeAsVersion

public Version getNodeAsVersion(org.apache.axiom.om.OMElement context,
                                XPath xpath,
                                Version defaultValue)
                         throws XMLParsingException
Throws:
XMLParsingException

getNodes

public List getNodes(org.apache.axiom.om.OMElement context,
                     XPath xpath)
              throws XMLParsingException
Throws:
XMLParsingException

getNodesAsStrings

public String[] getNodesAsStrings(org.apache.axiom.om.OMElement contextNode,
                                  XPath xpath)

getNodesAsQNames

public QName[] getNodesAsQNames(org.apache.axiom.om.OMElement contextNode,
                                XPath xpath)

getRequiredElement

public org.apache.axiom.om.OMElement getRequiredElement(org.apache.axiom.om.OMElement context,
                                                        XPath xpath)
                                                 throws XMLParsingException
Throws:
XMLParsingException

getRequiredElements

public List<org.apache.axiom.om.OMElement> getRequiredElements(org.apache.axiom.om.OMElement context,
                                                               XPath xpath)
                                                        throws XMLParsingException
Throws:
XMLParsingException

getRequiredNode

public Object getRequiredNode(org.apache.axiom.om.OMElement context,
                              XPath xpath)
                       throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsBoolean

public boolean getRequiredNodeAsBoolean(org.apache.axiom.om.OMElement context,
                                        XPath xpath)
                                 throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsDouble

public double getRequiredNodeAsDouble(org.apache.axiom.om.OMElement context,
                                      XPath xpath)
                               throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsFloat

public float getRequiredNodeAsFloat(org.apache.axiom.om.OMElement context,
                                    XPath xpath)
                             throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsInteger

public int getRequiredNodeAsInteger(org.apache.axiom.om.OMElement context,
                                    XPath xpath)
                             throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsURL

public URL getRequiredNodeAsURL(org.apache.axiom.om.OMElement context,
                                XPath xpath)
                         throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsString

public String getRequiredNodeAsString(org.apache.axiom.om.OMElement context,
                                      XPath xpath)
                               throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsQName

public QName getRequiredNodeAsQName(org.apache.axiom.om.OMElement context,
                                    XPath xpath)
                             throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodeAsVersion

public Version getRequiredNodeAsVersion(org.apache.axiom.om.OMElement context,
                                        XPath xpath)
                                 throws XMLParsingException
Throws:
XMLParsingException

getRequiredNodes

public List getRequiredNodes(org.apache.axiom.om.OMElement context,
                             XPath xpath)
                      throws XMLParsingException
Throws:
XMLParsingException

getNamespaceContext

public NamespaceBindings getNamespaceContext(org.apache.axiom.om.OMElement element)
Constructs a NamespaceContext from all active namespace bindings available in the scope of the given OMElement.

Parameters:
element - the given element
Returns:
the constructed namespace context

writeElement

public static void writeElement(XMLStreamWriter writer,
                                String namespace,
                                String elemName,
                                String value)
                         throws XMLStreamException
Write an element with simple text content into the XMLStream.

Convenience method to write simple elements like:

 <ogc:GeometryOperand>gml:Envelope</ogc:GeometryOperand>
 <gml:upperCorner>90 180</gml:upperCorner>
 

Parameters:
writer -
namespace - the namespace of the element
elemName - the element name
value - the text value of the element
Throws:
XMLStreamException

writeElement

public static void writeElement(XMLStreamWriter writer,
                                String namespace,
                                String elemName,
                                String value,
                                String attrNS,
                                String attribPRE,
                                String attrName,
                                String attrValue)
                         throws XMLStreamException
Write an element with simple text content and an attribute into the XMLStream.

Convenience method to write simple elements like:

 <ogc:GeometryOperand name="env">gml:Envelope</ogc:GeometryOperand>
 <gml:upperCorner>90 180</gml:upperCorner>
 

Parameters:
writer -
namespace - the namespace of the element
elemName - the element name
value - the text value of the element
attrNS - the namespace of the attribute, null if the local namespace of the element should be used
attribPRE - to use for the namespace binding
attrName - the attribute name
attrValue - the attribute value, if null the attribute will not be written.
Throws:
XMLStreamException

writeOptionalAttribute

public static void writeOptionalAttribute(XMLStreamWriter writer,
                                          String name,
                                          String value)
                                   throws XMLStreamException
Write an optional attribute at the current position of the writer. If the value is empty or null no attribute will be written.

Parameters:
writer -
name -
value -
Throws:
XMLStreamException

writeOptionalNSAttribute

public static void writeOptionalNSAttribute(XMLStreamWriter writer,
                                            String namespace,
                                            String name,
                                            String value)
                                     throws XMLStreamException
Write an optional attribute at the current position of the writer. If the value is empty or null no attribute will be written.

Parameters:
writer -
namespace - of the attribute
name - of the attribute
value - of the attribute might be null
Throws:
XMLStreamException

writeElement

public static void writeElement(XMLStreamWriter writer,
                                String namespace,
                                String elemName,
                                String attrNS,
                                String attrName,
                                String attrValue)
                         throws XMLStreamException
Write an element with a single attribute into the XMLStream.

Convenience method to write simple elements like:

 <ows:Post xlink:href="http://localhost/" />
 <ogc:TemporalOperator name="TM_Begins" />
 

Parameters:
writer -
namespace - the namespace of the element
elemName - the element name
attrNS - the namespace of the attribute, null if the local namespace of the element should be used
attrName - the attribute name
attrValue - the attribute value
Throws:
XMLStreamException

writeOptionalElement

public static void writeOptionalElement(XMLStreamWriter writer,
                                        String namespace,
                                        String elemName,
                                        String value)
                                 throws XMLStreamException
Write an optional element with simple text content into the XMLStream. If the value is null, than the element is omitted.

Convenience method to write simple elements like:

 <ogc:GeometryOperand>gml:Envelope</ogc:GeometryOperand>
 <gml:upperCorner>10 -42</gml:upperCorner>
 

Parameters:
writer -
namespace - the namespace of the element
elemName - the element name
value - the text value of the element
Throws:
XMLStreamException

writeElement

public static void writeElement(XMLStreamWriter writer,
                                XMLStreamReader inStream)
                         throws XMLStreamException
Copies an XML element (including all attributes and subnodes) from an XMLStreamReader into the given XMLStreamWriter.

Parameters:
writer - XMLStreamWriter that the xml is appended to
inStream - cursor must point at a START_ELEMENT event and points at the corresponding END_ELEMENT event afterwards
Throws:
XMLStreamException

writeElement

public static void writeElement(XMLStreamWriter writer,
                                String name,
                                String text)
                         throws XMLStreamException
Writes an element without namespace, and with an (optional) text

Parameters:
writer -
name -
text -
Throws:
XMLStreamException

maybeWriteElement

public static void maybeWriteElement(XMLStreamWriter writer,
                                     String name,
                                     String text)
                              throws XMLStreamException
Writes an element without namespace, only if text not null

Parameters:
writer -
name -
text -
Throws:
XMLStreamException

maybeWriteElementNS

public static void maybeWriteElementNS(XMLStreamWriter writer,
                                       String ns,
                                       String name,
                                       String text)
                                throws XMLStreamException
Writes an element with namespace, only if text not null

Parameters:
writer -
ns -
name -
text -
Throws:
XMLStreamException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.