org.apache.axiom.om.impl.dom
Class ElementImpl

java.lang.Object
  extended by org.apache.axiom.om.impl.dom.NodeImpl
      extended by org.apache.axiom.om.impl.dom.ChildNode
          extended by org.apache.axiom.om.impl.dom.ParentNode
              extended by org.apache.axiom.om.impl.dom.ElementImpl
All Implemented Interfaces:
Cloneable, OMContainerEx, OMNodeEx, OMConstants, OMContainer, OMElement, OMNode, OMSerializable, Element, Node, NodeList
Direct Known Subclasses:
SOAPElement, SOAPHeaderBlockImpl

public class ElementImpl
extends ParentNode
implements Element, OMElement, OMConstants

Implementation of the org.w3c.dom.Element and org.apache.axiom.om.Element interfaces.


Field Summary
protected  String localName
           
protected  OMNamespace namespace
           
 
Fields inherited from class org.apache.axiom.om.impl.dom.ParentNode
firstChild, lastChild
 
Fields inherited from class org.apache.axiom.om.impl.dom.ChildNode
nextSibling, parentNode, previousSibling
 
Fields inherited from class org.apache.axiom.om.impl.dom.NodeImpl
builder, done, factory, FIRSTCHILD, flags, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
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
ElementImpl(DocumentImpl ownerDocument, String tagName, NamespaceImpl ns, OMFactory factory)
          Creates a new element with the namespace.
ElementImpl(DocumentImpl ownerDocument, String tagName, NamespaceImpl ns, OMXMLParserWrapper builder, OMFactory factory)
           
ElementImpl(DocumentImpl ownerDocument, String tagName, OMFactory factory)
           
ElementImpl(OMFactory factory)
           
ElementImpl(ParentNode parentNode, String tagName, NamespaceImpl ns, OMFactory factory)
           
ElementImpl(ParentNode parentNode, String tagName, NamespaceImpl ns, OMXMLParserWrapper builder, OMFactory factory)
           
ElementImpl(String tagName, NamespaceImpl ns, OMXMLParserWrapper builder, OMFactory factory)
           
 
Method Summary
 OMAttribute addAttribute(OMAttribute attr)
          Adds an attribute to this element.
 OMAttribute addAttribute(String localName, String value, OMNamespace ns)
          Adds an attribute to this element.
 void buildWithAttachments()
          Parses this node and builds the object structure in memory.
 Node cloneNode(boolean deep)
           
 OMElement cloneOMElement()
          Creates a clone which belongs to a new document.
 OMNamespace declareDefaultNamespace(String uri)
          We use "" to store the default namespace of this element.
 OMNamespace declareNamespace(OMNamespace namespace)
          Allows overriding an existing declaration if the same prefix was used.
 OMNamespace declareNamespace(String uri, String prefix)
          Allows overriding an existing declaration if the same prefix was used.
 void discard()
          Discards a node.
 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(QName qname)
          Returns a named attribute if present.
 String getAttribute(String name)
          Looks in the local list of attributes and returns if found.
 Attr getAttributeNode(String name)
          Retrieves an attribute node by name.
 Attr getAttributeNodeNS(String namespaceURI, String localName)
          Retrieves an attribute node by local name and namespace URI.
 String getAttributeNS(String namespaceURI, String localName)
          Retrieves an attribute value by local name and namespace URI.
 NamedNodeMap getAttributes()
          Returns the set of attributes of this node and the namespace declarations available.
 String getAttributeValue(QName qname)
          Returns a named attribute's value, if present.
 Iterator getChildElements()
          Returns a filtered list of children - just the elements.
 OMNamespace getDefaultNamespace()
          This will retrieve the default namespace of this element, if available. null returned if none is found.
 NodeList getElementsByTagName(String name)
           
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
           
 OMElement getFirstElement()
          Returns the first Element node.
 int getLineNumber()
           
 String getLocalName()
          Returns the local name of this element node
 OMNamespace getNamespace()
          Returns the namespace of this element.
 String getNamespaceURI()
          Returns the value of the namespace URI.
 String getNamespaceURI(String prefix)
          Returns the namespace uri, given the prefix.
 OMNode getNextOMSibling()
          Default behavior returns null, overriden in ChildNode.
 String getNodeName()
           
 short getNodeType()
           
 String getPrefix()
          Returns the namespace prefix of this element node
 QName getQName()
          Returns the QName of this element.
 TypeInfo getSchemaTypeInfo()
           
 String getTagName()
           
 String getText()
          Gets all the text children and concatinates them to a single string.
 QName getTextAsQName()
          OMText can contain its information as a QName as well.
 String getTrimmedText()
           
 int getType()
          Returns the type of node.
 boolean hasAttribute(String name)
           
 boolean hasAttributeNS(String namespaceURI, String localName)
          Returns whether the given attribute is available or not.
 boolean hasAttributes()
          Returns whether this element contains any attribute or not.
 void internalSerialize(XMLStreamWriter writer, boolean cache)
          Serializes the node.
 void removeAttribute(OMAttribute attr)
          Removes an attribute from the element.
 void removeAttribute(String name)
          Removes an attribute by name.
 Attr removeAttributeNode(Attr oldAttr)
          Removes the specified attribute node.
 void removeAttributeNS(String namespaceURI, String localName)
           
 boolean removeNamespace(String prefix)
          Removes a declared namespace given its prefix.
 QName resolveQName(String qname)
          Resolves a QName literal in the namespace context defined by this element and produces a corresponding QName object.
 void setAttribute(String name, String value)
           
 Attr setAttributeNode(Attr attr)
          Adds a new attribute node.
 Attr setAttributeNodeNS(Attr attr)
           
 void setAttributeNS(String namespaceURI, String qualifiedName, String value)
          Adds a new attribute.
 void setBuilder(OMXMLParserWrapper wrapper)
          Sets the OM builder.
 void setIdAttribute(String name, boolean isId)
           
 void setIdAttributeNode(Attr idAttr, boolean isId)
           
 void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
           
 void setLineNumber(int lineNumber)
           
 void setLocalName(String localName)
          Sets the local name.
 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).
