org.apache.axiom.om
Interface OMElement

All Superinterfaces:
OMContainer, OMNode
All Known Subinterfaces:
OMSourcedElement, SOAPBody, SOAPEnvelope, SOAPFault, SOAPFaultCode, SOAPFaultDetail, SOAPFaultNode, SOAPFaultReason, SOAPFaultRole, SOAPFaultSubCode, SOAPFaultText, SOAPFaultValue, SOAPHeader, SOAPHeaderBlock
All Known Implementing Classes:
ElementImpl, OMElementImpl, OMSourcedElementImpl, SOAP11BodyImpl, SOAP11BodyImpl, SOAP11FaultCodeImpl, SOAP11FaultCodeImpl, SOAP11FaultDetailImpl, SOAP11FaultDetailImpl, SOAP11FaultImpl, SOAP11FaultImpl, SOAP11FaultReasonImpl, SOAP11FaultReasonImpl, SOAP11FaultRoleImpl, SOAP11FaultRoleImpl, SOAP11FaultSubCodeImpl, SOAP11FaultSubCodeImpl, SOAP11FaultTextImpl, SOAP11FaultTextImpl, SOAP11FaultValueImpl, SOAP11FaultValueImpl, SOAP11HeaderBlockImpl, SOAP11HeaderBlockImpl, SOAP11HeaderImpl, SOAP11HeaderImpl, SOAP12BodyImpl, SOAP12BodyImpl, SOAP12FaultCodeImpl, SOAP12FaultCodeImpl, SOAP12FaultDetailImpl, SOAP12FaultDetailImpl, SOAP12FaultImpl, SOAP12FaultImpl, SOAP12FaultNodeImpl, SOAP12FaultNodeImpl, SOAP12FaultReasonImpl, SOAP12FaultReasonImpl, SOAP12FaultRoleImpl, SOAP12FaultRoleImpl, SOAP12FaultSubCodeImpl, SOAP12FaultSubCodeImpl, SOAP12FaultTextImpl, SOAP12FaultTextImpl, SOAP12FaultValueImpl, SOAP12FaultValueImpl, SOAP12HeaderBlockImpl, SOAP12HeaderBlockImpl, SOAP12HeaderImpl, SOAP12HeaderImpl, SOAPBodyImpl, SOAPBodyImpl, SOAPElement, SOAPElement, SOAPEnvelopeImpl, SOAPEnvelopeImpl, SOAPFaultCodeImpl, SOAPFaultCodeImpl, SOAPFaultDetailImpl, SOAPFaultDetailImpl, SOAPFaultImpl, SOAPFaultImpl, SOAPFaultNodeImpl, SOAPFaultNodeImpl, SOAPFaultReasonImpl, SOAPFaultReasonImpl, SOAPFaultRoleImpl, SOAPFaultRoleImpl, SOAPFaultSubCodeImpl, SOAPFaultSubCodeImpl, SOAPFaultTextImpl, SOAPFaultTextImpl, SOAPFaultValueImpl, SOAPFaultValueImpl, SOAPHeaderBlockImpl, SOAPHeaderBlockImpl, SOAPHeaderImpl, SOAPHeaderImpl, SOAPTextImpl, SOAPTextImpl

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.axiom.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)
          Adds an attribute to this element.
 OMAttribute addAttribute(String attributeName, String value, OMNamespace ns)
          Adds an attribute to the current element.
 OMElement cloneOMElement()
          Clones this element.
 OMNamespace declareDefaultNamespace(String uri)
          This will declare a default namespace for this element explicitly
 OMNamespace declareNamespace(OMNamespace namespace)
          Declares a namespace with the element as its scope.
 OMNamespace declareNamespace(String uri, String prefix)
          Creates a namespace in the current element scope.
 OMNamespace findNamespace(String uri, String prefix)
          Finds a namespace with the given uri and prefix, in the scope of the hierarchy.
 OMNamespace findNamespaceURI(String prefix)
          Checks for a namespace in the context of this element with the given prefix and returns the relevant namespace object, if available.
 Iterator getAllAttributes()
          Returns a list of OMAttributes.
 Iterator getAllDeclaredNamespaces()
          Returns an iterator for all of the namespaces declared on this element.
 OMAttribute getAttribute(javax.xml.namespace.QName qname)
          Returns a named attribute if present.
 String getAttributeValue(javax.xml.namespace.QName qname)
          Returns a named attribute's value, if present.
 OMXMLParserWrapper getBuilder()
          Returns the builder object.
 Iterator getChildElements()
          Returns a filtered list of children - just the elements.
 OMNamespace getDefaultNamespace()
          This will retrieve the default namespace of this element, if available.
 OMElement getFirstElement()
          Returns the first child element of the element.
 int getLineNumber()
           
 String getLocalName()
          Returns the local name of the element.
 OMNamespace getNamespace()
           
 javax.xml.namespace.QName getQName()
          Gets the QName of this node.
 String getText()
          Returns the non-empty text children as a string.
 javax.xml.namespace.QName getTextAsQName()
          OMText can contain its information as a QName as well.
 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(String qname)
          Turns a prefix:local qname string into a proper QName, evaluating it in the OMElement context.
 void setBuilder(OMXMLParserWrapper wrapper)
          Method setBuilder.
 void setFirstChild(OMNode node)
          Deprecated. This method should not be called, un-intentionally. When some one randomly set the first child, all the links handling will not happen inside this method. So we have moved this method to the less visible interface, OMContainerEx.
 void setLineNumber(int lineNumber)
           
 void setLocalName(String localName)
          Method setLocalName
 void setNamespace(OMNamespace namespace)
          Sets the Namespace.
 void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
          This will not search the namespace in the scope nor will declare in the current element, as in setNamespace(OMNamespace).
 void setText(javax.xml.namespace.QName text)
           
 void setText(String text)
           
 String toString()
          This is a convenience method only.
 String toStringWithConsume()
          This is a convenience method only.
 
