org.apache.axiom.om.impl.llom
Class OMElementImpl

java.lang.Object
  extended by org.apache.axiom.om.impl.llom.OMSerializableImpl
      extended by org.apache.axiom.om.impl.llom.OMNodeImpl
          extended by org.apache.axiom.om.impl.llom.OMElementImpl
All Implemented Interfaces:
IChildNode, IContainer, IElement, IParentNode, OMContainerEx, OMElementEx, OMNodeEx, OMConstants, OMContainer, OMElement, OMInformationItem, OMNamedInformationItem, OMNode, OMSerializable
Direct Known Subclasses:
OMSourcedElementImpl, SOAPElement

public class OMElementImpl
extends OMNodeImpl
implements IElement, OMConstants

Class OMElementImpl


Field Summary
protected  java.util.HashMap attributes
          Field attributes
protected  OMXMLParserWrapper builder
           
protected  OMNode firstChild
          Field firstChild
protected  OMNode lastChild
           
protected  java.lang.String localName
          Field localName
protected  java.util.HashMap namespaces
          Field namespaces
protected  OMNamespace ns
          The namespace of this element.
protected  javax.xml.namespace.QName qName
           
protected  int state
           
 
Fields inherited from class org.apache.axiom.om.impl.llom.OMNodeImpl
nextSibling, parent, previousSibling
 
Fields inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
factory
 
Fields inherited from interface org.apache.axiom.om.impl.common.IParentNode
COMPLETE, DISCARDED, INCOMPLETE
 
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
 
Fields inherited from interface org.apache.axiom.om.OMConstants
ARRAY_ITEM_LOCALNAME, ARRAY_ITEM_NS_PREFIX, ARRAY_ITEM_NSURI, ARRAY_ITEM_QNAME, DATA_HANDLER, DEFAULT_CHAR_SET_ENCODING, DEFAULT_DEFAULT_NAMESPACE, DEFAULT_XML_VERSION, IS_BINARY, IS_DATA_HANDLERS_AWARE, PULL_TYPE_BUILDER, PUSH_TYPE_BUILDER, XMLATTRTYPE_CDATA, XMLATTRTYPE_ENTITIES, XMLATTRTYPE_ENTITY, XMLATTRTYPE_ID, XMLATTRTYPE_IDREF, XMLATTRTYPE_IDREFS, XMLATTRTYPE_NMTOKEN, XMLATTRTYPE_NMTOKENS, XMLATTRTYPE_NOTATION, XMLNS_NS_PREFIX, XMLNS_NS_URI, XMLNS_PREFIX, XMLNS_URI
 
Constructor Summary
OMElementImpl(OMContainer parent, java.lang.String localName, OMNamespace ns, OMXMLParserWrapper builder, OMFactory factory, boolean generateNSDecl)
           
OMElementImpl(javax.xml.namespace.QName qname, OMContainer parent, OMFactory factory)
          It is assumed that the QName passed contains, at least, the localName for this element.
 
Method Summary
 OMAttribute addAttribute(OMAttribute attr)
          Inserts an attribute to this element.
 OMAttribute addAttribute(java.lang.String attributeName, java.lang.String value, OMNamespace ns)
           
 void addChild(OMNode omNode)
           
 void addChild(OMNode omNode, boolean fromBuilder)
           
 OMNamespace addNamespaceDeclaration(java.lang.String uri, java.lang.String prefix)
           
 void build()
           
 void buildWithAttachments()
          Parses this node and builds the object structure in memory.
 OMElement cloneOMElement()
           
