org.apache.crimson.tree
Class AttributeNode

java.lang.Object
  extended byorg.apache.crimson.tree.NodeBase
      extended byorg.apache.crimson.tree.ParentNode
          extended byorg.apache.crimson.tree.NamespacedNode
              extended byorg.apache.crimson.tree.AttributeNode
All Implemented Interfaces:
org.w3c.dom.Attr, org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, XmlWritable
Direct Known Subclasses:
AttributeNode1

public class AttributeNode
extends NamespacedNode
implements org.w3c.dom.Attr

Node representing an XML attribute. Many views of attributes can be useful, but only the first of these is explicitly supported:

Logical View
Attributes always hold a string created by expanding character and entity references from source text conforming to the XML specification. If this attribute was declared in a DTD, normalization will often be done to eliminate insignificant whitespace.
DTD Validated View
If the attribute was declared in a DTD, it will have minimal semantics provided by its declaration, and checked by validating parsers. For example, the logical view may name one (or many) unparsed entities or DOM nodes. This view could provide direct access to them for any DTD, since these attribute semantics are defined by XML itself.
Semantic View
The person who wrote the DTD (or other namespace) defined what each attribute's logical view "means". For example, that it's a URL, or that the unparsed entity referred to identifies a particular database to be used. This view would provide direct access to such values, but would need to have code specialized to that DTD or namespace.
Physical View
Attributes may have children to represent text and entity reference nodes found in unexpanded and unnormalized XML source text. Such views are mostly of interest when editing XML text that is not dynamically generated by programs. This implementation does not currently support physical views of attributes.

Author:
David Brownell, Rajiv Mordani

Nested Class Summary
 
Nested classes inherited from class org.apache.crimson.tree.NamespacedNode
ParentNode.TagList, ParentNode.TagListNS
 
Field Summary
private  String defaultValue
           
private  org.w3c.dom.Element ownerElement
          At construction time ownerElement is null, it gets set whenever an attribute is set on an Element
private  boolean specified
           
private  String value
           
 
Fields inherited from class org.apache.crimson.tree.NamespacedNode
namespaceURI, ownerDocument, qName, readonly
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
AttributeNode(String namespaceURI, String qName, String value, boolean specified, String defaultValue)
          Constructs an attribute node.
 
Method Summary
(package private) static void checkArguments(String namespaceURI, String qualifiedName)
          Package private method to check arguments for constructor
(package private)  void checkChildType(int type)
           
(package private)  AttributeNode cloneAttributeNode(boolean deep)
          Clone this AttributeNode and possibly its children (which cannot be AttributeNodes themselves).
 org.w3c.dom.Node cloneNode(boolean deep)
          DOM: returns a copy of this node which is not owned by an Element
(package private)  String getDefaultValue()
           
 String getName()
          DOM: Returns the attribute name
 org.w3c.dom.Node getNextSibling()
          DOM: Returns null
 short getNodeType()
          DOM: Returns the ATTRIBUTE_NODE node type constant.
 String getNodeValue()
          DOM: Returns the attribute value.
 org.w3c.dom.Element getOwnerElement()
          DOM2:
 org.w3c.dom.Node getParentNode()
          DOM: Returns null
 org.w3c.dom.Node getPreviousSibling()
          DOM: Returns null
 boolean getSpecified()
          DOM: Returns true if the source text specified the attribute.
 String getValue()
          DOM: Returns the attribute value.
(package private)  AttributeNode makeClone()
          Make a clone of this node and return it.
 void setNodeValue(String value)
          DOM: Assigns the value of this attribute.
(package private)  void setOwnerElement(org.w3c.dom.Element element)
           
(package private)  void setSpecified(boolean specified)
          Flags whether the source text specified the attribute.
 void setValue(String value)
          DOM: Assigns the value of this attribute.
 void writeChildrenXml(XmlWriteContext context)
          Writes the attribute's value.
 void writeXml(XmlWriteContext context)
          Writes the attribute out, as if it were assigned within an element's starting tag (name="value").
 
