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

java.lang.Object
  extended byorg.apache.axis2.om.impl.llom.OMNodeImpl
      extended byorg.apache.axis2.om.impl.llom.OMElementImpl
All Implemented Interfaces:
OMConstants, OMContainer, OMContainerEx, OMElement, OMNode, OMNodeEx
Direct Known Subclasses:
RPCRequestElement, RPCResponseElement, SOAPElement, SOAPHeaderBlockImpl

public class OMElementImpl
extends OMNodeImpl
implements OMElement, OMConstants, OMContainerEx

Class OMElementImpl


Field Summary
protected  java.util.HashMap attributes
          Field attributes
protected  OMNode firstChild
          Field firstChild
protected  java.lang.String localName
          Field localName
protected  java.util.HashMap namespaces
          Field namespaces
protected  int noPrefixNamespaceCounter
          Field noPrefixNamespaceCounter
protected  OMNamespace ns
          Field ns
 
Fields inherited from class org.apache.axis2.om.impl.llom.OMNodeImpl
builder, done, nextSibling, nodeType, parent, previousSibling
 
Fields inherited from interface org.apache.axis2.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.axis2.om.OMConstants
ARRAY_ITEM_LOCALNAME, ARRAY_ITEM_NS_PREFIX, ARRAY_ITEM_NSURI, ARRAY_ITEM_QNAME, DEFAULT_CHAR_SET_ENCODING, DEFAULT_XML_VERSION, PULL_TYPE_BUILDER, PUSH_TYPE_BUILDER
 
Constructor Summary
OMElementImpl(javax.xml.namespace.QName qname, OMContainer parent)
          Here it is assumed that this QName passed, at least contains the localName for this element
OMElementImpl(java.lang.String localName, OMNamespace ns)
          Constructor OMElementImpl
OMElementImpl(java.lang.String localName, OMNamespace ns, OMContainer parent)
          This is the basic constructor for OMElement.
OMElementImpl(java.lang.String localName, OMNamespace ns, OMContainer parent, OMXMLParserWrapper builder)
          Constructor OMElementImpl
 
Method Summary
 OMAttribute addAttribute(OMAttribute attr)
          This will insert attribute to this element.
 OMAttribute addAttribute(java.lang.String attributeName, java.lang.String value, OMNamespace ns)
          Method addAttribute
 void addChild(OMNode child)
          This will add child to the element.
 void buildNext()
          This will force the parser to proceed, if parser has not yet finished with the XML input
 OMNamespace declareNamespace(OMNamespace namespace)
           
 OMNamespace declareNamespace(java.lang.String uri, java.lang.String prefix)
          THis will create a namespace in the current element scope
 OMNode detach()
          This will remove this information item and its children, from the model completely
 void discard()
          Discard implementation
 OMNamespace findNamespace(java.lang.String uri, java.lang.String prefix)
          This will find a namespace with the given uri and prefix, in the scope of the docuemnt.
 java.util.Iterator getAllDeclaredNamespaces()
          Method getAllDeclaredNamespaces
 OMAttribute getAttribute(javax.xml.namespace.QName qname)
          Return a named attribute if present
 java.util.Iterator getAttributes()
          This will return a List of OMAttributes
 OMXMLParserWrapper getBuilder()
          Method getBuilder
 java.util.Iterator getChildElements()
          Returns a filtered list of children - just the elements.
 java.util.Iterator getChildren()
          This returns a collection of this element.
 java.util.Iterator getChildrenWithName(javax.xml.namespace.QName elementQName)
          This will search for children with a given QName and will return an iterator to traverse through the OMNodes.
 OMAttribute getFirstAttribute(javax.xml.namespace.QName qname)
          This will help to search for an attribute with a given QName within this Element
 OMNode getFirstChild()
          Method getFirstChild
 OMElement getFirstChildWithName(javax.xml.namespace.QName elementQName)
          Method getFirstChildWithName
 OMElement getFirstElement()
          Get first element
 java.lang.String getLocalName()
          Method getLocalName
 OMNamespace getNamespace()
          Method getNamespace
 OMNode getNextSibling()
          This will give the next sibling.
 javax.xml.namespace.QName getQName()
          Method getQName
 java.lang.String getText()
          select all the text children and concat them to a single string
 java.lang.String getTrimmedText()
          Returns the concatanation of TRIMMED values of all OMText child nodes of this element This is incuded purely to improve usability
 int getType()
          This is to get the type of node, as this is the super class of all the nodes
 XMLStreamReader getXMLStreamReader()
          getXMLStreamReader
 XMLStreamReader getXMLStreamReaderWithoutCaching()
          getXMLStreamReaderWithoutCaching
 boolean isComplete()
          Method isComplete
 void removeAttribute(OMAttribute attr)
          Method removeAttribute
 void serialize(OMOutputImpl omOutput)
          This was requested during the second Axis2 summit.
