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

java.lang.Object
  extended by org.apache.axiom.om.impl.dom.NodeImpl
      extended by org.apache.axiom.om.impl.dom.ParentNode
          extended by org.apache.axiom.om.impl.dom.RootNode
              extended by org.apache.axiom.om.impl.dom.AttrImpl
All Implemented Interfaces:
IParentNode, OMAttribute, OMInformationItem, OMNamedInformationItem, org.w3c.dom.Attr, org.w3c.dom.Node, org.w3c.dom.NodeList

public class AttrImpl
extends RootNode
implements OMAttribute, org.w3c.dom.Attr

Implementation of org.w3c.dom.Attr and org.apache.axiom.om.OMAttribute


Field Summary
protected  boolean isId
          Flag used to mark an attribute as per the DOM Level 3 specification
 
Fields inherited from class org.apache.axiom.om.impl.dom.ParentNode
firstChild, lastChild
 
Fields inherited from class org.apache.axiom.om.impl.dom.NodeImpl
factory, FIRSTCHILD, flags, HAS_PARENT, 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.impl.common.IParentNode
COMPLETE, DISCARDED, INCOMPLETE
 
Constructor Summary
AttrImpl(DocumentImpl ownerDocument, java.lang.String name, OMFactory factory)
           
AttrImpl(DocumentImpl ownerDocument, java.lang.String localName, OMNamespace namespace, OMFactory factory)
           
AttrImpl(DocumentImpl ownerDocument, java.lang.String localName, OMNamespace ns, java.lang.String value, OMFactory factory)
           
AttrImpl(DocumentImpl ownerDocument, java.lang.String name, java.lang.String value, OMFactory factory)
           
 
Method Summary
 void build()
           
 boolean equals(java.lang.Object obj)
          An instance of AttrImpl can act as an OMAttribute and as well as an org.w3c.dom.Attr.
 java.lang.String getAttributeType()
           
 java.lang.String getAttributeValue()
           
 OMXMLParserWrapper getBuilder()
           
 java.lang.String getLocalName()
           
 java.lang.String getName()
           
 OMNamespace getNamespace()
          Returns the namespace of the attribute as an OMNamespace.
 java.lang.String getNamespaceURI()
          Returns the namespace URI of this attr node.
 org.w3c.dom.Node getNextSibling()
           
 java.lang.String getNodeName()
          Returns the name of this attribute.
 short getNodeType()
          Returns the node type.
 java.lang.String getNodeValue()
          Returns the value of this attribute.
 OMElement getOwner()
           
 org.w3c.dom.Element getOwnerElement()
          Returns the owner element.
 org.w3c.dom.Node getParentNode()
           
 java.lang.String getPrefix()
          Returns the namespace prefix of this attr node.
 javax.xml.namespace.QName getQName()
          Returns a qname representing the attribute.
 org.w3c.dom.TypeInfo getSchemaTypeInfo()
           
 boolean getSpecified()
           
 int getState()
           
 java.lang.String getValue()
          Returns the value of this attribute.
 int hashCode()
           
 void internalSerialize(javax.xml.stream.XMLStreamWriter writer, boolean cache)
           
 void internalSetNamespace(OMNamespace namespace)
          Set the namespace of the node without adding a corresponding namespace declaration.
 boolean isComplete()
           
 boolean isId()
           
 java.lang.String lookupNamespaceURI(java.lang.String specifiedPrefix)
           
 void setAttributeType(java.lang.String attrType)
          Sets the attribute value.
 void setAttributeValue(java.lang.String value)
          Sets the attribute value.
 void setComplete(boolean state)
           
 void setLocalName(java.lang.String localName)
          Sets the name of attribute.
 void setOMNamespace(OMNamespace omNamespace)
          Sets the namespace of this attribute node.
 void setPrefix(java.lang.String prefix)
           
 void setValue(java.lang.String value)
          Sets the value of the attribute.
 java.lang.String toString()
           
 