protected  void setOwnerDocument(DocumentImpl document)
          Sets the owner document.
 void setText(QName text)
          Set the content of this element to the given QName.
 void setText(String text)
          Creates a text node with the given value and adds it to the element.
 void setType(int nodeType)
           
 String toString()
          Overridden toString() for ease of debugging.
 String toStringWithConsume()
          This is a convenience method only.
 
Methods inherited from class org.apache.axiom.om.impl.dom.ParentNode
addChild, buildNext, getBuilder, getChildNodes, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getFirstChild, getFirstChildWithName, getFirstOMChild, getFirstOMChildIfAvailable, getLastChild, getTextContent, getXMLStreamReader, getXMLStreamReader, getXMLStreamReaderWithoutCaching, hasChildNodes, importNode, insertBefore, removeChild, replaceChild, setFirstChild, setLastChild, setTextContent
 
Methods inherited from class org.apache.axiom.om.impl.dom.ChildNode
detach, getNextOMSiblingIfAvailable, getNextSibling, getParent, getParentNode, getPreviousOMSibling, getPreviousSibling, insertSiblingAfter, insertSiblingBefore, setNextOMSibling, setParent, setPreviousOMSibling
 
Methods inherited from class org.apache.axiom.om.impl.dom.NodeImpl
appendChild, build, close, compareDocumentPosition, getBaseURI, getFeature, getLength, getNodeValue, getOMFactory, getOwnerDocument, getUserData, internalSerialize, internalSerializeAndConsume, isComplete, isDefaultNamespace, isEqualNode, isSameNode, isSupported, item, lookupNamespaceURI, lookupPrefix, normalize, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, setComplete, setNodeValue, setPrefix, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 
Methods inherited from interface org.apache.axiom.om.OMElement
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, setFirstChild
 
Methods inherited from interface org.apache.axiom.om.OMNode
detach, getParent, getPreviousOMSibling, insertSiblingAfter, insertSiblingBefore
 
Methods inherited from interface org.apache.axiom.om.OMContainer
addChild, buildNext, getBuilder, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getFirstChildWithName, getFirstOMChild, getXMLStreamReader, getXMLStreamReader, getXMLStreamReaderWithoutCaching
 
Methods inherited from interface org.apache.axiom.om.OMSerializable
build, close, getOMFactory, isComplete, serialize, serialize, serializeAndConsume
 
Methods inherited from interface org.apache.axiom.om.impl.OMContainerEx
setComplete
 

Field Detail

namespace

