org.apache.axis2.om
Interface OMElement

All Superinterfaces:
OMContainer, OMNode
All Known Subinterfaces:
SOAPBody, SOAPEnvelope, SOAPFault, SOAPFaultCode, SOAPFaultDetail, SOAPFaultNode, SOAPFaultReason, SOAPFaultRole, SOAPFaultSubCode, SOAPFaultText, SOAPFaultValue, SOAPHeader, SOAPHeaderBlock
All Known Implementing Classes:
ElementImpl, OMElementImpl, SOAPBodyImpl, SOAPBodyImpl, SOAPEnvelopeImpl, SOAPEnvelopeImpl, SOAPFaultCodeImpl, SOAPFaultCodeImpl, SOAPFaultDetailImpl, SOAPFaultDetailImpl, SOAPFaultImpl, SOAPFaultImpl, SOAPFaultNodeImpl, SOAPFaultNodeImpl, SOAPFaultReasonImpl, SOAPFaultReasonImpl, SOAPFaultRoleImpl, SOAPFaultRoleImpl, SOAPFaultSubCodeImpl, SOAPFaultSubCodeImpl, SOAPFaultTextImpl, SOAPFaultTextImpl, SOAPFaultValueImpl, SOAPFaultValueImpl, SOAPHeaderBlockImpl, SOAPHeaderBlockImpl, SOAPHeaderImpl, SOAPHeaderImpl

public interface OMElement
extends OMNode, OMContainer

A particular kind of node that represents an element infoset information item.

An element has a collection of children, attributes, and namespaces.

In contrast with DOM, this interface exposes namespaces separately from the attributes.


Field Summary
 
Fields inherited from interface org.apache.axis2.om.OMNode
CDATA_SECTION_NODE, COMMENT_NODE, DTD_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, PI_NODE, SPACE_NODE, TEXT_NODE
 
Method Summary
 OMAttribute addAttribute(OMAttribute attr)
          This will add an attribute to this element.
 OMAttribute addAttribute(java.lang.String attributeName, java.lang.String value, OMNamespace ns)
          Add an attribute to the current element.
 OMElement cloneOMElement()
          This method will clone this element.
 OMNamespace declareNamespace(OMNamespace namespace)
          Declare a namespace with the element as its scope.
 OMNamespace declareNamespace(java.lang.String uri, java.lang.String prefix)
          THis will create a namespace in the current element scope
 OMNamespace findNamespace(java.lang.String uri, java.lang.String prefix)
          This will find a namespace with the given uri and prefix, in the scope of the hierarchy.
 OMNamespace findNamespaceURI(java.lang.String prefix)
          This will check for a namespace in the context of this element with the given prefix and will return the relevant namespace object, if available.
 java.util.Iterator getAllAttributes()
          This will return a List of OMAttributes.
 java.util.Iterator getAllDeclaredNamespaces()
          Returns an iterator for all of the namespaces declared on this element.
 OMAttribute getAttribute(javax.xml.namespace.QName qname)
          Return a named attribute if present.
 java.lang.String getAttributeValue(javax.xml.namespace.QName qname)
          Return a named attribute's value, if present.
 OMXMLParserWrapper getBuilder()
          Returns the builder object.
 java.util.Iterator getChildElements()
          Returns a filtered list of children - just the elements.
 OMAttribute getFirstAttribute(javax.xml.namespace.QName qname)
          This will search for an attribute with a given QName within this Element
 OMElement getFirstElement()
          Returns the first child element of the element.
 java.lang.String getLocalName()
          Returns the local name of the element.
 OMNamespace getNamespace()
           
 javax.xml.namespace.QName getQName()
          Get the QName of this node
 java.lang.String getText()
          This will return the non-empty text children as a String
 javax.xml.stream.XMLStreamReader getXMLStreamReader()
          Returns the pull parser that will generate the pull events relevant to THIS element.
 javax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
          Returns the pull parser that will generate the pull events relevant to THIS element.
 void removeAttribute(OMAttribute attr)
          Method removeAttribute
 javax.xml.namespace.QName resolveQName(java.lang.String qname)
          Turn a prefix:local qname string into a proper QName, evaluating it in the OMElement context unprefixed qnames resolve to the local namespace
 void setBuilder(OMXMLParserWrapper wrapper)
          Method setBuilder
 void setFirstChild(OMNode node)
          Set the first child
 void setLocalName(java.lang.String localName)
          Method setLocalName
 void setNamespace(OMNamespace namespace)
          sets the Namespace
 void setText(java.lang.String text)
           
 java.lang.String toString()
          This is a convenience method only.
 java.lang.String toStringWithConsume()
          This is a convenience method only.
 