Methods inherited from class org.apache.axiom.om.impl.dom.ParentNode
addChild, addChild, appendChild, getChildNodes, getChildren, getChildrenWithLocalName, getChildrenWithName, getChildrenWithNamespaceURI, getDescendants, getFirstChild, getFirstChildWithName, getFirstOMChild, getFirstOMChildIfAvailable, getLastChild, getLastKnownOMChild, getLength, getSAXSource, getTextContent, getXMLStreamReader, getXMLStreamReader, getXMLStreamReader, getXMLStreamReaderWithoutCaching, hasChildNodes, insertBefore, item, removeChild, replaceChild, setFirstChild, setLastChild, setTextContent
 
Methods inherited from class org.apache.axiom.om.impl.dom.NodeImpl
buildWithAttachments, clone, cloneNode, close, compareDocumentPosition, detach, getAttributes, getBaseURI, getFeature, getNextOMSiblingIfAvailable, getOMFactory, getOwnerDocument, getParent, getPreviousOMSibling, getPreviousSibling, getUserData, hasAttributes, insertSiblingAfter, insertSiblingBefore, internalSerialize, internalSerializeAndConsume, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupPrefix, normalize, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, setNextOMSibling, setNodeValue, setParent, setParent, setPreviousOMSibling, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getOwnerDocument, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setTextContent, setUserData
 
Methods inherited from interface org.apache.axiom.om.OMInformationItem
clone, getOMFactory
 

Field Detail

isId

protected boolean isId
Flag used to mark an attribute as per the DOM Level 3 specification

Constructor Detail

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String localName,
                OMNamespace ns,
                java.lang.String value,
                OMFactory factory)

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String name,
                java.lang.String value,
                OMFactory factory)

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String name,
                OMFactory factory)

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String localName,
                OMNamespace namespace,
                OMFactory factory)
Method Detail

getNodeName

public java.lang.String getNodeName()
Returns the name of this attribute.

Specified by:
getNodeName in interface org.w3c.dom.Node

getNodeType

public short getNodeType()
Returns the node type.

Specified by:
getNodeType in interface org.w3c.dom.Node
See Also:
Node.getNodeType()

getNodeValue

public java.lang.String getNodeValue()
                              throws org.w3c.dom.DOMException
Returns the value of this attribute.

Specified by:
getNodeValue in interface org.w3c.dom.Node
Overrides:
getNodeValue in class NodeImpl
Throws:
org.w3c.dom.DOMException
See Also:
Node.getNodeValue()

getValue

public java.lang.String getValue()
Returns the value of this attribute.

Specified by:
getValue in interface org.w3c.dom.Attr
See Also:
Attr.getValue()

getName

public java.lang.String getName()
Specified by:
getName in interface org.w3c.dom.Attr

getOwnerElement

public org.w3c.dom.Element getOwnerElement()
Returns the owner element.

Specified by:
getOwnerElement in interface org.w3c.dom.Attr
See Also:
Attr.getOwnerElement()

getSpecified

public boolean getSpecified()
Specified by:
getSpecified in interface org.w3c.dom.Attr

getNamespace

public OMNamespace getNamespace()
Returns the namespace of the attribute as an OMNamespace.

Specified by:
getNamespace in interface OMNamedInformationItem
See Also:
OMNamedInformationItem.getNamespace()

getQName

public javax.xml.namespace.QName getQName()
Returns a qname representing the attribute.

Specified by:
getQName in interface OMNamedInformationItem
See Also:
OMNamedInformationItem.getQName()

getAttributeValue

public java.lang.String getAttributeValue()
Specified by:
getAttributeValue in interface OMAttribute

getAttributeType

public java.lang.String getAttributeType()
Specified by:
getAttributeType in interface OMAttribute

setLocalName

public void setLocalName(java.lang.String localName)
Sets the name of attribute.

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

internalSetNamespace

public void internalSetNamespace(OMNamespace namespace)
Set the namespace of the node without adding a corresponding namespace declaration.


setOMNamespace

public void setOMNamespace(OMNamespace omNamespace)
Sets the namespace of this attribute node.

Specified by:
setOMNamespace in interface OMAttribute
See Also:
(org.apache.axiom.om.OMNamespace)

setAttributeValue

public void setAttributeValue(java.lang.String value)
Sets the attribute value.