protected OMNamespace namespace

localName

protected String localName
Constructor Detail

ElementImpl

public ElementImpl(DocumentImpl ownerDocument,
                   String tagName,
                   OMFactory factory)
Parameters:
ownerDocument - ownerDocument
tagName - tagName
factory - OMFactory

ElementImpl

public ElementImpl(DocumentImpl ownerDocument,
                   String tagName,
                   NamespaceImpl ns,
                   OMFactory factory)
Creates a new element with the namespace.

Parameters:
ownerDocument -
tagName -
ns -
factory -

ElementImpl

public ElementImpl(DocumentImpl ownerDocument,
                   String tagName,
                   NamespaceImpl ns,
                   OMXMLParserWrapper builder,
                   OMFactory factory)

ElementImpl

public ElementImpl(ParentNode parentNode,
                   String tagName,
                   NamespaceImpl ns,
                   OMFactory factory)

ElementImpl

public ElementImpl(ParentNode parentNode,
                   String tagName,
                   NamespaceImpl ns,
                   OMXMLParserWrapper builder,
                   OMFactory factory)

ElementImpl

public ElementImpl(String tagName,
                   NamespaceImpl ns,
                   OMXMLParserWrapper builder,
                   OMFactory factory)

ElementImpl

public ElementImpl(OMFactory factory)
Method Detail

getNodeType

public short getNodeType()
Specified by:
getNodeType in interface Node

getNodeName

public String getNodeName()
Specified by:
getNodeName in interface Node

getNamespaceURI

public String getNamespaceURI()
Returns the value of the namespace URI.

Specified by:
getNamespaceURI in interface OMElement
Specified by:
getNamespaceURI in interface Node
Overrides:
getNamespaceURI in class NodeImpl
Returns:
the namespace URI of the element or null if the element has no namespace

getType

public int getType()
            throws OMException
Description copied from interface: OMNode
Returns the type of node.

Specified by:
getType in interface OMNode
Returns:
Returns one of OMNode.ELEMENT_NODE, OMNode.TEXT_NODE, OMNode.CDATA_SECTION_NODE, OMNode.COMMENT_NODE, OMNode.DTD_NODE, OMNode.PI_NODE, OMNode.ENTITY_REFERENCE_NODE or OMNode.SPACE_NODE.
Throws:
OMException

setType

public void setType(int nodeType)
             throws OMException
Specified by:
setType in interface OMNodeEx
Throws:
OMException

getTagName

public String getTagName()
Specified by:
getTagName in interface Element

removeAttribute

public void removeAttribute(String name)
                     throws DOMException
Removes an attribute by name.

Specified by:
removeAttribute in interface Element
Parameters:
name - The name of the attribute to remove
Throws:
DOMException
See Also:
Element.removeAttribute(String)

removeAttributeNS

public void removeAttributeNS(String namespaceURI,
                              String localName)
                       throws DOMException
Specified by:
removeAttributeNS in interface Element
Throws:
DOMException

removeAttributeNode

public Attr removeAttributeNode(Attr oldAttr)
                         throws DOMException
Removes the specified attribute node.

Specified by:
removeAttributeNode in interface Element
Throws:
DOMException
See Also:
Element.removeAttributeNode(org.w3c.dom.Attr)

hasAttribute

public boolean hasAttribute(String name)
Specified by:
hasAttribute in interface Element

hasAttributeNS

public boolean hasAttributeNS(String namespaceURI,
                              String localName)
Returns whether the given attribute is available or not.

Specified by:
hasAttributeNS in interface Element
See Also:
Element.hasAttributeNS(String, String)

getAttribute

public String getAttribute(String name)
Looks in the local list of attributes and returns if found. If the local list is null, returns "".

Specified by:
getAttribute in interface Element
See Also:
Element.getAttribute(String)

getAttributeNode

public Attr getAttributeNode(String name)
Retrieves an attribute node by name.

Specified by:
getAttributeNode in interface Element
See Also:
Element.getAttributeNode(String)

getAttributeNS

public String getAttributeNS(String namespaceURI,
                             String localName)
Retrieves an attribute value by local name and namespace URI.

Specified by:
getAttributeNS in interface Element
See Also:
Element.getAttributeNS(String, String)

getAttributeNodeNS

public Attr getAttributeNodeNS(String namespaceURI,
                               String localName)
