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

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
              extended by org.apache.axiom.om.impl.llom.OMSourcedElementImpl
All Implemented Interfaces:
OMContainerEx, OMNodeEx, OMConstants, OMContainer, OMElement, OMNode, OMSerializable, OMSourcedElement
Direct Known Subclasses:
SOAPHeaderBlockImpl

public class OMSourcedElementImpl
extends OMElementImpl
implements OMSourcedElement

Element backed by an arbitrary data source. When necessary, this element will be expanded by creating a parser from the data source.

Whenever methods are added to the base OMElementImpl class the corresponding methods must be added to this class (there's a unit test to verify that this has been done, just to make sure nothing gets accidentally broken). If the method only requires the element name and/or namespace information, the base class method can be called directly. Otherwise, the element must be expanded into a full OM tree (by calling the forceExpand() method) before the base class method is called. This will typically involve a heavy overhead penalty, so should be avoided if possible.


Field Summary
 
Fields inherited from class org.apache.axiom.om.impl.llom.OMElementImpl
attributes, DEFAULT_DEFAULT_NS_OBJECT, firstChild, lastChild, localName, namespaces, noPrefixNamespaceCounter, ns, qName
 
Fields inherited from class org.apache.axiom.om.impl.llom.OMNodeImpl
nextSibling, nodeType, parent, previousSibling
 
Fields inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
builder, done, factory
 
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
OMSourcedElementImpl(QName qName, OMFactory factory, OMDataSource source)
          Constructor that takes a QName instead of the local name and the namespace seperately
OMSourcedElementImpl(String localName, OMNamespace ns, OMContainer parent, OMFactory factory)
           
OMSourcedElementImpl(String localName, OMNamespace ns, OMContainer parent, OMXMLParserWrapper builder, OMFactory factory)
           
OMSourcedElementImpl(String localName, OMNamespace ns, OMFactory factory)
           
OMSourcedElementImpl(String localName, OMNamespace ns, OMFactory factory, OMDataSource source)
          Constructor.
 
Method Summary
 OMAttribute addAttribute(OMAttribute attr)
          Inserts an attribute to this element.
 OMAttribute addAttribute(String attributeName, String value, OMNamespace namespace)
          Adds an attribute to this element.
 void addChild(OMNode omNode)
          Adds child to the element.
 void build()
          Parses this node and builds the object structure in memory.
 void buildNext()
          Forces the parser to proceed, if parser has not yet finished with the XML input.
 void buildWithAttachments()
          Parses this node and builds the object structure in memory.
 OMElement cloneOMElement()
          Clones this element.
 OMNamespace declareDefaultNamespace(String uri)
          We use "" to store the default namespace of this element.
 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.
 OMNode detach()
          Removes this information item and its children, from the model completely.
 void discard()
          Method discard.
 OMNamespace findNamespace(String uri, String prefix)
          Finds a namespace with the given uri and prefix, in the scope of the document.
 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()
          Method getAllDeclaredNamespaces.
 OMAttribute getAttribute(QName qname)
          Returns a named attribute if present.
 String getAttributeValue(QName qname)
          Returns a named attribute's value, if present.
 OMXMLParserWrapper getBuilder()
          Method getBuilder.
 Iterator getChildElements()
          Returns a filtered list of children - just the elements.
 Iterator getChildren()
          Returns a collection of this element.
 Iterator getChildrenWithLocalName(String localName)
          Returns an iterator for child nodes matching the local name.
 Iterator getChildrenWithName(QName elementQName)
          Searches for children with a given QName and returns an iterator to traverse through the OMNodes.
 Iterator getChildrenWithNamespaceURI(String uri)
          Returns an iterator for child nodes matching the namespace uri.
 OMDataSource getDataSource()
          Provide access to the data source encapsulated in OMSourcedElement.
 OMNamespace getDefaultNamespace()
          This will retrieve the default namespace of this element, if available. null returned if none is found.
 OMElement getFirstChildWithName(QName elementQName)
          Method getFirstChildWithName.
 OMElement getFirstElement()
          Gets first element.
 OMNode getFirstOMChild()
          Method getFirstOMChild.
 OMNode getFirstOMChildIfAvailable()
          Get the first child if it is available.
 int getLineNumber()
           
 String getLocalName()
          Method getLocalName.
 OMNamespace getNamespace()
          Get the namespace this element is part of.
 String getNamespaceURI()
          Get the namespace URI of the element.
 OMNode getNextOMSibling()
          Gets the next sibling.
 OMNode getNextOMSiblingIfAvailable()
          Get the next sibling if it is available.
 QName getQName()
          Method getQName.
 String getText()
          Selects all the text children and concatenates them to a single string.
 QName getTextAsQName()
          OMText can contain its information as a QName as well.
 String getTrimmedText()
          Returns the concatination string of TRIMMED values of all OMText child nodes of this element.
 int getType()
          Gets the type of node, as this is the super class of all the nodes.
 XMLStreamReader getXMLStreamReader()
          Get a pull parser representation of this element with caching enabled.
 XMLStreamReader getXMLStreamReader(boolean cache)
          Get a pull parser representation of this element.
 XMLStreamReader getXMLStreamReaderWithoutCaching()
          Get a pull parser representation of this element with caching disabled.
 void internalSerialize(XMLStreamWriter writer, boolean cache)
          Serializes the node.
 boolean isComplete()
          Indicates whether parser has parsed this information item completely or not.
 boolean isExpanded()
          Check if element has been expanded into tree.
protected  void notifyChildComplete()
          This method will be called when one of the children becomes complete.
 void removeAttribute(OMAttribute attr)
          Method removeAttribute.
 QName resolveQName(String qname)
          Resolves a QName literal in the namespace context defined by this element and produces a corresponding QName object.
 void serialize(OutputStream output)
          Serializes the node with caching.
 void serialize(OutputStream output, OMOutputFormat format)
          Serializes the node with caching.
 void serialize(Writer writer)
          Serializes the node with caching.
 void serialize(Writer writer, OMOutputFormat format)
          Serializes the node with caching.
 void serialize(XMLStreamWriter xmlWriter)
          Serializes the information item with caching.
 void serializeAndConsume(OutputStream output)
          Serializes the node without caching.
 void serializeAndConsume(OutputStream output, OMOutputFormat format)
          Serializes the node without caching.
 void serializeAndConsume(Writer writer)
          Serializes the node without caching.
 void serializeAndConsume(Writer writer, OMOutputFormat format)
          Serializes the node without caching.
 void serializeAndConsume(XMLStreamWriter xmlWriter)
          Serializes the information item without caching.
 void setBuilder(OMXMLParserWrapper wrapper)
          Method setBuilder.
 void setComplete(boolean value)
          setComplete override The OMSourcedElement has its own isolated builder/reader during the expansion process.
 OMDataSource setDataSource(OMDataSource dataSource)
          setOMDataSource
 void setFirstChild(OMNode node)
          Method setFirstChild.
 void setLastChild(OMNode omNode)
          forcefully set the last element in this parent element
 void setLineNumber(int lineNumber)
           
 void setLocalName(String localName)
          Method setLocalName.
 void setNamespace(OMNamespace namespace)
          Method setNamespace.
 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(QName text)
          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.
 void setText(String text)
          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.
 String toString()
          This is a convenience method only.
 String toStringWithConsume()
          This is a convenience method only.
 
Methods inherited from class org.apache.axiom.om.impl.llom.OMNodeImpl
getParent, getPreviousOMSibling, importNode, insertSiblingAfter, insertSiblingBefore, internalSerialize, internalSerializeAndConsume, setNextOMSibling, setParent, setPreviousOMSibling, setType
 
Methods inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
close, getOMFactory, serialize
 
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.OMNode
getParent, getPreviousOMSibling, insertSiblingAfter, insertSiblingBefore
 
Methods inherited from interface org.apache.axiom.om.OMSerializable
close, getOMFactory, serialize
 

Constructor Detail

OMSourcedElementImpl

public OMSourcedElementImpl(String localName,
                            OMNamespace ns,
                            OMFactory factory,
                            OMDataSource source)
Constructor.

Parameters:
localName -
ns -
factory -
source -

OMSourcedElementImpl

public OMSourcedElementImpl(QName qName,
                            OMFactory factory,
                            OMDataSource source)
Constructor that takes a QName instead of the local name and the namespace seperately

Parameters:
qName -
factory -
source -

OMSourcedElementImpl

public OMSourcedElementImpl(String localName,
                            OMNamespace ns,
                            OMContainer parent,
                            OMFactory factory)

OMSourcedElementImpl

public OMSourcedElementImpl(String localName,
                            OMNamespace ns,
                            OMContainer parent,
                            OMXMLParserWrapper builder,
                            OMFactory factory)

OMSourcedElementImpl

public OMSourcedElementImpl(String localName,
                            OMNamespace ns,
                            OMFactory factory)
Method Detail

isExpanded

public boolean isExpanded()
Check if element has been expanded into tree.

Specified by:
isExpanded in interface OMSourcedElement
Returns:
true if expanded, false if not

getChildElements

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

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

declareNamespace

public OMNamespace declareNamespace(String uri,
                                    String prefix)
Description copied from class: OMElementImpl
Creates a namespace in the current element scope.

Specified by:
declareNamespace in interface OMElement
Overrides:
declareNamespace in class OMElementImpl
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 namespace.
See Also:
OMElement.declareNamespace(OMNamespace), OMElement.findNamespace(String, String), OMElement.getAllDeclaredNamespaces()

declareDefaultNamespace

public OMNamespace declareDefaultNamespace(String uri)
Description copied from class: OMElementImpl
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
Overrides:
declareDefaultNamespace in class OMElementImpl

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
Overrides:
getDefaultNamespace in class OMElementImpl

declareNamespace

public OMNamespace declareNamespace(OMNamespace namespace)
Description copied from interface: OMElement
Declares a namespace with the element as its scope.

Specified by:
declareNamespace in interface OMElement
Overrides:
declareNamespace in class OMElementImpl
Parameters:
namespace - The namespace to declare.
Returns:
Returns namespace.
See Also:
OMElement.declareNamespace(String, String), OMElement.findNamespace(String, String), OMElement.getAllDeclaredNamespaces()

findNamespace

public OMNamespace findNamespace(String uri,
                                 String prefix)
Description copied from class: OMElementImpl
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
Overrides:
findNamespace in class OMElementImpl
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.declareNamespace(String, String), OMElement.declareNamespace(OMNamespace), OMElement.getAllDeclaredNamespaces()

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
Overrides:
findNamespaceURI in class OMElementImpl

getAllDeclaredNamespaces

public Iterator getAllDeclaredNamespaces()
                                  throws OMException
Description copied from class: OMElementImpl
Method getAllDeclaredNamespaces.

Specified by:
getAllDeclaredNamespaces in interface OMElement
Overrides:
getAllDeclaredNamespaces in class OMElementImpl
Returns:
Returns Iterator.
Throws:
OMException
See Also:
OMElement.findNamespace(String, String), OMElement.declareNamespace(String, String), OMElement.declareNamespace(OMNamespace)

getAllAttributes

public Iterator getAllAttributes()
Description copied from class: OMElementImpl
Returns a List of OMAttributes.

Specified by:
getAllAttributes in interface OMElement
Overrides:
getAllAttributes in class OMElementImpl
Returns:
Returns iterator.
See Also:
OMElement.getAttribute(javax.xml.namespace.QName), OMElement.addAttribute(OMAttribute), OMElement.addAttribute(String, String, OMNamespace)

getAttribute

public OMAttribute getAttribute(QName qname)
Description copied from class: OMElementImpl
Returns a named attribute if present.

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

getAttributeValue

public String getAttributeValue(QName qname)
Description copied from class: OMElementImpl
Returns a named attribute's value, if present.

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

addAttribute

public OMAttribute addAttribute(OMAttribute attr)
Description copied from class: OMElementImpl
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
Overrides:
addAttribute in class OMElementImpl
Parameters:
attr - The attribute to add.
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)