Methods inherited from class org.apache.crimson.tree.NamespacedNode
appendChild, getAttributes, getChildNodes, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getIndexOf, getInheritedAttribute, getLanguage, getLastChild, getLength, getLocalName, getMessage, getMessage, getNamespaceURI, getNodeName, getOwnerDocument, getParentImpl, getPrefix, hasAttributes, hasChildNodes, insertBefore, isReadonly, isSupported, item, normalize, reduceWaste, removeChild, removeWhiteSpaces, replaceChild, setOwnerDocument, setParentNode, setPrefix, setReadonly, trimToSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNodeName, getOwnerDocument, getPrefix, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setPrefix
 

Field Detail

value

private String value

specified

private boolean specified

defaultValue

private String defaultValue

ownerElement

private org.w3c.dom.Element ownerElement
At construction time ownerElement is null, it gets set whenever an attribute is set on an Element

Constructor Detail

AttributeNode

public AttributeNode(String namespaceURI,
                     String qName,
                     String value,
                     boolean specified,
                     String defaultValue)
              throws org.w3c.dom.DOMException
Constructs an attribute node. Used for SAX2 and DOM2

Method Detail

makeClone

AttributeNode makeClone()
Make a clone of this node and return it. Used for cloneNode().


checkArguments

static void checkArguments(String namespaceURI,
                           String qualifiedName)
                    throws DomEx
Package private method to check arguments for constructor

Throws:
DomEx

getDefaultValue

String getDefaultValue()

getOwnerElement

public org.w3c.dom.Element getOwnerElement()
DOM2:

Specified by:
getOwnerElement in interface org.w3c.dom.Attr

setOwnerElement

void setOwnerElement(org.w3c.dom.Element element)

getNodeType

public short getNodeType()
DOM: Returns the ATTRIBUTE_NODE node type constant.

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

getName

public String getName()
DOM: Returns the attribute name

Specified by:
getName in interface org.w3c.dom.Attr

getValue

public String getValue()
DOM: Returns the attribute value.

Specified by:
getValue in interface org.w3c.dom.Attr

setValue

public void setValue(String value)
DOM: Assigns the value of this attribute.

Specified by:
setValue in interface org.w3c.dom.Attr

getNodeValue

public String getNodeValue()
DOM: Returns the attribute value.

Specified by:
getNodeValue in interface org.w3c.dom.Node
Overrides:
getNodeValue in class NodeBase

getSpecified

public boolean getSpecified()
DOM: Returns true if the source text specified the attribute.

Specified by:
getSpecified in interface org.w3c.dom.Attr

setNodeValue

public void setNodeValue(String value)
DOM: Assigns the value of this attribute.

Specified by:
setNodeValue in interface org.w3c.dom.Node
Overrides:
setNodeValue in class NodeBase

setSpecified

void setSpecified(boolean specified)
Flags whether the source text specified the attribute.


getParentNode

public org.w3c.dom.Node getParentNode()
DOM: Returns null

Specified by:
getParentNode in interface org.w3c.dom.Node
Overrides:
getParentNode in class NodeBase

getNextSibling

public org.w3c.dom.Node getNextSibling()
DOM: Returns null

Specified by:
getNextSibling in interface org.w3c.dom.Node
Overrides:
getNextSibling in class NodeBase

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
DOM: Returns null

Specified by:
getPreviousSibling in interface org.w3c.dom.Node
Overrides:
getPreviousSibling in class NodeBase

writeXml

public void writeXml(XmlWriteContext context)
              throws IOException
Writes the attribute out, as if it were assigned within an element's starting tag (name="value").

Specified by:
writeXml in interface XmlWritable
Throws:
IOException

writeChildrenXml

public void writeChildrenXml(XmlWriteContext context)
                      throws IOException
Writes the attribute's value.

Specified by:
writeChildrenXml in interface XmlWritable
Overrides:
writeChildrenXml in class ParentNode
Parameters:
context - describes how the children should be printed
Throws:
IOException

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
DOM: returns a copy of this node which is not owned by an Element

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

cloneAttributeNode

AttributeNode cloneAttributeNode(boolean deep)
Clone this AttributeNode and possibly its children (which cannot be AttributeNodes themselves). "ownerElement" will remain null.


checkChildType

void checkChildType(int type)
              throws org.w3c.dom.DOMException
Specified by:
checkChildType in class ParentNode
Throws:
org.w3c.dom.DOMException