protected  OMElement createClone(OMCloneOptions options, OMContainer targetParent)
           
 OMNamespace declareDefaultNamespace(java.lang.String uri)
           
 OMNamespace declareNamespace(OMNamespace namespace)
           
 OMNamespace declareNamespace(java.lang.String uri, java.lang.String prefix)
           
 OMNode detach()
          Removes this information item and its children, from the model completely.
 void discard()
          Method discard.
 void discarded()
           
 OMNamespace findNamespace(java.lang.String uri, java.lang.String prefix)
          Finds a namespace with the given uri and prefix, in the scope of the document.
 OMNamespace findNamespaceURI(java.lang.String prefix)
           
 java.util.Iterator getAllAttributes()
          Returns a List of OMAttributes.
 java.util.Iterator getAllDeclaredNamespaces()
          Method getAllDeclaredNamespaces.
 OMAttribute getAttribute(javax.xml.namespace.QName qname)
          Returns a named attribute if present.
 java.lang.String getAttributeValue(javax.xml.namespace.QName qname)
          Returns a named attribute's value, if present.
 OMXMLParserWrapper getBuilder()
          Method getBuilder.
 java.util.Iterator getChildElements()
          Returns a filtered list of children - just the elements.
 java.util.Iterator getChildren()
          Returns a collection of this element.
 java.util.Iterator getChildrenWithLocalName(java.lang.String localName)
           
 java.util.Iterator getChildrenWithName(javax.xml.namespace.QName elementQName)
          Searches for children with a given QName and returns an iterator to traverse through the OMNodes.
 java.util.Iterator getChildrenWithNamespaceURI(java.lang.String uri)
           
 OMNamespace getDefaultNamespace()
           
 java.util.Iterator getDescendants(boolean includeSelf)
           
 OMElement getFirstChildWithName(javax.xml.namespace.QName elementQName)
          Method getFirstChildWithName.
 OMElement getFirstElement()
          Gets first element.
 OMNode getFirstOMChild()
          Method getFirstOMChild.
 OMNode getFirstOMChildIfAvailable()
           
 OMNode getLastKnownOMChild()
           
 int getLineNumber()
           
 java.lang.String getLocalName()
          Method getLocalName.
 OMNamespace getNamespace()
           
 javax.xml.namespace.NamespaceContext getNamespaceContext(boolean detached)
           
 java.util.Iterator getNamespacesInScope()
           
 java.lang.String getNamespaceURI()
           
 java.lang.String getPrefix()
           
 javax.xml.namespace.QName getQName()
          Method getQName.
 javax.xml.transform.sax.SAXSource getSAXSource(boolean cache)
           
 int getState()
           
 java.lang.String getText()
           
 javax.xml.namespace.QName getTextAsQName()
           
 java.io.Reader getTextAsStream(boolean cache)
           
 int getType()
           
 javax.xml.stream.XMLStreamReader getXMLStreamReader()
           
 javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean cache)
           
 javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration)
           
 javax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
           
 void internalSerialize(javax.xml.stream.XMLStreamWriter writer, boolean cache)
          Serializes the node.
 boolean isComplete()
           
 void removeAttribute(OMAttribute attr)
           
 void removeChildren()
           
 javax.xml.namespace.QName resolveQName(java.lang.String qname)
           
 void setBuilder(OMXMLParserWrapper wrapper)
          Method setBuilder.
 void setComplete(boolean complete)
           
 void setFirstChild(OMNode firstChild)
          Method setFirstChild.
 void setLastChild(OMNode omNode)
           
 void setLineNumber(int lineNumber)
           
 void setLocalName(java.lang.String localName)
          Method setLocalName.
 void setNamespace(OMNamespace namespace)
           
 void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
           
 void setText(javax.xml.namespace.QName qname)
           
 void setText(java.lang.String text)
           
 java.lang.String toString()
           
 java.lang.String toStringWithConsume()
           
 void undeclarePrefix(java.lang.String prefix)
           
 void writeTextTo(java.io.Writer out, boolean cache)
           
 
Methods inherited from class org.apache.axiom.om.impl.llom.OMNodeImpl
clone, getIParentNode, getNextOMSibling, getNextOMSiblingIfAvailable, getParent, getPreviousOMSibling, insertSiblingAfter, insertSiblingBefore, internalSerialize, internalSerializeAndConsume, setNextOMSibling, setParent, setPreviousOMSibling
 
Methods inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
close, getOMFactory, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.axiom.om.OMElement
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
 
Methods inherited from interface org.apache.axiom.om.impl.common.IChildNode
getIParentNode
 
Methods inherited from interface org.apache.axiom.om.impl.OMNodeEx
getNextOMSiblingIfAvailable, internalSerialize, internalSerializeAndConsume, setNextOMSibling, setParent, setPreviousOMSibling
 
Methods inherited from interface org.apache.axiom.om.OMNode
getNextOMSibling, getParent, getPreviousOMSibling, insertSiblingAfter, insertSiblingBefore
 