addAttribute

public OMAttribute addAttribute(String attributeName,
                                String value,
                                OMNamespace namespace)
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
Overrides:
addAttribute in class OMElementImpl
Parameters:
attributeName - 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.
namespace - 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

public void removeAttribute(OMAttribute attr)
Description copied from class: OMElementImpl
Method removeAttribute.

Specified by:
removeAttribute in interface OMElement
Overrides:
removeAttribute in class OMElementImpl

setBuilder

public void setBuilder(OMXMLParserWrapper wrapper)
Description copied from class: OMElementImpl
Method setBuilder.

Specified by:
setBuilder in interface OMElement
Overrides:
setBuilder in class OMElementImpl

getBuilder

public OMXMLParserWrapper getBuilder()
Description copied from class: OMElementImpl
Method getBuilder.

Specified by:
getBuilder in interface OMContainer
Overrides:
getBuilder in class OMElementImpl
Returns:
Returns OMXMLParserWrapper.

setFirstChild

public void setFirstChild(OMNode node)
Description copied from class: OMElementImpl
Method setFirstChild.

Specified by:
setFirstChild in interface OMContainerEx
Specified by:
setFirstChild in interface OMElement
Overrides:
setFirstChild in class OMElementImpl

setLastChild

public void setLastChild(OMNode omNode)
Description copied from interface: OMContainerEx
forcefully set the last element in this parent element