protected  void serialize(OMOutputImpl omOutput, boolean cache)
           
 void serializeWithCache(OMOutputImpl omOutput)
          Method serializeWithCache
 void setBuilder(OMXMLParserWrapper wrapper)
          Method setBuilder
 void setFirstChild(OMNode firstChild)
          Method setFirstChild
 void setLocalName(java.lang.String localName)
          Method setLocalName
 void setNamespace(OMNamespace namespace)
          Method setNamespace
 void setText(java.lang.String text)
          Sets the text of the given element.
 
Methods inherited from class org.apache.axis2.om.impl.llom.OMNodeImpl
build, getParent, getPreviousSibling, insertSiblingAfter, insertSiblingBefore, serialize, serializeWithCache, setComplete, setNextSibling, setParent, setPreviousSibling, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.axis2.om.OMNode
build, getParent, getPreviousSibling, insertSiblingAfter, insertSiblingBefore, serialize, serializeWithCache
 
Methods inherited from interface org.apache.axis2.om.impl.OMContainerEx
setComplete
 

Field Detail

ns

protected OMNamespace ns
Field ns


localName

protected java.lang.String localName
Field localName


firstChild

protected OMNode firstChild
Field firstChild


namespaces

protected java.util.HashMap namespaces
Field namespaces


attributes

protected java.util.HashMap attributes
Field attributes


noPrefixNamespaceCounter

protected int noPrefixNamespaceCounter
Field noPrefixNamespaceCounter

Constructor Detail

OMElementImpl

public OMElementImpl(java.lang.String localName,
                     OMNamespace ns,
                     OMContainer parent,
                     OMXMLParserWrapper builder)
Constructor OMElementImpl


OMElementImpl

public OMElementImpl(java.lang.String localName,
                     OMNamespace ns)
Constructor OMElementImpl


OMElementImpl

public OMElementImpl(java.lang.String localName,
                     OMNamespace ns,
                     OMContainer parent)
This is the basic constructor for OMElement. All the other constructors within this class will depend on this.

Parameters:
localName - - this MUST always be not null
ns - - can be null
parent - - this should be an OMContainer

OMElementImpl

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

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

addChild

public void addChild(OMNode child)
This will add child to the element. One can decide whether he append the child or he adds to the front of the children list

Specified by:
addChild in interface OMElement
Parameters:
child -

getChildrenWithName

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

Specified by:
getChildrenWithName in interface OMElement
Parameters:
elementQName -
Returns:
Throws:
OMException
OMException

getFirstChildWithName

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

Specified by:
getFirstChildWithName in interface OMElement
Parameters:
elementQName -
Returns:
Throws:
OMException

getNextSibling

public OMNode getNextSibling()
                      throws OMException
This will give the next sibling. This can be an OMAttribute for OMAttribute or OMText or OMELement for others.

Specified by:
getNextSibling in interface OMNode
Overrides:
getNextSibling in class OMNodeImpl
Returns:
Throws:
OMException
OMException

getChildren

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

Specified by:
getChildren in interface OMElement
Returns:
children

getChildElements

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

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

declareNamespace

public OMNamespace declareNamespace(java.lang.String uri,
                                    java.lang.String prefix)
THis will create a namespace in the current element scope

Specified by:
declareNamespace in interface OMElement
Parameters:
uri -
prefix -
Returns:
namespace

declareNamespace

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

findNamespace

public OMNamespace findNamespace(java.lang.String uri,
                                 java.lang.String prefix)
                          throws OMException
This will find a namespace with the given uri and prefix, in the scope of the docuemnt. This will start to find from the current element and goes up in the hiararchy until this finds one. If none is found, return null

Specified by:
findNamespace in interface OMElement
Parameters:
uri -
prefix -
Returns:
Throws:
OMException
OMException

getAllDeclaredNamespaces

public java.util.Iterator getAllDeclaredNamespaces()
Method getAllDeclaredNamespaces

Specified by:
getAllDeclaredNamespaces in interface OMElement
Returns:
iterator

getFirstAttribute

public OMAttribute getFirstAttribute(javax.xml.namespace.QName qname)
                              throws OMException
This will help to search for an attribute with a given QName within this Element

Specified by:
getFirstAttribute in interface OMElement
Parameters:
qname -
Returns:
Throws:
OMException
OMException

getAttributes

public java.util.Iterator getAttributes()
This will return a List of OMAttributes