Methods inherited from interface org.apache.axiom.om.OMSerializable
close, serialize, serialize, serializeAndConsume
 
Methods inherited from interface org.apache.axiom.om.OMInformationItem
clone, getOMFactory
 

Field Detail

builder

protected OMXMLParserWrapper builder

state

protected int state

ns

protected OMNamespace ns
The namespace of this element. Possible values:


localName

protected java.lang.String localName
Field localName


qName

protected javax.xml.namespace.QName qName

firstChild

protected OMNode firstChild
Field firstChild


namespaces

protected java.util.HashMap namespaces
Field namespaces


attributes

protected java.util.HashMap attributes
Field attributes


lastChild

protected OMNode lastChild
Constructor Detail

OMElementImpl

public OMElementImpl(OMContainer parent,
                     java.lang.String localName,
                     OMNamespace ns,
                     OMXMLParserWrapper builder,
                     OMFactory factory,
                     boolean generateNSDecl)

OMElementImpl

public OMElementImpl(javax.xml.namespace.QName qname,
                     OMContainer parent,
                     OMFactory factory)
              throws OMException
It is assumed that the QName passed contains, at least, the localName for this element.

Parameters:
qname - - this should be valid qname according to javax.xml.namespace.QName
Throws:
OMException
Method Detail

addChild

public void addChild(OMNode omNode)
Specified by:
addChild in interface OMContainer

addChild

public void addChild(OMNode omNode,
                     boolean fromBuilder)
Specified by:
addChild in interface OMContainerEx

getChildrenWithName

public java.util.Iterator getChildrenWithName(javax.xml.namespace.QName elementQName)
Searches for children with a given QName and returns an iterator to traverse through the OMNodes. This QName can contain any combination of prefix, localname and URI.

Specified by:
getChildrenWithName in interface OMContainer
Throws:
OMException

getChildrenWithLocalName

public java.util.Iterator getChildrenWithLocalName(java.lang.String localName)
Specified by:
getChildrenWithLocalName in interface OMContainer

getChildrenWithNamespaceURI

public java.util.Iterator getChildrenWithNamespaceURI(java.lang.String uri)
Specified by:
getChildrenWithNamespaceURI in interface OMContainer

getFirstChildWithName

public OMElement getFirstChildWithName(javax.xml.namespace.QName elementQName)
                                throws OMException
Method getFirstChildWithName.

Specified by:
getFirstChildWithName in interface OMContainer
Throws:
OMException

getChildren

public java.util.Iterator getChildren()
Returns a collection of this element. Children can be of types OMElement, OMText.

Specified by:
getChildren in interface OMContainer
Returns:
Returns children.

getDescendants

public java.util.Iterator getDescendants(boolean includeSelf)
Specified by:
getDescendants in interface OMContainer

getChildElements

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

Specified by:
getChildElements in interface OMElement
Returns:
Returns an iterator of the child elements.

declareNamespace

public OMNamespace declareNamespace(java.lang.String uri,
                                    java.lang.String prefix)
Specified by:
declareNamespace in interface OMElement

declareDefaultNamespace

public OMNamespace declareDefaultNamespace(java.lang.String uri)
Specified by:
declareDefaultNamespace in interface OMElement

getDefaultNamespace

public OMNamespace getDefaultNamespace()
Specified by:
getDefaultNamespace in interface OMElement

addNamespaceDeclaration

public OMNamespace addNamespaceDeclaration(java.lang.String uri,
                                           java.lang.String prefix)
Specified by:
addNamespaceDeclaration in interface OMElementEx

declareNamespace

public OMNamespace declareNamespace(OMNamespace namespace)
Specified by:
declareNamespace in interface OMElement
Returns:
Returns namespace.

undeclarePrefix

public void undeclarePrefix(java.lang.String prefix)
Specified by:
undeclarePrefix in interface OMElement

findNamespace

public OMNamespace findNamespace(java.lang.String uri,
                                 java.lang.String prefix)
Finds a namespace with the given uri and prefix, in the scope of the document. Starts to find from the current element and goes up in the hiararchy until one is found. If none is found, returns null.

Specified by:
findNamespace in interface OMElement

findNamespaceURI

public OMNamespace findNamespaceURI(java.lang.String prefix)
Specified by:
findNamespaceURI in interface OMElement

getAllDeclaredNamespaces