Methods inherited from interface org.apache.axiom.om.OMNode
build, buildWithAttachments, close, detach, discard, getNextOMSibling, getOMFactory, getParent, getPreviousOMSibling, getType, insertSiblingAfter, insertSiblingBefore, isComplete, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
 
Methods inherited from interface org.apache.axiom.om.OMContainer
addChild, buildNext, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getFirstChildWithName, getFirstOMChild, isComplete
 

Method Detail

getChildElements

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

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

declareNamespace

OMNamespace declareNamespace(String uri,
                             String prefix)
Creates 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. If "" is given, first this will check for an existing namespace with the same uri. If not found, a prefix will be auto-generated.
Returns:
Returns the created namespace information item.
See Also:
declareNamespace(OMNamespace), findNamespace(String, String), getAllDeclaredNamespaces()

declareDefaultNamespace

OMNamespace declareDefaultNamespace(String uri)
This will declare a default namespace for this element explicitly

Parameters:
uri -

getDefaultNamespace

OMNamespace getDefaultNamespace()
This will retrieve the default namespace of this element, if available. null returned if none is found.


declareNamespace

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

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

findNamespace

OMNamespace findNamespace(String uri,
                          String prefix)
Finds a namespace with the given uri and prefix, in the scope of the hierarchy.

Searches from the current element and goes up the hiararchy until a match is found. If no match is found, returns 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:
Returns the matching namespace declaration, or null if none was found.
See Also:
declareNamespace(String, String), declareNamespace(OMNamespace), getAllDeclaredNamespaces()

findNamespaceURI

OMNamespace findNamespaceURI(String prefix)
Checks for a namespace in the context of this element with the given prefix and returns the relevant namespace object, if available. If not available, returns null.

Parameters:
prefix -

getAllDeclaredNamespaces

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:
Returns an iterator over the OMNamespace items declared on the current element.
Throws:
OMException
See Also:
findNamespace(String, String), declareNamespace(String, String), declareNamespace(OMNamespace)

getAllAttributes

Iterator getAllAttributes()
Returns 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

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

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

getAttributeValue

String getAttributeValue(javax.xml.namespace.QName qname)
Returns a named attribute's value, if present.

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

addAttribute

OMAttribute addAttribute(OMAttribute attr)
Adds an attribute to this element.

There is no order implied by added attributes.

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

addAttribute

OMAttribute addAttribute(String attributeName,
                         String value,
                         OMNamespace ns)
Adds 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:
Returns the added attribute.

removeAttribute

void removeAttribute(OMAttribute attr)
Method removeAttribute

Parameters:
attr -

setBuilder

void setBuilder(OMXMLParserWrapper wrapper)
Method setBuilder.

Parameters:
wrapper -

getBuilder

OMXMLParserWrapper getBuilder()
Returns the builder object.

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

setFirstChild

void setFirstChild(OMNode node)
Deprecated. This method should not be called, un-intentionally. When some one randomly set the first child, all the links handling will not happen inside this method. So we have moved this method to the less visible interface, OMContainerEx.

Sets the first child.

Parameters:
node -

getFirstElement

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

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

getXMLStreamReader

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

Caching is on.

Returns:
Returns an XMLStreamReader relative to this element.

getXMLStreamReaderWithoutCaching

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

Caching is off.

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

setText

void setText(String text)
Parameters:
text -

setText

void setText(javax.xml.namespace.QName text)

getText

String getText()
Returns the non-empty text children as a string.

This method iterates over all the text children of the element and concatenates them to a single string. Only direct children will be considered, i.e. the text is not extracted recursively. For example the return value for <element>A<child>B</child>C</element> will be AC.

All whitespace will be preserved.

Returns:
A string representing the concatenation of the child text nodes. If there are no child text nodes, an empty string is returned.

getTextAsQName

javax.xml.namespace.QName getTextAsQName()
OMText can contain its information as a QName as well. This will return the text as a QName


getLocalName

String getLocalName()
Returns the local name of the element.

Returns:
Returns the local name of the element.

setLocalName

void setLocalName(String localName)
Method setLocalName

Parameters:
localName -

getNamespace

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

setNamespace

void setNamespace(OMNamespace namespace)
Sets the Namespace. This will first search for a namespace in the current scope with the given namespace. If no namespace is found with the given details, then it will declare a new one. Then that namespace will be assigned to this element.

Parameters:
namespace -

setNamespaceWithNoFindInCurrentScope

void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
This will not search the namespace in the scope nor will declare in the current element, as in setNamespace(OMNamespace). This will just assign the given namespace to the element.

Parameters:
namespace -

getQName

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

Returns:
Returns the QName for the element.

toString

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

Overrides:
toString in class Object

toStringWithConsume

String toStringWithConsume()
                           throws javax.xml.stream.XMLStreamException
This is a convenience method only. This basically serializes 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

javax.xml.namespace.QName resolveQName(String qname)
Turns 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:
Returns null for any failure to extract a qname.

cloneOMElement

OMElement cloneOMElement()
Clones this element. Since both elements are build compleletely, you will lose the differed building capability.

Returns:
Returns OMElement.

setLineNumber

void setLineNumber(int lineNumber)

getLineNumber

int getLineNumber()


Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.