org.openxml.dom
Class AttrImpl

java.lang.Object
  extended by org.openxml.dom.NodeImpl
      extended by org.openxml.dom.ParentNodeImpl
          extended by org.openxml.dom.ParentNSNodeImpl
              extended by org.openxml.dom.AttrImpl
All Implemented Interfaces:
Cloneable, Attr, Node

public final class AttrImpl
extends ParentNSNodeImpl
implements Attr

Represents an attribute in an Element node.

Attributes are not real nodes, they are not children in their parent element. Siblings and parents are not accessible.

Attributes in XML documents support children, but only of the type Text and EntityReference.

The specified value of an attribute indicates whether it's value has been changed since it was constructed with the default value. The specified value is not used when cloning an attribute or testing for equality.

To speed up implementation, all attributes are implemented as double-linked list using ParentNodeImpl. Namespace support is provided by ParentNSNodeImpl.

See Also:
Attr, ParentNSNodeImpl, ElementImpl

Field Summary
 
Fields inherited from class org.openxml.dom.NodeImpl
ATTLIST_DECL_NODE, ELEMENT_DECL_NODE, PARAM_ENTITY_NODE
 
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
 
Method Summary
protected  NodeImpl castNewChild(Node newChild)
          Assures that the children of an attribute are either Text or EntityReference.
 Object clone()
           
protected  void cloneInto(NodeImpl into, boolean deep)
          This clone method is called after a new node has been constructed to copy the contents of this node into the new one.
 Node cloneNode(boolean deep)
           
 short compareDocumentPosition(Node other)
           
 String getBaseURI()
           
 Object getFeature(String feature, String version)
           
 String getName()
           
protected  AttrImpl getNextAttr()
          Return the next attribute following this one.
 Node getNextSibling()
          Returns the next sibling of this node.
 short getNodeType()
          Abstract method must be implemented by each node class.
 Element getOwnerElement()
          Returns the element node this attribute is attached to, or null if attribute not in use in any element.
 Node getParentNode()
          Returns the parent node of this node.
 Node getPreviousSibling()
          Returns the previous sibling of this node.
 TypeInfo getSchemaTypeInfo()
           
 boolean getSpecified()
           
 String getTextContent()
           
 Object getUserData(String key)
           
 String getValue()
           
 boolean hasAttributes()
           
 boolean isDefaultNamespace(String namespaceURI)
           
 boolean isEqualNode(Node arg)
           
 boolean isId()
           
 boolean isSameNode(Node other)
           
 boolean isSupported(String feature, String version)
           
 String lookupNamespaceURI(String prefix)
           
 String lookupPrefix(String namespaceURI)
           
 void setNodeValue(String value)
          Changes the value of the node.
 void setTextContent(String textContent)
           
 Object setUserData(String key, Object data, UserDataHandler handler)
           
 void setValue(String value)
           
 String toString()
           
 
Methods inherited from class org.openxml.dom.ParentNSNodeImpl
equals, getLocalName, getNamespaceURI, getPrefix, setPrefix
 
Methods inherited from class org.openxml.dom.ParentNodeImpl
appendChild, castOldChild, createNodeIterator, getChildNodes, getFirstChild, getLastChild, hasChildNodes, insertBefore, normalize, removeChild, removeInnerIterator, replaceChild
 
Methods inherited from class org.openxml.dom.NodeImpl
getAttributes, getNodeName, getNodeValue, getOwnerDocument, isReadOnly, makeReadOnly, setOwnerDocument, supports
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNodeName, getNodeValue, getOwnerDocument, getPrefix, hasChildNodes, insertBefore, normalize, removeChild, replaceChild, setPrefix
 

Method Detail

getNodeType

public short getNodeType()
Description copied from class: NodeImpl
Abstract method must be implemented by each node class.

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

getName

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

getSpecified

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

getValue

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

setNodeValue

public void setNodeValue(String value)
Description copied from class: NodeImpl
Changes the value of the node. Not all node types support the notion of a value. If the value is not supported by a particular node type, it will throw an exception when calling this method. The following table specifies which node types support values:
 Element                Not supported
 Attr                   Supported
 Text                   Supported
 CDATASection           Supported
 EntityReference        Not supported
 Entity                 Not supported
 ProcessingInstruction  Supported
 Comment                Supported
 Document               Not supported
 DocumentType           Not supported
 DocumentFragment       Not supported
 Notation               Not supported
 
For most node types, if the value is set to null, NodeImpl.getNodeValue() will return an empty string instead.

Specified by:
setNodeValue in interface Node
Overrides:
setNodeValue in class NodeImpl
Parameters:
value - New value of node

setValue

public void setValue(String value)
Specified by:
setValue in interface Attr

getParentNode