Specified by:
setLastChild in interface OMContainerEx
Overrides:
setLastChild in class OMElementImpl

getFirstElement

public OMElement getFirstElement()
Description copied from class: OMElementImpl
Gets first element.

Specified by:
getFirstElement in interface OMElement
Overrides:
getFirstElement in class OMElementImpl
Returns:
Returns element.

getXMLStreamReader

public XMLStreamReader getXMLStreamReader(boolean cache)
Description copied from interface: OMContainer
Get a pull parser representation of this element. This methods creates an XMLStreamReader instance that produces a sequence of StAX events for this element and its content. The sequence of events is independent of the state of this element and the value of the cache parameter, but the side effects of calling this method and consuming the reader are different:

State cache Side effects
The element is fully built (or was created programmatically). true No side effects. The reader will synthesize StAX events from the object model.
false
The element is partially built, i.e. deferred parsing is taking place. true When a StAX event is requested from the reader, it will built the information item (if necessary) and synthesize the StAX event. If the caller completely consumes the reader, the element will be completely built. Otherwise it will be partially built.
false The reader will delegate to the underlying parser starting from the event corresponding to the last information item that has been built. In other words, after synthesizing a number of events, the reader will switch to delegation mode. An attempt to access the object model afterwards will result in an error.

To free any resources associated with the returned reader, the caller MUST invoke the XMLStreamReader.close() method.