public java.util.Iterator getAllDeclaredNamespaces()
Method getAllDeclaredNamespaces.

Specified by:
getAllDeclaredNamespaces in interface OMElement
Returns:
Returns Iterator.

getNamespacesInScope

public java.util.Iterator getNamespacesInScope()
Specified by:
getNamespacesInScope in interface OMElement

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext(boolean detached)
Specified by:
getNamespaceContext in interface OMElement

getAllAttributes

public java.util.Iterator getAllAttributes()
Returns a List of OMAttributes.

Specified by:
getAllAttributes in interface OMElement
Returns:
Returns iterator.

getAttribute

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

Specified by:
getAttribute in interface OMElement
Parameters:
qname - the qualified name to search for
Returns:
Returns an OMAttribute with the given name if found, or null

getAttributeValue

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

Specified by:
getAttributeValue in interface OMElement
Parameters:
qname - the qualified name to search for
Returns:
Returns a String containing the attribute value, or null.

addAttribute

public OMAttribute addAttribute(OMAttribute attr)
Inserts an attribute to this element. Implementor can decide as to insert this in the front or at the end of set of attributes.

The owner of the attribute is set to be the particular OMElement. If the attribute already has an owner then the attribute is cloned (i.e. its name, value and namespace are copied to a new attribute) and the new attribute is added to the element. It's owner is then set to be the particular OMElement.

Specified by:
addAttribute in interface OMElement
Returns:
The attribute that was added to the element. Note: The added attribute may not be the same instance that was given to add. This can happen if the given attribute already has an owner. In such case the returned attribute and the given attribute are equal but not the same instance.
See Also:
OMAttributeImpl.equals(Object)

removeAttribute

public void removeAttribute(OMAttribute attr)
Specified by:
removeAttribute in interface OMElement

addAttribute

public OMAttribute addAttribute(java.lang.String attributeName,
                                java.lang.String value,
                                OMNamespace ns)
Specified by:
addAttribute in interface OMElement

setBuilder

public void setBuilder(OMXMLParserWrapper wrapper)
Method setBuilder.

Specified by:
setBuilder in interface OMElement

getBuilder

public OMXMLParserWrapper getBuilder()
Method getBuilder.

Specified by:
getBuilder in interface IParentNode
Specified by:
getBuilder in interface OMContainer
Specified by:
getBuilder in class OMSerializableImpl
Returns:
Returns OMXMLParserWrapper.

getFirstOMChild

public OMNode getFirstOMChild()
Method getFirstOMChild.

Specified by:
getFirstOMChild in interface OMContainer
Returns:
Returns child.

getFirstOMChildIfAvailable

public OMNode getFirstOMChildIfAvailable()
Specified by:
getFirstOMChildIfAvailable in interface IParentNode

getLastKnownOMChild

public OMNode getLastKnownOMChild()
Specified by:
getLastKnownOMChild in interface IContainer

setFirstChild

public void setFirstChild(OMNode firstChild)
Method setFirstChild.

Specified by:
setFirstChild in interface IContainer

setLastChild

public void setLastChild(OMNode omNode)
Specified by:
setLastChild in interface IContainer

detach

public OMNode detach()
              throws OMException
Removes this information item and its children, from the model completely.

Specified by:
detach in interface OMNode
Overrides:
detach in class OMNodeImpl
Throws:
OMException

getType

public int getType()
Specified by:
getType in interface OMNode

build

public void build()
           throws OMException
Specified by:
build in interface OMSerializable
Throws:
OMException

getState

public int getState()
Specified by:
getState in interface IParentNode

isComplete

public boolean isComplete()
Specified by:
isComplete in interface IParentNode
Specified by:
isComplete in interface OMSerializable

setComplete

public void setComplete(boolean complete)
Specified by:
setComplete in interface OMContainerEx
Specified by:
setComplete in interface OMNodeEx
Specified by:
setComplete in class OMSerializableImpl

discarded

public void discarded()
Specified by:
discarded in interface OMContainerEx

getXMLStreamReader

public javax.xml.stream.XMLStreamReader getXMLStreamReader()
Specified by:
getXMLStreamReader in interface OMContainer

getXMLStreamReaderWithoutCaching

public javax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
Specified by:
getXMLStreamReaderWithoutCaching in interface OMContainer

