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:
Cloneable, OMNodeEx, OMAttribute, OMNode, OMSerializable, Attr, Node, NodeList

public class AttrImpl
extends NodeImpl
implements OMAttribute, 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
protected  ParentNode parent
          Owner of this attribute
 
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, OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, String name, OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, String localName, OMNamespace namespace, OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, String localName, OMNamespace ns, String value, OMFactory factory)
           
  AttrImpl(DocumentImpl ownerDocument, String name, String value, OMFactory factory)
           
 
Method Summary
 Node cloneNode(boolean deep)
           
 OMNode detach()
          Not supported: Cannot detach attributes.
 void discard()
          Not supported: Cannot discard attributes.
 boolean equals(Object obj)
          An instance of AttrImpl can act as an OMAttribute and as well as an org.w3c.dom.Attr.
 String getAttributeType()
          Returns the attribute value.
 String getAttributeValue()
          Returns the attribute value.
 String getLocalName()
          Returns the attribute name.
 String getName()
           
 OMNamespace getNamespace()
          Returns the namespace of the attribute as an OMNamespace.
 String getNamespaceURI()
          Returns the namespace URI of this attr node.
 String getNodeName()
          Returns the name of this attribute.
 short getNodeType()
          Returns the node type.
 String getNodeValue()
          Returns the value of this attribute.
 OMElement getOwner()
          Returns the owner element of this attribute
 Element getOwnerElement()
          Returns the owner element.
 OMContainer getParent()
          Returns the parent node of this attribute.
 String getPrefix()
          Returns the namespace prefix of this attr node.
 QName getQName()
          Returns a qname representing the attribute.
 TypeInfo getSchemaTypeInfo()
           
 boolean getSpecified()
           
 int getType()
          Returns the type of this attribute node.
 String getValue()
          Returns the value of this attribute.
 int hashCode()
           
 void internalSerialize(XMLStreamWriter writer, boolean cache)
          This is not supported since attributes serialization is handled by the serialization of the owner nodes.
 boolean isId()
           
protected  boolean isUsed()
           
 void setAttributeType(String attrType)
          Sets the attribute value.
 void setAttributeValue(String value)
          Sets the attribute value.
 void setLocalName(String localName)
          Sets the name of attribute.
 void setOMNamespace(OMNamespace omNamespace)
          Sets the namespace of this attribute node.
 void setParent(OMContainer element)
          Sets the parent element to the given OMContainer.
 void setType(int nodeType)
          Sets the type.
protected  void setUsed(boolean used)
           
 void setValue(String value)
          Sets the value of the attribute.
 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, getNextOMSiblingIfAvailable, getNextSibling, getOMFactory, getOwnerDocument, getParentNode, getPreviousOMSibling, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, insertSiblingAfter, insertSiblingBefore, internalSerialize, internalSerializeAndConsume, isComplete, isDefaultNamespace, isEqualNode, isSameNode, isSupported, item, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, serialize, 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

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,
                   OMFactory factory)

AttrImpl

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

AttrImpl

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

AttrImpl

public AttrImpl(DocumentImpl ownerDocument,
                String name,
                OMFactory factory)

AttrImpl

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

getNodeName

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

Specified by:
getNodeName in interface Node

getNodeType

public short getNodeType()
Returns the node type.

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

getNodeValue

public String getNodeValue()
                    throws DOMException
Returns the value of this attribute.

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

getValue

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

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

getName

public String getName()
Specified by:
getName in interface Attr

getOwnerElement

public Element getOwnerElement()
Returns the owner element.

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

getSpecified

public boolean getSpecified()
Specified by:
getSpecified in interface Attr

detach

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

Specified by:
detach in interface OMNode
Overrides:
detach in class NodeImpl
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.
See Also:
OMNode.detach()

discard

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

Specified by:
discard in interface OMNode
Throws:
OMException
See Also:
OMNode.discard()

getType

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

Specified by:
getType in interface OMNode
Returns:
Returns one of OMNode.ELEMENT_NODE, OMNode.TEXT_NODE, OMNode.CDATA_SECTION_NODE, OMNode.COMMENT_NODE, OMNode.DTD_NODE, OMNode.PI_NODE, OMNode.ENTITY_REFERENCE_NODE or OMNode.SPACE_NODE.
See Also:
OMNode.getType()

internalSerialize

public void internalSerialize(XMLStreamWriter writer,
                              boolean cache)
                       throws XMLStreamException
This is not supported since attributes serialization is handled by the serialization of the owner nodes.

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

getNamespace

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

Specified by:
getNamespace in interface OMAttribute
Returns:
Returns OMNamespace.
See Also:
OMAttribute.getNamespace()

getQName

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

Specified by:
getQName in interface OMAttribute
Returns:
Returns javax.xml.namespace.QName
See Also:
OMAttribute.getQName()

getAttributeValue

public String getAttributeValue()
Returns the attribute value.

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

getAttributeType

public String getAttributeType()
Returns the attribute value.

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

setLocalName

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

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

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(String value)
Sets the attribute value.

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

setAttributeType

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

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

setParent

public void setParent(OMContainer element)
Sets the parent element to the given OMContainer.

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

setType

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

Specified by:
setType in interface OMNodeEx
Throws:
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(String value)
              throws DOMException
Sets the value of the attribute.

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

getParent

public OMContainer getParent()
Returns the parent node of this attribute.

Specified by:
getParent in interface OMNode
Overrides:
getParent in class NodeImpl
Returns:
The OMContainer of the node.
See Also:
OMNode.getParent()

getLocalName

public String getLocalName()
Returns the attribute name.

Specified by:
getLocalName in interface OMAttribute
Specified by:
getLocalName in interface Node
Overrides:
getLocalName in class NodeImpl
Returns:
Returns localName.
See Also:
Node.getLocalName()

getNamespaceURI

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

Specified by:
getNamespaceURI in interface Node
Overrides:
getNamespaceURI in class NodeImpl
See Also:
Node.getNamespaceURI()

getPrefix

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

Specified by:
getPrefix in interface Node
Overrides:
getPrefix in class NodeImpl
See Also:
Node.getPrefix()

cloneNode

public Node cloneNode(boolean deep)
Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class NodeImpl

getSchemaTypeInfo

public TypeInfo getSchemaTypeInfo()
Specified by:
getSchemaTypeInfo in interface Attr

isId

public boolean isId()
Specified by:
isId in interface Attr

toString

public String toString()
Overrides:
toString in class Object

getOwner

public OMElement getOwner()
Returns the owner element of this attribute

Specified by:
getOwner in interface 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(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 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 Object


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