Specified by:
getAttributes in interface OMElement
Returns:
iterator

getAttribute

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

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

addAttribute

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

Specified by:
addAttribute in interface OMElement
Parameters:
attr -
Returns:
attribute

removeAttribute

public void removeAttribute(OMAttribute attr)
Method removeAttribute

Specified by:
removeAttribute in interface OMElement
Parameters:
attr -

addAttribute

public OMAttribute addAttribute(java.lang.String attributeName,
                                java.lang.String value,
                                OMNamespace ns)
Method addAttribute

Specified by:
addAttribute in interface OMElement
Parameters:
attributeName -
value -
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:
attribute

setBuilder

public void setBuilder(OMXMLParserWrapper wrapper)
Method setBuilder

Specified by:
setBuilder in interface OMElement
Parameters:
wrapper -

getBuilder

public OMXMLParserWrapper getBuilder()
Method getBuilder

Specified by:
getBuilder in interface OMElement
Returns:
builder

buildNext

public void buildNext()
This will force the parser to proceed, if parser has not yet finished with the XML input

Specified by:
buildNext in interface OMContainer

getFirstChild

public OMNode getFirstChild()
Method getFirstChild

Specified by:
getFirstChild in interface OMElement
Returns:
child

setFirstChild

public void setFirstChild(OMNode firstChild)
Method setFirstChild

Specified by:
setFirstChild in interface OMElement
Parameters:
firstChild -

detach

public OMNode detach()
              throws OMException
This will remove this information item and its children, from the model completely

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

isComplete

public boolean isComplete()
Method isComplete

Specified by:
isComplete in interface OMNode
Overrides:
isComplete in class OMNodeImpl
Returns:
boolean

getType

public int getType()
            throws OMException
This is to get the type of node, as this is the super class of all the nodes

Specified by:
getType in interface OMNode
Overrides:
getType in class OMNodeImpl
Returns:
Throws:
OMException
OMException

getXMLStreamReader

public XMLStreamReader getXMLStreamReader()
getXMLStreamReader

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

getXMLStreamReaderWithoutCaching

public XMLStreamReader getXMLStreamReaderWithoutCaching()
getXMLStreamReaderWithoutCaching

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

setText

public void setText(java.lang.String text)
Sets the text of the given element. caution - This method will wipe out all the text elements (and hence any moxed content) before setting the text

Specified by:
setText in interface OMElement
Parameters:
text -

getText

public java.lang.String getText()
select all the text children and concat them to a single string

Specified by:
getText in interface OMElement
Returns:
text

getTrimmedText

public java.lang.String getTrimmedText()
Returns the concatanation of TRIMMED values of all OMText child nodes of this element This is incuded purely to improve usability


serializeWithCache

public void serializeWithCache(OMOutputImpl omOutput)
                        throws XMLStreamException
Method serializeWithCache

Overrides:
serializeWithCache in class OMNodeImpl
Parameters:
omOutput -
Throws:
XMLStreamException
See Also:
#serializeWithCache(org.apache.axis2.om.impl.OMOutputImpl)

serialize

protected void serialize(OMOutputImpl omOutput,
                         boolean cache)
                  throws XMLStreamException
Throws:
XMLStreamException

serialize

public void serialize(OMOutputImpl omOutput)
               throws XMLStreamException
This was requested during the second Axis2 summit. When one call this method, this will serialize without building the object structure in the memory. Misuse of this method will cause loss of data.So its advised to use populateYourSelf() method, before this, if you want to preserve data in the stream.

Overrides:
serialize in class OMNodeImpl
Parameters:
omOutput -
Throws:
XMLStreamException
See Also:
#serialize(org.apache.axis2.om.impl.OMOutputImpl)

getFirstElement

public OMElement getFirstElement()
Get first element

Specified by:
getFirstElement in interface OMElement
Returns:
element

getLocalName

public java.lang.String getLocalName()
Method getLocalName

Specified by:
getLocalName in interface OMElement
Returns:
local name

setLocalName

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

Specified by:
setLocalName in interface OMElement
Parameters:
localName -

getNamespace

public OMNamespace getNamespace()
                         throws OMException
Method getNamespace

Specified by:
getNamespace in interface OMElement
Returns:
the OMNamespace object associated with this element
Throws:
OMException

setNamespace

public void setNamespace(OMNamespace namespace)
Method setNamespace

Specified by:
setNamespace in interface OMElement
Parameters:
namespace -

getQName

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

Specified by:
getQName in interface OMElement
Returns:
qname

discard

public void discard()
             throws OMException
Discard implementation

Specified by:
discard in interface OMNode
Throws:
OMException