getXMLStreamReader

public javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean cache)
Specified by:
getXMLStreamReader in interface OMContainer

getXMLStreamReader

public javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean cache,
                                                           OMXMLStreamReaderConfiguration configuration)
Specified by:
getXMLStreamReader in interface OMContainer

setText

public void setText(java.lang.String text)
Specified by:
setText in interface OMElement

setText

public void setText(javax.xml.namespace.QName qname)
Specified by:
setText in interface OMElement

getText

public java.lang.String getText()
Specified by:
getText in interface OMElement

getTextAsStream

public java.io.Reader getTextAsStream(boolean cache)
Specified by:
getTextAsStream in interface OMElement

getTextAsQName

public javax.xml.namespace.QName getTextAsQName()
Specified by:
getTextAsQName in interface OMElement

writeTextTo

public void writeTextTo(java.io.Writer out,
                        boolean cache)
                 throws java.io.IOException
Specified by:
writeTextTo in interface OMElement
Throws:
java.io.IOException

internalSerialize

public void internalSerialize(javax.xml.stream.XMLStreamWriter writer,
                              boolean cache)
                       throws javax.xml.stream.XMLStreamException
Description copied from class: OMSerializableImpl
Serializes the node.

Specified by:
internalSerialize in interface OMNodeEx
Specified by:
internalSerialize in class OMSerializableImpl
Throws:
javax.xml.stream.XMLStreamException

getFirstElement

public OMElement getFirstElement()
Gets first element.

Specified by:
getFirstElement in interface OMElement
Returns:
Returns element.

getLocalName

public java.lang.String getLocalName()
Method getLocalName.

Specified by:
getLocalName in interface OMNamedInformationItem
Returns:
Returns local name.

setLocalName

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

Specified by:
setLocalName in interface OMNamedInformationItem

getNamespace

public OMNamespace getNamespace()
Specified by:
getNamespace in interface OMNamedInformationItem

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface OMNamedInformationItem

getNamespaceURI

public java.lang.String getNamespaceURI()
Specified by:
getNamespaceURI in interface OMNamedInformationItem

setNamespace

public void setNamespace(OMNamespace namespace)
Specified by:
setNamespace in interface OMElement

setNamespaceWithNoFindInCurrentScope

public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
Specified by:
setNamespaceWithNoFindInCurrentScope in interface OMElement

getQName

public javax.xml.namespace.QName getQName()
Method getQName.

Specified by:
getQName in interface OMNamedInformationItem
Returns:
Returns QName.

toStringWithConsume

public java.lang.String toStringWithConsume()
                                     throws javax.xml.stream.XMLStreamException
Specified by:
toStringWithConsume in interface OMElement
Throws:
javax.xml.stream.XMLStreamException

toString

public java.lang.String toString()
Specified by:
toString in interface OMElement
Overrides:
toString in class java.lang.Object

discard

public void discard()
             throws OMException
Method discard.

Specified by:
discard in interface OMNode
Throws:
OMException

resolveQName

public javax.xml.namespace.QName resolveQName(java.lang.String qname)
Specified by:
resolveQName in interface OMElement

cloneOMElement

public OMElement cloneOMElement()
Specified by:
cloneOMElement in interface OMElement

createClone

protected OMElement createClone(OMCloneOptions options,
                                OMContainer targetParent)

setLineNumber

public void setLineNumber(int lineNumber)
Specified by:
setLineNumber in interface OMElement

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface OMElement

buildWithAttachments

public void buildWithAttachments()
Description copied from class: OMNodeImpl
Parses this node and builds the object structure in memory. AXIOM supports two levels of deffered building. First is deffered building of AXIOM using StAX. Second level is the deffered building of attachments. AXIOM reads in the attachements from the stream only when user asks by calling getDataHandler(). build() method builds the OM without the attachments. buildAll() builds the OM together with attachement data. This becomes handy when user wants to free the input stream.

Specified by:
buildWithAttachments in interface OMNode
Overrides:
buildWithAttachments in class OMNodeImpl

getSAXSource

public javax.xml.transform.sax.SAXSource getSAXSource(boolean cache)
Specified by:
getSAXSource in interface OMContainer

removeChildren

public void removeChildren()
Specified by:
removeChildren in interface OMContainer


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