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.AttrImpl
All Implemented Interfaces:
java.lang.Cloneable, org.apache.axiom.om.impl.OMNodeEx, org.apache.axiom.om.OMAttribute, org.apache.axiom.om.OMNode, org.w3c.dom.Attr, org.w3c.dom.Node, org.w3c.dom.NodeList

public class AttrImpl
extends NodeImpl
implements org.apache.axiom.om.OMAttribute, org.w3c.dom.Attr

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


Field Summary
private  java.lang.String attrName
          Name of the attribute
private  TextImpl attrValue
          Attribute value
protected  boolean isId
          Flag used to mark an attribute as per the DOM Level 3 specification
private  NamespaceImpl namespace
          Attribute namespace
protected  ParentNode parent
          Owner of this attribute
private  boolean used
          Flag to indicate whether this attr is used or not
 
Fields inherited from class org.apache.axiom.om.impl.dom.NodeImpl
builder, done, factory, FIRSTCHILD, flags, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface org.apache.axiom.om.OMNode
DTD_NODE, PI_NODE, SPACE_NODE
 
Constructor Summary
protected AttrImpl(DocumentImpl ownerDocument, org.apache.axiom.om.OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, java.lang.String name, org.apache.axiom.om.OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, java.lang.String localName, org.apache.axiom.om.OMNamespace namespace, org.apache.axiom.om.OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, java.lang.String localName, org.apache.axiom.om.OMNamespace ns, java.lang.String value, org.apache.axiom.om.OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, java.lang.String name, java.lang.String value, org.apache.axiom.om.OMFactory factory)
           
 
Method Summary
 org.w3c.dom.Node cloneNode(boolean deep)
           
 org.apache.axiom.om.OMNode detach()
          Not supported: Cannot detach attributes.
 void discard()
          Not supported: Cannot discard attributes.
 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 getAttributeValue()
          Returns the attribute value.
 java.lang.String getLocalName()
          Returns the attribute name.
 java.lang.String getName()
           
 org.apache.axiom.om.OMNamespace getNamespace()
          Returns the namespace of the attribute as an OMNamespace.
 java.lang.String getNamespaceURI()
          Returns the namespace URI of this attr node.
 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.
 org.apache.axiom.om.OMElement getOwner()
          Returns the owner element of this attribute
 org.w3c.dom.Element getOwnerElement()
          Returns the owner element.
 org.apache.axiom.om.OMContainer getParent()
          Returns the parent node of this attribute.
 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 getType()
          Returns the type of this attribute node.
 java.lang.String getValue()
          Returns the value of this attribute.
 int hashCode()
           
 void internalSerialize(javax.xml.stream.XMLStreamWriter writer)
          This is not supported since attributes serialization is handled by the serialization of the owner nodes.
 void internalSerializeAndConsume(javax.xml.stream.XMLStreamWriter writer)
          This is not supported since attributes serialization is handled by the serialization of the owner nodes.
 boolean isId()
           
protected  boolean isUsed()
           
 void setAttributeValue(java.lang.String value)
          Sets the attribute value.
 void setLocalName(java.lang.String localName)
          Sets the name of attribute.
 void setOMNamespace(org.apache.axiom.om.OMNamespace omNamespace)
          Sets the namespace of this attribute node.
 void setParent(org.apache.axiom.om.OMContainer element)
          Sets the parent element to the given OMContainer.
 void setType(int nodeType)
          Sets the type.
protected  void setUsed(boolean used)
           
 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.NodeImpl
appendChild, build, buildWithAttachments, close, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLength, getNextOMSibling, getNextSibling, getOMFactory, getOwnerDocument, getParentNode, getPreviousOMSibling, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, insertSiblingAfter, insertSiblingBefore, internalSerializeWithCache, isComplete, isDefaultNamespace, isEqualNode, isFirstChild, isFirstChild, isNormalized, isNormalized, isOwned, isOwned, isReadonly, isReadonly, isSameNode, isSpecified, isSpecified, isSupported, item, lookupNamespaceURI, lookupPrefix, normalize, parentNode, removeChild, replaceChild, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, setComplete, setNextOMSibling, setNodeValue, setOwnerDocument, setPrefix, setPreviousOMSibling, setTextContent, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.axiom.om.OMAttribute
getOMFactory
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Field Detail

attrName

private java.lang.String attrName
Name of the attribute


attrValue

private TextImpl attrValue
Attribute value


namespace

private NamespaceImpl namespace
Attribute namespace


used

private boolean used
Flag to indicate whether this attr is used or not


parent

protected ParentNode parent
Owner of this attribute


isId

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

Constructor Detail

AttrImpl