The returned reader MAY implement the extension defined by DataHandlerReader and any binary content will be reported using this extension. More precisely, if the object model contains an OMText instance with OMText.isBinary() returning true (or would contain such an instance after it has been fully built), then its data will always be exposed through this extension.

The caller MUST NOT make any other assumption about the returned reader, in particular about its runtime type.

Note (non normative): For various reasons, existing code based on Axiom versions prior to 1.2.9 makes assumptions on the returned reader that should no longer be considered valid:

Code making any of these assumptions should be fixed, so that only XMLStreamReader and DataHandlerReader are used (and if necessary, XOPEncodingStreamReader).

Specified by:
getXMLStreamReader in interface OMContainer
Overrides:
getXMLStreamReader in class OMElementImpl
Parameters:
cache - indicates if caching should be enabled
Returns:
an XMLStreamReader representation of this element

getXMLStreamReader

public XMLStreamReader getXMLStreamReader()
Description copied from interface: OMContainer
Get a pull parser representation of this element with caching enabled. This method has the same effect as OMContainer.getXMLStreamReader(boolean) with cache set to true.

Specified by:
getXMLStreamReader in interface OMContainer
Overrides:
getXMLStreamReader in class OMElementImpl
Returns:
an XMLStreamReader representation of this element

getXMLStreamReaderWithoutCaching

public XMLStreamReader getXMLStreamReaderWithoutCaching()
Description copied from interface: OMContainer
Get a pull parser representation of this element with caching disabled. This method has the same effect as OMContainer.getXMLStreamReader(boolean) with cache set to false.

Specified by:
getXMLStreamReaderWithoutCaching in interface OMContainer
Overrides:
getXMLStreamReaderWithoutCaching in class OMElementImpl
Returns:
an XMLStreamReader representation of this element

setText

public void setText(String text)
Description copied from class: OMElementImpl
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:
setText in interface OMElement
Overrides:
setText in class OMElementImpl

setText

public void setText(QName text)
Description copied from class: OMElementImpl
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:
setText in interface OMElement
Overrides:
setText in class OMElementImpl
Parameters:
text - the QName value

getText

public String getText()
Description copied from class: OMElementImpl
Selects all the text children and concatenates them to a single string.

Specified by:
getText in interface OMElement
Overrides:
getText in class OMElementImpl
Returns:
Returns String.

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
Overrides:
getTextAsQName in class OMElementImpl