Retrieves an attribute node by local name and namespace URI.

Specified by:
getAttributeNodeNS in interface Element
See Also:
Element.getAttributeNodeNS(String, String)

setAttributeNode

public Attr setAttributeNode(Attr attr)
                      throws DOMException
Adds a new attribute node.

Specified by:
setAttributeNode in interface Element
Throws:
DOMException
See Also:
Element.setAttributeNode(org.w3c.dom.Attr)

setAttribute

public void setAttribute(String name,
                         String value)
                  throws DOMException
Specified by:
setAttribute in interface Element
Throws:
DOMException

setAttributeNodeNS

public Attr setAttributeNodeNS(Attr attr)
                        throws DOMException
Specified by:
setAttributeNodeNS in interface Element
Throws:
DOMException

setAttributeNS

public void setAttributeNS(String namespaceURI,
                           String qualifiedName,
                           String value)
                    throws DOMException
Adds a new attribute.

Specified by:
setAttributeNS in interface Element
Throws:
DOMException
See Also:
Element.setAttributeNS(String, String, String)

hasAttributes

public boolean hasAttributes()
Returns whether this element contains any attribute or not.

Specified by:
hasAttributes in interface Node
Overrides:
hasAttributes in class NodeImpl

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Specified by:
getElementsByTagNameNS in interface Element

getElementsByTagName

public NodeList getElementsByTagName(String name)
Specified by:
getElementsByTagName in interface Element

addAttribute

public OMAttribute addAttribute(OMAttribute attr)
Description copied from interface: OMElement
Adds an attribute to this element.

If the attribute already has an owner, 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. Otherwise the existing instance specified by the attr parameter is added to the element. In both cases the owner of the added attribute is set to be the particular OMElement.

If there is already an attribute with the same name and namespace URI, it will be replaced and its owner set to null.

In the particular case where the attribute specified by attr is already owned by the element, calling this method has no effect.

Attributes are not stored in any particular order. In particular, there is no guarantee that the added attribute will be returned as the last item by the iterator produced by a subsequent call to OMElement.getAllAttributes().

If the attribute being added has a namespace, but no corresponding namespace declaration is in scope for the element (i.e. declared on the element or one of its ancestors), a new namespace declaration is added to the element. Note that both the namespace prefix and URI are taken into account when looking for an existing namespace declaration.

Specified by:
addAttribute in interface OMElement
Parameters:
attr - The attribute to add.
Returns:
The attribute that was added to the element. As described above this may or may not be the same as attr, depending on whether the attribute specified by this parameter already has an owner or not.
See Also:
(org.apache.axiom.om.OMAttribute)

addAttribute

public OMAttribute addAttribute(String localName,
                                String value,
                                OMNamespace ns)
Description copied from interface: OMElement
Adds an attribute to this element.

If the element already has an attribute with the same local name and namespace URI, then this existing attribute will be removed from the element, i.e. this method will always create a new OMAttribute instance and never update an existing one.

Specified by:
addAttribute in interface OMElement
Parameters:
localName - The local name for the attribute.
value - The string value of the attribute. 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.
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.

declareNamespace

public OMNamespace declareNamespace(OMNamespace namespace)
Allows overriding an existing declaration if the same prefix was used.

Specified by:
declareNamespace in interface OMElement
Parameters:
namespace - The namespace to declare.
Returns:
Returns the namespace parameter passed.
See Also:
(org.apache.axiom.om.OMNamespace)

declareNamespace

public OMNamespace declareNamespace(String uri,
                                    String prefix)
Allows overriding an existing declaration if the same prefix was used.

Specified by:
declareNamespace in interface OMElement
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:
OMElement.declareNamespace(String, String)

declareDefaultNamespace

public OMNamespace declareDefaultNamespace(String uri)
We use "" to store the default namespace of this element. As one can see user can not give "" as the prefix, when he declare a usual namespace.

Specified by:
declareDefaultNamespace in interface OMElement
Parameters:
uri -

getDefaultNamespace

public OMNamespace getDefaultNamespace()
Description copied from interface: OMElement
This will retrieve the default namespace of this element, if available. null returned if none is found.

Specified by:
getDefaultNamespace in interface OMElement

findNamespace

public OMNamespace findNamespace(String uri,
                                 String prefix)
Description copied from interface: OMElement
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.