protected AttrImpl(DocumentImpl ownerDocument,
                   org.apache.axiom.om.OMFactory factory)

AttrImpl

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

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String name,
                java.lang.String value,
                org.apache.axiom.om.OMFactory factory)

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String name,
                org.apache.axiom.om.OMFactory factory)

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                java.lang.String localName,
                org.apache.axiom.om.OMNamespace namespace,
                org.apache.axiom.om.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

detach

public org.apache.axiom.om.OMNode detach()
                                  throws org.apache.axiom.om.OMException
Not supported: Cannot detach attributes. Use the operations available in the owner node.

Specified by:
detach in interface org.apache.axiom.om.OMNode
Overrides:
detach in class NodeImpl
Throws:
org.apache.axiom.om.OMException
See Also:
OMNode.detach()

discard

public void discard()
             throws org.apache.axiom.om.OMException
Not supported: Cannot discard attributes. Use the operations available in the owner node.

Specified by:
discard in interface org.apache.axiom.om.OMNode
Throws:
org.apache.axiom.om.OMException
See Also:
OMNode.discard()

getType

public int getType()
Returns the type of this attribute node.

Specified by:
getType in interface org.apache.axiom.om.OMNode
See Also:
OMNode.getType()

internalSerialize

public void internalSerialize(javax.xml.stream.XMLStreamWriter writer)
                       throws javax.xml.stream.XMLStreamException
This is not supported since attributes serialization is handled by the serialization of the owner nodes.

Specified by:
internalSerialize in interface org.apache.axiom.om.impl.OMNodeEx
Throws:
javax.xml.stream.XMLStreamException

internalSerializeAndConsume

public void internalSerializeAndConsume(javax.xml.stream.XMLStreamWriter writer)
                                 throws javax.xml.stream.XMLStreamException
This is not supported since attributes serialization is handled by the serialization of the owner nodes.

Specified by:
internalSerializeAndConsume in interface org.apache.axiom.om.impl.OMNodeEx
Throws:
javax.xml.stream.XMLStreamException
See Also:
(org.apache.axiom.om.impl.MTOMXMLStreamWriter)

getNamespace

public org.apache.axiom.om.OMNamespace getNamespace()
Returns the namespace of the attribute as an OMNamespace.

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

getQName

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

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

getAttributeValue

public java.lang.String getAttributeValue()
Returns the attribute value.

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

setLocalName

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

Specified by:
setLocalName in interface org.apache.axiom.om.OMAttribute
See Also:
OMAttribute.setLocalName(String)

setOMNamespace

public void setOMNamespace(org.apache.axiom.om.OMNamespace omNamespace)
Sets the namespace of this attribute node.

Specified by:
setOMNamespace in interface org.apache.axiom.om.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 org.apache.axiom.om.OMAttribute
See Also:
OMAttribute.setAttributeValue(String)

setParent

public void setParent(org.apache.axiom.om.OMContainer element)
Sets the parent element to the given OMContainer.

Specified by:
setParent in interface org.apache.axiom.om.impl.OMNodeEx
See Also:
(org.apache.axiom.om.OMContainer)

setType

public void setType(int nodeType)
             throws org.apache.axiom.om.OMException
Sets the type. NOT IMPLEMENTED: Unnecessary.

Specified by:
setType in interface org.apache.axiom.om.impl.OMNodeEx
Throws:
org.apache.axiom.om.OMException
See Also:
OMNodeEx.setType(int)

isUsed

protected boolean isUsed()
Returns:
Returns boolean.

setUsed

protected void setUsed(boolean used)
Parameters:
used - The used to set.

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)

getParent

public org.apache.axiom.om.OMContainer getParent()
Returns the parent node of this attribute.

Specified by:
getParent in interface org.apache.axiom.om.OMNode
Overrides:
getParent in class NodeImpl
See Also:
OMNode.getParent()

getLocalName

public java.lang.String getLocalName()
Returns the attribute name.

Specified by:
getLocalName in interface org.apache.axiom.om.OMAttribute
Specified by:
getLocalName in interface org.w3c.dom.Node
Overrides:
getLocalName in class NodeImpl
See Also:
Node.getLocalName()

getNamespaceURI

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

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 org.w3c.dom.Node
Overrides:
getPrefix in class NodeImpl
See Also:
Node.getPrefix()

cloneNode

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

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 org.apache.axiom.om.OMElement getOwner()
Returns the owner element of this attribute

Specified by:
getOwner in interface org.apache.axiom.om.OMAttribute
Returns:
OMElement - if the parent OMContainer is an instanceof OMElement we return that OMElement else return null. To get the OMContainer itself use getParent() method.

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