getLocalName

public String getLocalName()
Description copied from class: OMElementImpl
Method getLocalName.

Specified by:
getLocalName in interface OMElement
Overrides:
getLocalName in class OMElementImpl
Returns:
Returns local name.

setLocalName

public void setLocalName(String localName)
Description copied from class: OMElementImpl
Method setLocalName.

Specified by:
setLocalName in interface OMElement
Overrides:
setLocalName in class OMElementImpl

getNamespace

public OMNamespace getNamespace()
                         throws OMException
Description copied from interface: OMElement
Get the namespace this element is part of.

Specified by:
getNamespace in interface OMElement
Overrides:
getNamespace in class OMElementImpl
Returns:
the namespace of this element, or null if the element has no namespace
Throws:
OMException

getNamespaceURI

public String getNamespaceURI()
Description copied from interface: OMElement
Get the namespace URI of the element. Note that the contract of this method is identical to DOM's Node.getNamespaceURI() (when called on an Element).

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

setNamespace

public void setNamespace(OMNamespace namespace)
Description copied from class: OMElementImpl
Method setNamespace.

Specified by:
setNamespace in interface OMElement
Overrides:
setNamespace in class OMElementImpl

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
Overrides:
setNamespaceWithNoFindInCurrentScope in class OMElementImpl

getQName

public QName getQName()
Description copied from class: OMElementImpl
Method getQName.

Specified by:
getQName in interface OMElement
Overrides:
getQName in class OMElementImpl
Returns:
Returns QName.

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
Overrides:
toStringWithConsume in class OMElementImpl
Throws:
XMLStreamException

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
Overrides:
resolveQName in class OMElementImpl
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()
Description copied from interface: OMElement
Clones this element. Since both elements are build compleletely, you will lose the differed building capability.

Specified by:
cloneOMElement in interface OMElement
Overrides:
cloneOMElement in class OMElementImpl
Returns:
Returns OMElement.

setLineNumber

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

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface OMElement
Overrides:
getLineNumber in class OMElementImpl

discard

public void discard()
             throws OMException
Description copied from class: OMElementImpl
Method discard.

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

getType

public int getType()
Description copied from class: OMElementImpl
Gets the type of node, as this is the super class of all the nodes.

Specified by:
getType in interface OMNode
Overrides:
getType in class OMElementImpl
Returns:
Returns the type of node as indicated by OMNodeImpl.setType(int)
See Also:
OMNodeImpl.setType(int)

internalSerialize

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

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

serialize

public void serialize(XMLStreamWriter xmlWriter)
               throws XMLStreamException
Description copied from interface: OMSerializable
Serializes the information item with caching. This method has the same effect as OMSerializable.serialize(XMLStreamWriter, boolean) with cache set to true.

Specified by:
serialize in interface OMSerializable
Overrides:
serialize in class OMSerializableImpl
Throws:
XMLStreamException

serialize

public void serialize(OutputStream output)
               throws XMLStreamException
Description copied from interface: OMElement
Serializes the node with caching.

Specified by:
serialize in interface OMContainer
Specified by:
serialize in interface OMElement
Specified by:
serialize in interface OMNode
Overrides:
serialize in class OMSerializableImpl
Throws:
XMLStreamException

serialize

public void serialize(Writer writer)
               throws XMLStreamException
Description copied from interface: OMElement
Serializes the node with caching.

Specified by:
serialize in interface OMContainer
Specified by:
serialize in interface OMElement
Specified by:
serialize in interface OMNode
Overrides:
serialize in class OMSerializableImpl
Throws:
XMLStreamException

serialize

public void serialize(OutputStream output,
                      OMOutputFormat format)
               throws XMLStreamException
Description copied from interface: OMElement
Serializes the node with caching.

Specified by:
serialize in interface OMContainer
Specified by:
serialize in interface OMElement
Specified by:
serialize in interface OMNode
Overrides:
serialize in class OMSerializableImpl
Throws:
XMLStreamException

serialize

public void serialize(Writer writer,
                      OMOutputFormat format)
               throws XMLStreamException
Description copied from interface: OMElement
Serializes the node with caching.

Specified by:
serialize in interface OMContainer
Specified by:
serialize in interface OMElement
Specified by:
serialize in interface OMNode
Overrides:
serialize in class OMSerializableImpl
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(XMLStreamWriter xmlWriter)
                         throws XMLStreamException