Specified by:
findNamespace in interface OMElement
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:
OMElement.findNamespace(String, String)

findNamespaceURI

public OMNamespace findNamespaceURI(String prefix)
Description copied from interface: OMElement
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.

Specified by:
findNamespaceURI in interface OMElement

getAttribute

public OMAttribute getAttribute(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
See Also:
(javax.xml.namespace.QName)

getAttributeValue

public String getAttributeValue(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.

getFirstElement

public OMElement getFirstElement()
Returns the first Element node.

Specified by:
getFirstElement in interface OMElement
Returns:
Returns the first child element of the element, or null if none was found.
See Also:
OMElement.getFirstElement()

getNamespace

public OMNamespace getNamespace()
Returns the namespace of this element.

Specified by:
getNamespace in interface OMElement
Returns:
the namespace of this element, or null if the element has no namespace
See Also:
OMElement.getNamespace()

getQName

public QName getQName()
Returns the QName of this element.

Specified by:
getQName in interface OMElement
Returns:
Returns the QName for the element.
See Also:
OMElement.getQName()

getText

public String getText()
Gets all the text children and concatinates them to a single string.

Specified by:
getText in interface OMElement
Returns:
A string representing the concatenation of the child text nodes. If there are no child text nodes, an empty string is returned.
See Also:
OMElement.getText()

getTextAsQName

public QName getTextAsQName()
Description copied from interface: OMElement
OMText can contain its information as a QName as well. This will return the text as a QName

Specified by:
getTextAsQName in interface OMElement

getTrimmedText

public String getTrimmedText()

removeAttribute

public void removeAttribute(OMAttribute attr)
Removes an attribute from the element.

Specified by:
removeAttribute in interface OMElement
See Also:
(org.apache.axiom.om.OMAttribute)

setBuilder

public void setBuilder(OMXMLParserWrapper wrapper)
Sets the OM builder.

Specified by:
setBuilder in interface OMElement
See Also:
(org.apache.axiom.om.OMXMLParserWrapper)

setLocalName

public void setLocalName(String localName)
Sets the local name.

Specified by:
setLocalName in interface OMElement
See Also:
OMElement.setLocalName(String)

setNamespace

public void setNamespace(OMNamespace namespace)
Sets the namespace.

Specified by:
setNamespace in interface OMElement
See Also:
(org.apache.axiom.om.OMNamespace)

setNamespaceWithNoFindInCurrentScope

public void setNamespaceWithNoFindInCurrentScope(OMNamespace namespace)
Description copied from interface: OMElement
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.

Specified by:
setNamespaceWithNoFindInCurrentScope in interface OMElement

setText

public void setText(String text)
Creates a text node with the given value and adds it to the element.

Specified by:
setText in interface OMElement
See Also:
OMElement.setText(String)

setText

public void setText(QName text)
Description copied from interface: OMElement
Set the content of this element to the given QName. If no matching namespace declaration for the QName is in scope, then this method will add one.

Specified by:
setText in interface OMElement
Parameters:
text - the QName value

internalSerialize

public void internalSerialize(XMLStreamWriter writer,
                              boolean cache)
                       throws XMLStreamException
Description copied from interface: OMNodeEx
Serializes the node. Note that this is an internal method that MUST NOT be used outside of Axiom. Please use OMSerializable.serialize(XMLStreamWriter, boolean) instead.

Specified by:
internalSerialize in interface OMNodeEx
cache - indicates if caching should be enabled
Throws:
XMLStreamException

toStringWithConsume

public String toStringWithConsume()
                           throws XMLStreamException
Description copied from interface: OMElement
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.

Specified by:
toStringWithConsume in interface OMElement
Throws:
XMLStreamException

toString

public String toString()
Overridden toString() for ease of debugging.

Specified by:
toString in interface OMElement
Overrides:
toString in class Object
See Also:
Object.toString()

getChildElements

public Iterator getChildElements()
Description copied from interface: OMElement
Returns a filtered list of children - just the elements.

Specified by:
getChildElements in interface OMElement
Returns:
Returns an iterator over the child elements.
See Also:
OMContainer.getChildren(), OMContainer.getChildrenWithName(javax.xml.namespace.QName)

getAllDeclaredNamespaces

public Iterator getAllDeclaredNamespaces()
                                  throws OMException
Description copied from interface: OMElement
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.

Specified by:
getAllDeclaredNamespaces in interface OMElement
Returns:
Returns an iterator over the OMNamespace items declared on the current element.
Throws:
OMException
See Also:
OMElement.getAllDeclaredNamespaces()

getAllAttributes

public Iterator getAllAttributes()
Description copied from interface: OMElement
Returns a list of OMAttributes.

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

Specified by:
getAllAttributes in interface OMElement
Returns:
Returns an Iterator of OMAttribute items associated with the element.
See Also:
OMElement.getAllAttributes()

getLocalName

public String getLocalName()
Returns the local name of this element node

Specified by:
getLocalName in interface OMElement
Specified by:
getLocalName in interface Node
Overrides:
getLocalName in class NodeImpl
Returns:
Returns the local name of the element.
See Also:
Node.getLocalName()

getPrefix

public String getPrefix()
Returns the namespace prefix of this element node

Specified by:
getPrefix in interface Node
Overrides:
getPrefix in class NodeImpl
See Also:
Node.getPrefix()

setOwnerDocument

protected void setOwnerDocument(DocumentImpl document)
Description copied from class: NodeImpl
Sets the owner document.

Overrides:
setOwnerDocument in class NodeImpl
See Also:
(org.apache.axiom.om.impl.dom.DocumentImpl)

resolveQName

public QName resolveQName(String qname)
Description copied from interface: OMElement
Resolves a QName literal in the namespace context defined by this element and produces a corresponding QName object. The implementation uses the algorithm defined by the XML Schema specification. In particular, the namespace for an unprefixed QName is the default namespace (not the null namespace), i.e. QNames are resolved in the same way as element names.

Specified by:
resolveQName in interface OMElement
Parameters:
qname - the QName literal to resolve
Returns:
the QName object, or null if the QName can't be resolved, i.e. if the prefix is not bound in the namespace context of this element

cloneOMElement

public OMElement cloneOMElement()
Creates a clone which belongs to a new document.

Specified by:
cloneOMElement in interface OMElement
Returns:
Returns OMElement.
See Also:
OMElement.cloneOMElement()

setLineNumber

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

getLineNumber

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

cloneNode

public Node cloneNode(boolean deep)
Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class ParentNode

getAttributes

public NamedNodeMap getAttributes()
Returns the set of attributes of this node and the namespace declarations available.

Specified by:
getAttributes in interface Node
Overrides:
getAttributes in class NodeImpl
See Also:
ElementImpl

getNamespaceURI

public String getNamespaceURI(String prefix)
Returns the namespace uri, given the prefix. If it is not found at this element, searches the parent.

Parameters:
prefix -
Returns:
Returns namespace.

removeNamespace

public boolean removeNamespace(String prefix)
Removes a declared namespace given its prefix.

Parameters:
prefix -
Returns:
Returns whether the namespace relevant to the given prefix was removed or not

getNextOMSibling

public OMNode getNextOMSibling()
                        throws OMException
Description copied from class: NodeImpl
Default behavior returns null, overriden in ChildNode.

Specified by:
getNextOMSibling in interface OMNode
Overrides:
getNextOMSibling in class ChildNode
Returns:
Returns the next sibling in document order.
Throws:
OMException

discard

public void discard()
             throws OMException
Description copied from interface: OMNode
Discards a node.

Discard goes to the parser level and if the element is not completely built, then it will be completely skipped at the parser level.

Specified by:
discard in interface OMNode
Overrides:
discard in class ChildNode
Throws:
OMException

setIdAttribute

public void setIdAttribute(String name,
                           boolean isId)
                    throws DOMException
Specified by:
setIdAttribute in interface Element
Throws:
DOMException

setIdAttributeNS

public void setIdAttributeNS(String namespaceURI,
                             String localName,
                             boolean isId)
                      throws DOMException
Specified by:
setIdAttributeNS in interface Element
Throws:
DOMException

setIdAttributeNode

public void setIdAttributeNode(Attr idAttr,
                               boolean isId)
                        throws DOMException
Specified by:
setIdAttributeNode in interface Element
Throws:
DOMException

getSchemaTypeInfo

public TypeInfo getSchemaTypeInfo()
Specified by:
getSchemaTypeInfo in interface Element

buildWithAttachments

public void buildWithAttachments()
Description copied from class: NodeImpl
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 NodeImpl


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