Package org.apache.axiom.om.impl.llom
Class OMElementImpl
java.lang.Object
org.apache.axiom.om.impl.llom.OMSerializableImpl
org.apache.axiom.om.impl.llom.OMNodeImpl
org.apache.axiom.om.impl.llom.OMElementImpl
- All Implemented Interfaces:
org.apache.axiom.om.impl.OMContainerEx,org.apache.axiom.om.impl.OMNodeEx,org.apache.axiom.om.OMConstants,org.apache.axiom.om.OMContainer,org.apache.axiom.om.OMElement,org.apache.axiom.om.OMNode,org.apache.axiom.om.OMSerializable
- Direct Known Subclasses:
OMSourcedElementImpl,SOAPElement
public class OMElementImpl
extends OMNodeImpl
implements org.apache.axiom.om.OMElement, org.apache.axiom.om.OMConstants, org.apache.axiom.om.impl.OMContainerEx
Class OMElementImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMapField attributesstatic final org.apache.axiom.om.OMNamespaceprotected org.apache.axiom.om.OMNodeField firstChildprotected org.apache.axiom.om.OMNodeprotected StringField localNameprotected HashMapField namespacesprotected intField noPrefixNamespaceCounterprotected org.apache.axiom.om.OMNamespaceField nsprotected QNameFields inherited from class org.apache.axiom.om.impl.llom.OMNodeImpl
nextSibling, nodeType, parent, previousSiblingFields inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
builder, done, factoryFields 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_URIFields 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 -
Constructor Summary
ConstructorsConstructorDescriptionOMElementImpl(String localName, org.apache.axiom.om.OMNamespace ns, org.apache.axiom.om.OMContainer parent, org.apache.axiom.om.OMFactory factory) This is the basic constructor for OMElement.OMElementImpl(String localName, org.apache.axiom.om.OMNamespace ns, org.apache.axiom.om.OMContainer parent, org.apache.axiom.om.OMXMLParserWrapper builder, org.apache.axiom.om.OMFactory factory) Constructor OMElementImpl.OMElementImpl(String localName, org.apache.axiom.om.OMNamespace ns, org.apache.axiom.om.OMFactory factory) Constructor OMElementImpl.OMElementImpl(QName qname, org.apache.axiom.om.OMContainer parent, org.apache.axiom.om.OMFactory factory) It is assumed that the QName passed contains, at least, the localName for this element. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.axiom.om.OMAttributeaddAttribute(String attributeName, String value, org.apache.axiom.om.OMNamespace ns) org.apache.axiom.om.OMAttributeaddAttribute(org.apache.axiom.om.OMAttribute attr) Inserts an attribute to this element.voidaddChild(org.apache.axiom.om.OMNode child) Adds child to the element.voidbuild()Parses this node and builds the object structure in memory.voidForces the parser to proceed, if parser has not yet finished with the XML input.voidParses this node and builds the object structure in memory.org.apache.axiom.om.OMElementorg.apache.axiom.om.OMNamespaceWe use "" to store the default namespace of this element.org.apache.axiom.om.OMNamespacedeclareNamespace(String uri, String prefix) Creates a namespace in the current element scope.org.apache.axiom.om.OMNamespacedeclareNamespace(org.apache.axiom.om.OMNamespace namespace) org.apache.axiom.om.OMNodedetach()Removes this information item and its children, from the model completely.voiddiscard()Method discard.org.apache.axiom.om.OMNamespacefindNamespace(String uri, String prefix) Finds a namespace with the given uri and prefix, in the scope of the document.org.apache.axiom.om.OMNamespacefindNamespaceURI(String prefix) Returns a List of OMAttributes.Method getAllDeclaredNamespaces.org.apache.axiom.om.OMAttributegetAttribute(QName qname) Returns a named attribute if present.getAttributeValue(QName qname) Returns a named attribute's value, if present.org.apache.axiom.om.OMXMLParserWrapperMethod getBuilder.Returns a filtered list of children - just the elements.Returns a collection of this element.getChildrenWithLocalName(String localName) getChildrenWithName(QName elementQName) Searches for children with a given QName and returns an iterator to traverse through the OMNodes.org.apache.axiom.om.OMNamespaceorg.apache.axiom.om.OMElementgetFirstChildWithName(QName elementQName) Method getFirstChildWithName.org.apache.axiom.om.OMElementGets first element.org.apache.axiom.om.OMNodeMethod getFirstOMChild.org.apache.axiom.om.OMNodeintMethod getLocalName.org.apache.axiom.om.OMNamespaceorg.apache.axiom.om.OMNodeGets the next sibling.getQName()Method getQName.getText()Selects all the text children and concatenates them to a single string.Returns the concatination string of TRIMMED values of all OMText child nodes of this element.intgetType()Gets the type of node, as this is the super class of all the nodes.getXMLStreamReader(boolean cache) getXMLStreamReader(boolean cache, boolean preserveNamespaceContext) voidinternalSerialize(XMLStreamWriter writer, boolean cache) Serializes the node.protected voidThis method will be called when one of the children becomes complete.voidremoveAttribute(org.apache.axiom.om.OMAttribute attr) Method removeAttribute.resolveQName(String qname) Converts a prefix:local qname string into a proper QName, evaluating it in the OMElement context.voidsetBuilder(org.apache.axiom.om.OMXMLParserWrapper wrapper) Method setBuilder.voidsetFirstChild(org.apache.axiom.om.OMNode firstChild) Method setFirstChild.voidsetLastChild(org.apache.axiom.om.OMNode omNode) voidsetLineNumber(int lineNumber) voidsetLocalName(String localName) Method setLocalName.voidsetNamespace(org.apache.axiom.om.OMNamespace namespace) Method setNamespace.voidsetNamespaceWithNoFindInCurrentScope(org.apache.axiom.om.OMNamespace namespace) voidSets the text of the given element.voidSets the text, as a QName, of the given element.toString()Methods inherited from class org.apache.axiom.om.impl.llom.OMNodeImpl
getNextOMSiblingIfAvailable, getParent, getPreviousOMSibling, importNode, insertSiblingAfter, insertSiblingBefore, internalSerialize, internalSerializeAndConsume, setComplete, setNextOMSibling, setParent, setPreviousOMSibling, setTypeMethods inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
close, getOMFactory, isComplete, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsumeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.axiom.om.OMContainer
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsumeMethods inherited from interface org.apache.axiom.om.impl.OMContainerEx
setCompleteMethods inherited from interface org.apache.axiom.om.OMElement
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsumeMethods inherited from interface org.apache.axiom.om.OMNode
getParent, getPreviousOMSibling, insertSiblingAfter, insertSiblingBeforeMethods inherited from interface org.apache.axiom.om.OMSerializable
close, getOMFactory, isComplete, serialize, serialize, serializeAndConsume
-
Field Details
-
DEFAULT_DEFAULT_NS_OBJECT
public static final org.apache.axiom.om.OMNamespace DEFAULT_DEFAULT_NS_OBJECT -
ns
protected org.apache.axiom.om.OMNamespace nsField ns -
localName
Field localName -
qName
-
firstChild
protected org.apache.axiom.om.OMNode firstChildField firstChild -
namespaces
Field namespaces -
attributes
Field attributes -
noPrefixNamespaceCounter
protected int noPrefixNamespaceCounterField noPrefixNamespaceCounter -
lastChild
protected org.apache.axiom.om.OMNode lastChild
-
-
Constructor Details
-
OMElementImpl
public OMElementImpl(String localName, org.apache.axiom.om.OMNamespace ns, org.apache.axiom.om.OMContainer parent, org.apache.axiom.om.OMXMLParserWrapper builder, org.apache.axiom.om.OMFactory factory) Constructor OMElementImpl. A null namespace indicates that the default namespace in scope is used -
OMElementImpl
public OMElementImpl(String localName, org.apache.axiom.om.OMNamespace ns, org.apache.axiom.om.OMFactory factory) Constructor OMElementImpl. -
OMElementImpl
public OMElementImpl(String localName, org.apache.axiom.om.OMNamespace ns, org.apache.axiom.om.OMContainer parent, org.apache.axiom.om.OMFactory factory) This is the basic constructor for OMElement. All the other constructors depends on this.- Parameters:
localName- - this MUST always be not nullns- - can be nullparent- - this should be an OMContainerfactory- - factory that created this OMElement A null namespace indicates that the default namespace in scope is used
-
OMElementImpl
public OMElementImpl(QName qname, org.apache.axiom.om.OMContainer parent, org.apache.axiom.om.OMFactory factory) throws org.apache.axiom.om.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:
org.apache.axiom.om.OMException
-
-
Method Details
-
addChild
public void addChild(org.apache.axiom.om.OMNode child) Adds child to the element. One can decide whether to append the child or to add to the front of the children list.- Specified by:
addChildin interfaceorg.apache.axiom.om.OMContainer
-
getChildrenWithName
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:
getChildrenWithNamein interfaceorg.apache.axiom.om.OMContainer- Throws:
org.apache.axiom.om.OMException
-
getChildrenWithLocalName
- Specified by:
getChildrenWithLocalNamein interfaceorg.apache.axiom.om.OMContainer
-
getChildrenWithNamespaceURI
- Specified by:
getChildrenWithNamespaceURIin interfaceorg.apache.axiom.om.OMContainer
-
getFirstChildWithName
public org.apache.axiom.om.OMElement getFirstChildWithName(QName elementQName) throws org.apache.axiom.om.OMException Method getFirstChildWithName.- Specified by:
getFirstChildWithNamein interfaceorg.apache.axiom.om.OMContainer- Throws:
org.apache.axiom.om.OMException
-
getNextOMSibling
public org.apache.axiom.om.OMNode getNextOMSibling() throws org.apache.axiom.om.OMExceptionGets the next sibling. This can be an OMAttribute or OMText or OMELement for others.- Specified by:
getNextOMSiblingin interfaceorg.apache.axiom.om.OMNode- Overrides:
getNextOMSiblingin classOMNodeImpl- Returns:
- Returns OMNode.
- Throws:
org.apache.axiom.om.OMException
-
getChildren
Returns a collection of this element. Children can be of types OMElement, OMText.- Specified by:
getChildrenin interfaceorg.apache.axiom.om.OMContainer- Returns:
- Returns children.
-
getChildElements
Returns a filtered list of children - just the elements.- Specified by:
getChildElementsin interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns an iterator of the child elements.
-
declareNamespace
Creates a namespace in the current element scope.- Specified by:
declareNamespacein interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns namespace.
-
declareDefaultNamespace
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:
declareDefaultNamespacein interfaceorg.apache.axiom.om.OMElement- Parameters:
uri-
-
getDefaultNamespace
public org.apache.axiom.om.OMNamespace getDefaultNamespace()- Specified by:
getDefaultNamespacein interfaceorg.apache.axiom.om.OMElement
-
declareNamespace
public org.apache.axiom.om.OMNamespace declareNamespace(org.apache.axiom.om.OMNamespace namespace) - Specified by:
declareNamespacein interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns namespace.
-
findNamespace
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:
findNamespacein interfaceorg.apache.axiom.om.OMElement
-
findNamespaceURI
- Specified by:
findNamespaceURIin interfaceorg.apache.axiom.om.OMElement
-
getAllDeclaredNamespaces
Method getAllDeclaredNamespaces.- Specified by:
getAllDeclaredNamespacesin interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns Iterator.
-
getAllAttributes
Returns a List of OMAttributes.- Specified by:
getAllAttributesin interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns iterator.
-
getAttribute
Returns a named attribute if present.- Specified by:
getAttributein interfaceorg.apache.axiom.om.OMElement- Parameters:
qname- the qualified name to search for- Returns:
- Returns an OMAttribute with the given name if found, or null
-
getAttributeValue
Returns a named attribute's value, if present.- Specified by:
getAttributeValuein interfaceorg.apache.axiom.om.OMElement- Parameters:
qname- the qualified name to search for- Returns:
- Returns a String containing the attribute value, or null.
-
addAttribute
public org.apache.axiom.om.OMAttribute addAttribute(org.apache.axiom.om.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 particularOMElement.- Specified by:
addAttributein interfaceorg.apache.axiom.om.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:
-
removeAttribute
public void removeAttribute(org.apache.axiom.om.OMAttribute attr) Method removeAttribute.- Specified by:
removeAttributein interfaceorg.apache.axiom.om.OMElement
-
addAttribute
public org.apache.axiom.om.OMAttribute addAttribute(String attributeName, String value, org.apache.axiom.om.OMNamespace ns) - Specified by:
addAttributein interfaceorg.apache.axiom.om.OMElement
-
setBuilder
public void setBuilder(org.apache.axiom.om.OMXMLParserWrapper wrapper) Method setBuilder.- Specified by:
setBuilderin interfaceorg.apache.axiom.om.OMElement
-
getBuilder
public org.apache.axiom.om.OMXMLParserWrapper getBuilder()Method getBuilder.- Specified by:
getBuilderin interfaceorg.apache.axiom.om.OMContainer- Returns:
- Returns OMXMLParserWrapper.
-
buildNext
public void buildNext()Forces the parser to proceed, if parser has not yet finished with the XML input.- Specified by:
buildNextin interfaceorg.apache.axiom.om.OMContainer
-
getFirstOMChild
public org.apache.axiom.om.OMNode getFirstOMChild()Method getFirstOMChild.- Specified by:
getFirstOMChildin interfaceorg.apache.axiom.om.OMContainer- Returns:
- Returns child.
-
getFirstOMChildIfAvailable
public org.apache.axiom.om.OMNode getFirstOMChildIfAvailable()- Specified by:
getFirstOMChildIfAvailablein interfaceorg.apache.axiom.om.impl.OMContainerEx
-
setFirstChild
public void setFirstChild(org.apache.axiom.om.OMNode firstChild) Method setFirstChild.- Specified by:
setFirstChildin interfaceorg.apache.axiom.om.impl.OMContainerEx- Specified by:
setFirstChildin interfaceorg.apache.axiom.om.OMElement
-
setLastChild
public void setLastChild(org.apache.axiom.om.OMNode omNode) - Specified by:
setLastChildin interfaceorg.apache.axiom.om.impl.OMContainerEx
-
detach
public org.apache.axiom.om.OMNode detach() throws org.apache.axiom.om.OMExceptionRemoves this information item and its children, from the model completely.- Specified by:
detachin interfaceorg.apache.axiom.om.OMNode- Overrides:
detachin classOMNodeImpl- Throws:
org.apache.axiom.om.OMException
-
getType
public int getType()Gets the type of node, as this is the super class of all the nodes.- Specified by:
getTypein interfaceorg.apache.axiom.om.OMNode- Overrides:
getTypein classOMNodeImpl- Returns:
- Returns the type of node as indicated by
OMNodeImpl.setType(int) - See Also:
-
build
public void build() throws org.apache.axiom.om.OMExceptionDescription copied from class:OMSerializableImplParses this node and builds the object structure in memory. However a node, created programmatically, will have done set to true by default and this will cause populateyourself not to work properly!- Specified by:
buildin interfaceorg.apache.axiom.om.OMSerializable- Overrides:
buildin classOMSerializableImpl- Throws:
org.apache.axiom.om.OMException
-
getXMLStreamReader
- Specified by:
getXMLStreamReaderin interfaceorg.apache.axiom.om.OMContainer
-
getXMLStreamReaderWithoutCaching
- Specified by:
getXMLStreamReaderWithoutCachingin interfaceorg.apache.axiom.om.OMContainer
-
getXMLStreamReader
- Specified by:
getXMLStreamReaderin interfaceorg.apache.axiom.om.OMContainer
-
getXMLStreamReader
- Specified by:
getXMLStreamReaderin interfaceorg.apache.axiom.om.OMElement
-
setText
Sets the text of the given element. caution - This method will wipe out all the text elements (and hence any mixed content) before setting the text.- Specified by:
setTextin interfaceorg.apache.axiom.om.OMElement
-
setText
Sets the text, as a QName, of the given element. caution - This method will wipe out all the text elements (and hence any mixed content) before setting the text.- Specified by:
setTextin interfaceorg.apache.axiom.om.OMElement
-
getText
Selects all the text children and concatenates them to a single string.- Specified by:
getTextin interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns String.
-
getTextAsQName
- Specified by:
getTextAsQNamein interfaceorg.apache.axiom.om.OMElement
-
getTrimmedText
Returns the concatination string of TRIMMED values of all OMText child nodes of this element. This is included purely to improve usability. -
internalSerialize
Description copied from class:OMSerializableImplSerializes the node.- Specified by:
internalSerializein interfaceorg.apache.axiom.om.impl.OMNodeEx- Specified by:
internalSerializein classOMSerializableImpl- Parameters:
writer-- Throws:
XMLStreamException
-
getFirstElement
public org.apache.axiom.om.OMElement getFirstElement()Gets first element.- Specified by:
getFirstElementin interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns element.
-
getLocalName
Method getLocalName.- Specified by:
getLocalNamein interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns local name.
-
setLocalName
Method setLocalName.- Specified by:
setLocalNamein interfaceorg.apache.axiom.om.OMElement
-
getNamespace
public org.apache.axiom.om.OMNamespace getNamespace()- Specified by:
getNamespacein interfaceorg.apache.axiom.om.OMElement
-
setNamespace
public void setNamespace(org.apache.axiom.om.OMNamespace namespace) Method setNamespace.- Specified by:
setNamespacein interfaceorg.apache.axiom.om.OMElement
-
setNamespaceWithNoFindInCurrentScope
public void setNamespaceWithNoFindInCurrentScope(org.apache.axiom.om.OMNamespace namespace) - Specified by:
setNamespaceWithNoFindInCurrentScopein interfaceorg.apache.axiom.om.OMElement
-
getQName
Method getQName.- Specified by:
getQNamein interfaceorg.apache.axiom.om.OMElement- Returns:
- Returns QName.
-
toStringWithConsume
- Specified by:
toStringWithConsumein interfaceorg.apache.axiom.om.OMElement- Throws:
XMLStreamException
-
toString
-
discard
public void discard() throws org.apache.axiom.om.OMExceptionMethod discard.- Specified by:
discardin interfaceorg.apache.axiom.om.OMNode- Throws:
org.apache.axiom.om.OMException
-
resolveQName
Converts a prefix:local qname string into a proper QName, evaluating it in the OMElement context. Unprefixed qnames resolve to the local namespace.- Specified by:
resolveQNamein interfaceorg.apache.axiom.om.OMElement- Parameters:
qname- prefixed qname string to resolve- Returns:
- Returns null for any failure to extract a qname.
-
cloneOMElement
public org.apache.axiom.om.OMElement cloneOMElement()- Specified by:
cloneOMElementin interfaceorg.apache.axiom.om.OMElement
-
setLineNumber
public void setLineNumber(int lineNumber) - Specified by:
setLineNumberin interfaceorg.apache.axiom.om.OMElement
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceorg.apache.axiom.om.OMElement
-
buildWithAttachments
public void buildWithAttachments()Description copied from class:OMNodeImplParses 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:
buildWithAttachmentsin interfaceorg.apache.axiom.om.OMNode- Overrides:
buildWithAttachmentsin classOMNodeImpl
-
notifyChildComplete
protected void notifyChildComplete()This method will be called when one of the children becomes complete.
-