Description copied from interface: OMSerializable
Serializes the information item without caching. This method has the same effect as OMSerializable.serialize(XMLStreamWriter, boolean) with cache set to false.

Specified by:
serializeAndConsume in interface OMSerializable
Overrides:
serializeAndConsume in class OMSerializableImpl
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(OutputStream output)
                         throws XMLStreamException
Description copied from interface: OMElement
Serializes the node without caching.

Specified by:
serializeAndConsume in interface OMContainer
Specified by:
serializeAndConsume in interface OMElement
Specified by:
serializeAndConsume in interface OMNode
Overrides:
serializeAndConsume in class OMSerializableImpl
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(Writer writer)
                         throws XMLStreamException
Description copied from interface: OMElement
Serializes the node without caching.

Specified by:
serializeAndConsume in interface OMContainer
Specified by:
serializeAndConsume in interface OMElement
Specified by:
serializeAndConsume in interface OMNode
Overrides:
serializeAndConsume in class OMSerializableImpl
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(OutputStream output,
                                OMOutputFormat format)
                         throws XMLStreamException
Description copied from interface: OMElement
Serializes the node without caching.

Specified by:
serializeAndConsume in interface OMContainer
Specified by:
serializeAndConsume in interface OMElement
Specified by:
serializeAndConsume in interface OMNode
Overrides:
serializeAndConsume in class OMSerializableImpl
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(Writer writer,
                                OMOutputFormat format)
                         throws XMLStreamException
Description copied from interface: OMElement
Serializes the node without caching.

Specified by:
serializeAndConsume in interface OMContainer
Specified by:
serializeAndConsume in interface OMElement
Specified by:
serializeAndConsume in interface OMNode
Overrides:
serializeAndConsume in class OMSerializableImpl
Throws:
XMLStreamException

addChild

public void addChild(OMNode omNode)
Description copied from class: OMElementImpl
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:
addChild in interface OMContainer
Overrides:
addChild in class OMElementImpl

getChildrenWithName

public Iterator getChildrenWithName(QName elementQName)
Description copied from class: OMElementImpl
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
Overrides:
getChildrenWithName in class OMElementImpl
Parameters:
elementQName - The QName specifying namespace and local name to match.
Returns:
Returns an iterator of OMElement items that match the given QName

getChildrenWithLocalName

public Iterator getChildrenWithLocalName(String localName)
Description copied from interface: OMContainer
Returns an iterator for child nodes matching the local name.

Specified by:
getChildrenWithLocalName in interface OMContainer
Overrides:
getChildrenWithLocalName in class OMElementImpl
Returns:
Returns an iterator of OMElement items that match the given localName

getChildrenWithNamespaceURI

public Iterator getChildrenWithNamespaceURI(String uri)
Description copied from interface: OMContainer
Returns an iterator for child nodes matching the namespace uri.

Specified by:
getChildrenWithNamespaceURI in interface OMContainer
Overrides:
getChildrenWithNamespaceURI in class OMElementImpl
Returns:
Returns an iterator of OMElement items that match the given uri

getFirstChildWithName

public OMElement getFirstChildWithName(QName elementQName)
                                throws OMException
Description copied from class: OMElementImpl
Method getFirstChildWithName.

Specified by:
getFirstChildWithName in interface OMContainer
Overrides:
getFirstChildWithName in class OMElementImpl
Parameters:
elementQName - The QName to use for matching.
Returns:
The first child element in document order that matches the qname criteria, or null if none is found.
Throws:
OMException - If an error occurs during deferred parsing.
See Also:
OMContainer.getChildrenWithName(QName)

getChildren

public Iterator getChildren()
Description copied from class: OMElementImpl
Returns a collection of this element. Children can be of types OMElement, OMText.

Specified by:
getChildren in interface OMContainer
Overrides:
getChildren in class OMElementImpl
Returns:
Returns children.
See Also:
OMContainer.getFirstChildWithName(javax.xml.namespace.QName), OMContainer.getChildrenWithName(javax.xml.namespace.QName)

getFirstOMChild

public OMNode getFirstOMChild()
Description copied from class: OMElementImpl
Method getFirstOMChild.