Specified by:
setAttributeValue in interface OMAttribute
See Also:
OMAttribute.setAttributeValue(String)

setAttributeType

public void setAttributeType(java.lang.String attrType)
Sets the attribute value.

Specified by:
setAttributeType in interface OMAttribute
See Also:
OMAttribute.setAttributeType(String)

setValue

public void setValue(java.lang.String value)
              throws org.w3c.dom.DOMException
Sets the value of the attribute.

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

getParentNode

public org.w3c.dom.Node getParentNode()
Specified by:
getParentNode in interface org.w3c.dom.Node
Overrides:
getParentNode in class NodeImpl

getLocalName

public java.lang.String getLocalName()
Specified by:
getLocalName in interface OMNamedInformationItem
Specified by:
getLocalName in interface org.w3c.dom.Node
Overrides:
getLocalName in class NodeImpl

getNamespaceURI

public java.lang.String getNamespaceURI()
Returns the namespace URI of this attr node.

Specified by:
getNamespaceURI in interface OMNamedInformationItem
Specified by:
getNamespaceURI in interface org.w3c.dom.Node
Overrides:
getNamespaceURI in class NodeImpl
See Also:
Node.getNamespaceURI()

getPrefix

public java.lang.String getPrefix()
Returns the namespace prefix of this attr node.

Specified by:
getPrefix in interface OMNamedInformationItem
Specified by:
getPrefix in interface org.w3c.dom.Node
Overrides:
getPrefix in class NodeImpl
See Also:
Node.getPrefix()

setPrefix

public void setPrefix(java.lang.String prefix)
               throws org.w3c.dom.DOMException
Specified by:
setPrefix in interface org.w3c.dom.Node
Overrides:
setPrefix in class NodeImpl
Throws:
org.w3c.dom.DOMException

getSchemaTypeInfo

public org.w3c.dom.TypeInfo getSchemaTypeInfo()
Specified by:
getSchemaTypeInfo in interface org.w3c.dom.Attr

isId

public boolean isId()
Specified by:
isId in interface org.w3c.dom.Attr

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getOwner

public OMElement getOwner()
Specified by:
getOwner in interface OMAttribute

equals

public boolean equals(java.lang.Object obj)
An instance of AttrImpl can act as an OMAttribute and as well as an org.w3c.dom.Attr. So we first check if the object to compare with (obj) is of type OMAttribute (this includes instances of OMAttributeImpl or AttrImpl (instances of this class)). If so we check for the equality of namespaces first (note that if the namespace of this instance is null then for the obj to be equal its namespace must also be null). This condition solely doesn't determine the equality. So we check for the equality of names and values (note that the value can also be null in which case the same argument holds as that for the namespace) of the two instances. If all three conditions are met then we say the two instances are equal.

If obj is of type org.w3c.dom.Attr then we perform the same equality check as before. Note that, however, the implementation of the test for equality in this case is little different than before.

If obj is neither of type OMAttribute nor of type org.w3c.dom.Attr then we return false.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to compare with this instance
Returns:
True if the two objects are equal or else false. The equality is checked as explained above.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

internalSerialize

public void internalSerialize(javax.xml.stream.XMLStreamWriter writer,
                              boolean cache)
                       throws javax.xml.stream.XMLStreamException
Specified by:
internalSerialize in class NodeImpl
Throws:
javax.xml.stream.XMLStreamException

getBuilder

public final OMXMLParserWrapper getBuilder()
Specified by:
getBuilder in interface IParentNode
Specified by:
getBuilder in class NodeImpl

getState

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

isComplete

public final boolean isComplete()
Specified by:
isComplete in interface IParentNode
Specified by:
isComplete in class NodeImpl

setComplete

public final void setComplete(boolean state)
Specified by:
setComplete in class NodeImpl

build

public final void build()

getNextSibling

public final org.w3c.dom.Node getNextSibling()
Specified by:
getNextSibling in interface org.w3c.dom.Node

lookupNamespaceURI

public final java.lang.String lookupNamespaceURI(java.lang.String specifiedPrefix)
Specified by:
lookupNamespaceURI in interface org.w3c.dom.Node


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