Methods inherited from interface org.apache.axis2.om.OMNode
build, detach, discard, getNextOMSibling, getParent, getPreviousOMSibling, getType, insertSiblingAfter, insertSiblingBefore, isComplete, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
 
Methods inherited from interface org.apache.axis2.om.OMContainer
addChild, buildNext, getChildren, getChildrenWithName, getFirstChildWithName, getFirstOMChild, isComplete
 

Method Detail

getChildElements

public java.util.Iterator getChildElements()
Returns a filtered list of children - just the elements.

Returns:
an iterator over the child elements
See Also:
OMContainer.getChildren(), OMContainer.getChildrenWithName(javax.xml.namespace.QName)

declareNamespace

public OMNamespace declareNamespace(java.lang.String uri,
                                    java.lang.String prefix)
THis will create a namespace in the current element scope

Parameters:
uri - The namespace to declare in the current scope. The caller is expected to ensure that the URI is a valid namespace name.
prefix - The prefix to associate with the given namespace. The caller is expected to ensure that this is a valid XML prefix.
Returns:
The created namespace information item.
See Also:
declareNamespace(OMNamespace), findNamespace(String, String), getAllDeclaredNamespaces()

declareNamespace

public OMNamespace declareNamespace(OMNamespace namespace)
Declare a namespace with the element as its scope.

Parameters:
namespace - The namespace to declare
Returns:
The namespace parameter passed.
See Also:
declareNamespace(String, String), findNamespace(String, String), getAllDeclaredNamespaces()

findNamespace

public OMNamespace findNamespace(java.lang.String uri,
                                 java.lang.String prefix)
This will find a namespace with the given uri and prefix, in the scope of the hierarchy.

This will search from the current element and go up the hiararchy until a match is found. If no match is found, return null.

Either prefix or uri should be null. Results are undefined if both are specified.

Parameters:
uri - The namespace to look for. If this is specified, prefix should be null.
prefix - The prefix to look for. If this is specified, uri should be null.
Returns:
The matching namespace declaration, or null if none was found.
See Also:
declareNamespace(String, String), declareNamespace(OMNamespace), getAllDeclaredNamespaces()

findNamespaceURI

public OMNamespace findNamespaceURI(java.lang.String prefix)
This will check for a namespace in the context of this element with the given prefix and will return the relevant namespace object, if available. If not available, will return null.

Parameters:
prefix -

getAllDeclaredNamespaces

public java.util.Iterator getAllDeclaredNamespaces()
                                            throws OMException
Returns an iterator for all of the namespaces declared on this element.

If you're interested in all namespaces in scope, you need to call this function for all parent elements as well. Note that the iterator may be invalidated by any call to either declareNamespace function.

Returns:
An iterator over the OMNamespace items declared on the current element.
Throws:
OMException
See Also:
findNamespace(String, String), declareNamespace(String, String), declareNamespace(OMNamespace)

getFirstAttribute

public OMAttribute getFirstAttribute(javax.xml.namespace.QName qname)
This will search for an attribute with a given QName within this Element

Parameters:
qname - The attribute name to match.
Returns:
The attribute, if found, or null otherwise.

getAllAttributes

public java.util.Iterator getAllAttributes()
This will return a List of OMAttributes.

Note that the iterator returned by this function will be invalidated by any addAttribute call.

Returns:
Returns an Iterator of OMAttribute items associated with the element.
See Also:
getAttribute(javax.xml.namespace.QName), addAttribute(OMAttribute), addAttribute(String, String, OMNamespace)