Specified by:
getFirstOMChild in interface OMContainer
Overrides:
getFirstOMChild in class OMElementImpl
Returns:
Returns child.

getFirstOMChildIfAvailable

public OMNode getFirstOMChildIfAvailable()
Description copied from interface: OMContainerEx
Get the first child if it is available. The child is available if it is complete or if the builder has started building the node. In the latter case, OMSerializable.isComplete() may return false when called on the child. In contrast to OMContainer.getFirstOMChild(), this method will never modify the state of the underlying parser.

Specified by:
getFirstOMChildIfAvailable in interface OMContainerEx
Overrides:
getFirstOMChildIfAvailable in class OMElementImpl
Returns:
the first child or null if the container has no children or the builder has not yet started to build the first child

buildNext

public void buildNext()
Description copied from class: OMElementImpl
Forces the parser to proceed, if parser has not yet finished with the XML input.

Specified by:
buildNext in interface OMContainer
Overrides:
buildNext in class OMElementImpl

detach

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

Specified by:
detach in interface OMNode
Overrides:
detach in class OMElementImpl
Returns:
The detached node. This is always the instance on which this method is invoked.
Throws:
OMException - If a node is not complete, the detach can trigger further parsing, which may cause an exception.

getNextOMSibling

public OMNode getNextOMSibling()
                        throws OMException
Description copied from class: OMElementImpl
Gets the next sibling. This can be an OMAttribute or OMText or OMELement for others.

Specified by:
getNextOMSibling in interface OMNode
Overrides:
getNextOMSibling in class OMElementImpl
Returns:
Returns OMNode.
Throws:
OMException

getNextOMSiblingIfAvailable

public OMNode getNextOMSiblingIfAvailable()
Description copied from interface: OMNodeEx
Get the next sibling if it is available. The sibling is available if it is complete or if the builder has started building the node. In the latter case, OMSerializable.isComplete() may return false when called on the sibling. In contrast to OMNode.getNextOMSibling(), this method will never modify the state of the underlying parser.

Specified by:
getNextOMSiblingIfAvailable in interface OMNodeEx
Overrides:
getNextOMSiblingIfAvailable in class OMNodeImpl
Returns:
the next sibling or null if the node has no next sibling or the builder has not yet started to build the next sibling

getTrimmedText

public String getTrimmedText()
Description copied from class: OMElementImpl
Returns the concatination string of TRIMMED values of all OMText child nodes of this element. This is included purely to improve usability.

Overrides:
getTrimmedText in class OMElementImpl

isComplete

public boolean isComplete()
Description copied from interface: OMSerializable
Indicates whether parser has parsed this information item completely or not. If some info are not available in the item, one has to check this attribute to make sure that, this item has been parsed completely or not.

Specified by:
isComplete in interface OMSerializable
Overrides:
isComplete in class OMSerializableImpl
Returns:
Returns boolean.

toString

public String toString()
Description copied from interface: OMElement
This is a convenience method only. This will basically serialize the given OMElement to a String but will build the OMTree in the memory

Specified by:
toString in interface OMElement
Overrides:
toString in class OMElementImpl

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 OMElementImpl

build

public void build()
           throws OMException
Description copied from class: OMSerializableImpl
Parses 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:
build in interface OMSerializable
Overrides:
build in class OMElementImpl
Throws:
OMException

notifyChildComplete

protected void notifyChildComplete()
Description copied from class: OMElementImpl
This method will be called when one of the children becomes complete.

Overrides:
notifyChildComplete in class OMElementImpl

getDataSource

public OMDataSource getDataSource()
Provide access to the data source encapsulated in OMSourcedElement. This is usesful when we want to access the raw data in the data source.

Specified by:
getDataSource in interface OMSourcedElement
Returns:
the internal datasource

setDataSource

public OMDataSource setDataSource(OMDataSource dataSource)
setOMDataSource

Specified by:
setDataSource in interface OMSourcedElement
Parameters:
dataSource - new OMDataSource
Returns:
null or old OMDataSource

setComplete

public void setComplete(boolean value)
setComplete override The OMSourcedElement has its own isolated builder/reader during the expansion process. Thus calls to setCompete should stop here and not propogate up to the parent (which may have a different builder or no builder).

Specified by:
setComplete in interface OMContainerEx
Specified by:
setComplete in interface OMNodeEx
Overrides:
setComplete in class OMNodeImpl


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