public Node getParentNode()
Description copied from class: NodeImpl
Returns the parent node of this node. Node may not necessarily have a parent node. If node has been created but not added to any other node, it will be parentless. The Document node is always parentless.

Specified by:
getParentNode in interface Node
Overrides:
getParentNode in class NodeImpl
Returns:
Parent node of this node

getPreviousSibling

public Node getPreviousSibling()
Description copied from class: NodeImpl
Returns the previous sibling of this node. If node has no previous siblings, returns null.

Specified by:
getPreviousSibling in interface Node
Overrides:
getPreviousSibling in class NodeImpl
Returns:
Previous sibling or null

getNextSibling

public Node getNextSibling()
Description copied from class: NodeImpl
Returns the next sibling of this node. If node has no next siblings, returns null.

Specified by:
getNextSibling in interface Node
Overrides:
getNextSibling in class NodeImpl
Returns:
Next sibling or null

getOwnerElement

public Element getOwnerElement()
Returns the element node this attribute is attached to, or null if attribute not in use in any element.

Specified by:
getOwnerElement in interface Attr
Returns:
Element node of this attribute, or null

toString

public String toString()
Overrides:
toString in class Object

clone

public final Object clone()
Overrides:
clone in class Object

cloneNode

public final Node cloneNode(boolean deep)
Specified by:
cloneNode in interface Node

getNextAttr

protected AttrImpl getNextAttr()
Return the next attribute following this one. getNextSibling() returns null by definition of DOM, but outside classes (ElementImpl and AttrNodeMap) require traversal over attribute list.

Returns:
Next attribute in list

cloneInto

protected void cloneInto(NodeImpl into,
                         boolean deep)
Description copied from class: NodeImpl
This clone method is called after a new node has been constructed to copy the contents of this node into the new one. It clones in contents but not in context, and guarantees that the cloned node will pass the equality test (see NodeImpl.equals(java.lang.Object)).

into must be a valid node of the exact same class as this one. deep is true if deep cloning (includes all children nodes) is to be performed. If deep is false, the clone might not pass the equality test.

Derived classes override and call this method to add per-class variable copying. This method is called by Node.cloneNode(boolean) and the default Object.clone() method.

Contents cloning duplicates the node's name and value, and its children. It does not duplicate it's context, that is, the node's parent or sibling. Initially a clone node has no parents or siblings. However, the node does belong to the same document, since all nodes must belong to some document. The cloned node is never read-only.

Overrides:
cloneInto in class ParentNSNodeImpl
Parameters:
into - A node into which to duplicate this one
deep - True if deep cloning is required

castNewChild

protected NodeImpl castNewChild(Node newChild)
                         throws DOMException
Assures that the children of an attribute are either Text or EntityReference.

Overrides:
castNewChild in class ParentNodeImpl
Parameters:
newChild - New child node
Returns:
newChild cast to type NodeImpl
Throws:
DOMException - HIERARCHY_REQUEST_ERR newChild is null, does not belong to this DOM, or its node type is not supported for this parent

getSchemaTypeInfo

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

isId

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

compareDocumentPosition

public short compareDocumentPosition(Node other)
                              throws DOMException
Specified by:
compareDocumentPosition in interface Node
Throws:
DOMException

getBaseURI

public String getBaseURI()
Specified by:
getBaseURI in interface Node

getFeature

public Object getFeature(String feature,
                         String version)
Specified by:
getFeature in interface Node

getTextContent

public String getTextContent()
                      throws DOMException
Specified by:
getTextContent in interface Node
Throws:
DOMException

getUserData

public Object getUserData(String key)
Specified by:
getUserData in interface Node

isDefaultNamespace

public boolean isDefaultNamespace(String namespaceURI)
Specified by:
isDefaultNamespace in interface Node

isEqualNode

public boolean isEqualNode(Node arg)
Specified by:
isEqualNode in interface Node

isSameNode

public boolean isSameNode(Node other)
Specified by:
isSameNode in interface Node

lookupNamespaceURI

public String lookupNamespaceURI(String prefix)
Specified by:
lookupNamespaceURI in interface Node

lookupPrefix

public String lookupPrefix(String namespaceURI)
Specified by:
lookupPrefix in interface Node

setTextContent

public void setTextContent(String textContent)
                    throws DOMException
Specified by:
setTextContent in interface Node
Throws:
DOMException

setUserData

public Object setUserData(String key,
                          Object data,
                          UserDataHandler handler)
Specified by:
setUserData in interface Node

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface Node

isSupported

public boolean isSupported(String feature,
                           String version)
Specified by:
isSupported in interface Node


Phantom® and NetPhantom® are registered trademarks of Codectica Systems SARL.
© Copyright Codectica Systems SARL, 2008. All rights reserved.