getAttribute

public OMAttribute getAttribute(javax.xml.namespace.QName qname)
Return a named attribute if present.

Parameters:
qname - the qualified name to search for
Returns:
an OMAttribute with the given name if found, or null

getAttributeValue

public java.lang.String getAttributeValue(javax.xml.namespace.QName qname)
Return a named attribute's value, if present.

Parameters:
qname - the qualified name to search for
Returns:
a String containing the attribute value, or null

addAttribute

public OMAttribute addAttribute(OMAttribute attr)
This will add an attribute to this element.

There is no order implied by added attributes.

Parameters:
attr - The attribute to add.
Returns:
The passed in attribute.

addAttribute

public OMAttribute addAttribute(java.lang.String attributeName,
                                java.lang.String value,
                                OMNamespace ns)
Add an attribute to the current element.

This function does not check to make sure that the given attribute value can be serialized directly as an XML value. The caller may, for example, pass a string with the character 0x01.

Parameters:
attributeName - The "local name" for the attribute.
value - The string value of the attribute.
ns - The namespace has to be one of the in scope namespace. i.e. the passed namespace must be declared in the parent element of this attribute or ancestors of the parent element of the attribute.
Returns:
The added attribute.

removeAttribute

public void removeAttribute(OMAttribute attr)
Method removeAttribute

Parameters:
attr -

setBuilder

public void setBuilder(OMXMLParserWrapper wrapper)
Method setBuilder

Parameters:
wrapper -

getBuilder

public OMXMLParserWrapper getBuilder()
Returns the builder object.

Returns:
The builder object used to construct the underlying XML infoset on the fly.

setFirstChild

public void setFirstChild(OMNode node)
Set the first child

Parameters:
node -

getFirstElement

public OMElement getFirstElement()
Returns the first child element of the element.

Returns:
The first child element of the element, or null if none was found.

getXMLStreamReader

public javax.xml.stream.XMLStreamReader getXMLStreamReader()
Returns the pull parser that will generate the pull events relevant to THIS element.

Caching is on.

Returns:
Return an XMLStreamReader relative to this element.

getXMLStreamReaderWithoutCaching

public javax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
Returns the pull parser that will generate the pull events relevant to THIS element.

Caching is off.

Returns:
Return an XMLStreamReader relative to this element, with no caching.

setText

public void setText(java.lang.String text)
Parameters:
text -

getText

public java.lang.String getText()
This will return the non-empty text children as a String

Returns:
A String representing the concatenation of the child text nodes.

getLocalName

public java.lang.String getLocalName()
Returns the local name of the element.

Returns:
The local name of the element.

setLocalName

public void setLocalName(java.lang.String localName)
Method setLocalName

Parameters:
localName -

getNamespace

public OMNamespace getNamespace()
                         throws OMException
Returns:
the OMNamespace object associated with this element
Throws:
OMException

setNamespace

public void setNamespace(OMNamespace namespace)
sets the Namespace

Parameters:
namespace -

getQName

public javax.xml.namespace.QName getQName()
Get the QName of this node

Returns:
The QName for the element.

toString

public java.lang.String toString()
This is a convenience method only. This will basically serialize the given OMElement to a String but will build the OMTree in the memory


toStringWithConsume

public java.lang.String toStringWithConsume()
                                     throws javax.xml.stream.XMLStreamException
This is a convenience method only. This will basically serialize the given OMElement to a String but will NOT build the OMTree in the memory. So you are at your own risk of losing information.

Throws:
javax.xml.stream.XMLStreamException

resolveQName

public javax.xml.namespace.QName resolveQName(java.lang.String qname)
Turn a prefix:local qname string into a proper QName, evaluating it in the OMElement context unprefixed qnames resolve to the local namespace

Parameters:
qname - prefixed qname string to resolve
Returns:
null for any failure to extract a qname.

cloneOMElement

public OMElement cloneOMElement()
This method will clone this element. But both elements will be build compleletely. So you will lose the differed building capability.

Returns: