org.apache.crimson.tree
Class NodeBase

java.lang.Object
  extended byorg.apache.crimson.tree.NodeBase
All Implemented Interfaces:
org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, XmlWritable
Direct Known Subclasses:
DataNode, Doctype, Doctype.EntityNode, Doctype.NotationNode, ParentNode, PINode

abstract class NodeBase
extends Object
implements org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, XmlWritable

Base class for DOM parse tree nodes which may appear in XmlDocument nodes. This implements "parented by" and "owning document" relationships. If the parent is not null, this also supports sibling relationships through that parent. Children may be directly accessed through this class, although it is subclasses which implement that access.

Author:
David Brownell

Field Summary
(package private)  XmlDocument ownerDocument
           
private  ParentNode parent
           
private  int parentIndex
           
(package private)  boolean 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
(package private) NodeBase()
          Constructs a node which will later have its parent set by some other member of this package.
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 org.w3c.dom.NamedNodeMap getAttributes()
          DOM: returns null.
 org.w3c.dom.NodeList getChildNodes()
          DOM: Returns an object which permits "live" access to all this node's children.
 org.w3c.dom.Node getFirstChild()
          DOM: Returns null.
 int getIndexOf(org.w3c.dom.Node maybeChild)
          Returns the index of the node in the list of children, such that item() will return that child.
 String getInheritedAttribute(String name)
          Returns the value of a given attribute, tracing up through ancestors if needed.
 String getLanguage()
          Returns the language id (value of xml:lang attribute) applicable to this node, if known.
 org.w3c.dom.Node getLastChild()
          DOM: returns null.
 int getLength()
          DOM: Returns zero.
 String getLocalName()
          DOM2: returns null.
(package private)  String getMessage(String messageId)
           
(package private)  String getMessage(String messageId, Object[] parameters)
           
 String getNamespaceURI()
          DOM2: returns null.
 org.w3c.dom.Node getNextSibling()
          DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling.
 String getNodeValue()
          DOM: Returns null; overridden by subclasses as needed.
 org.w3c.dom.Document getOwnerDocument()
          DOM: Returns the document to which this node belongs.
(package private)  ParentNode getParentImpl()
           
 org.w3c.dom.Node getParentNode()
          DOM: Returns the node's parent.
 String getPrefix()
          DOM2: returns null.
 org.w3c.dom.Node getPreviousSibling()
          DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          DOM: Returns false.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 boolean isReadonly()
          Method to allow easy determination of whether a node is read only.
 boolean isSupported(String feature, String version)
          DOM2:
 org.w3c.dom.Node item(int i)
          DOM: Returns null.
 void normalize()
          DOM2: noop.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 void setNodeValue(String value)
          DOM: does nothing; overridden by subclasses as needed.
protected  void setOwnerDocument(XmlDocument doc)
           
(package private)  void setParentNode(ParentNode arg, int index)
           
 void setPrefix(String prefix)
          DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces.
 void setReadonly(boolean deep)
          Sets the node to be readonly; applies recursively to the children of this node if the parameter is true.
 void writeChildrenXml(XmlWriteContext context)
          Does nothing; this type of node has no children.
 
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
cloneNode, getNodeName, getNodeType
 
Methods inherited from interface org.apache.crimson.tree.XmlWritable
writeXml
 

Field Detail

parent

private ParentNode parent

parentIndex

private int parentIndex

ownerDocument

XmlDocument ownerDocument

readonly

boolean readonly
Constructor Detail

NodeBase

NodeBase()
Constructs a node which will later have its parent set by some other member of this package.

Method Detail

getParentImpl

ParentNode getParentImpl()

isReadonly

public boolean isReadonly()
Description copied from interface: NodeEx
Method to allow easy determination of whether a node is read only.

Specified by:
isReadonly in interface NodeEx
Returns:
true if the node is read only

setReadonly

public void setReadonly(boolean deep)
Description copied from interface: NodeEx
Sets the node to be readonly; applies recursively to the children of this node if the parameter is true.

Specified by:
setReadonly in interface NodeEx
Parameters:
deep - If true recursively set the nodes in the subtree under the current node to be read only. If false then set only the current node to be readonly

getLanguage

public String getLanguage()
Returns the language id (value of xml:lang attribute) applicable to this node, if known. Traces up through ancestors as needed.

Specified by:
getLanguage in interface NodeEx
Returns:
the value of the xml:lang attribute, or null if no such attribute is found.

getInheritedAttribute

public String getInheritedAttribute(String name)
Returns the value of a given attribute, tracing up through ancestors if needed. In the XML standard, two attributes are inherited: xml:lang and xml:space. This mechanism can also be involved with Cascading Style Sheets (CSS). The current version of XML Namespaces also uses inheritance.

Specified by:
getInheritedAttribute in interface NodeEx
Parameters:
name - identifies the attribute; colons may be included, but namespace prefixes are not interpreted
Returns:
the value of the inherited attribute, or null if no value was inherited.

writeChildrenXml

public void writeChildrenXml(XmlWriteContext context)
                      throws IOException
Does nothing; this type of node has no children.

Specified by:
writeChildrenXml in interface XmlWritable
Throws:
IOException

getParentNode

public org.w3c.dom.Node getParentNode()
DOM: Returns the node's parent. This will be null in cases such as newly created or removed nodes, and for attributes, fragments, and documents.

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

setParentNode

void setParentNode(ParentNode arg,
                   int index)
             throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

setOwnerDocument

protected void setOwnerDocument(XmlDocument doc)

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
DOM: Returns the document to which this node belongs.

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

hasChildNodes

public boolean hasChildNodes()
DOM: Returns false. Overridden by subclasses which support children.

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

setNodeValue

public void setNodeValue(String value)
DOM: does nothing; overridden by subclasses as needed.

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

getNodeValue

public String getNodeValue()
DOM: Returns null; overridden by subclasses as needed.

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

getFirstChild

public org.w3c.dom.Node getFirstChild()
DOM: Returns null. Overridden by subclasses which support children.

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

getLength

public int getLength()
DOM: Returns zero. Overridden by subclasses which support children.

Specified by:
getLength in interface org.w3c.dom.NodeList

item

public org.w3c.dom.Node item(int i)
DOM: Returns null. Overridden by subclasses which support children.

Specified by:
item in interface org.w3c.dom.NodeList

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
DOM: Returns an object which permits "live" access to all this node's children.

In this implementation, nodes provide such access without needing another node as an intermediary; "this" is returned.

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

getLastChild

public org.w3c.dom.Node getLastChild()
DOM: returns null. Overridden by subclasses which support children.

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

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
appendChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
insertBefore in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
replaceChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
removeChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

getNextSibling

public org.w3c.dom.Node getNextSibling()
DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling. In this implementation, sibling access from a node is slower than indexed access from its parent.

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

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling. In this implementation, sibling access from a node is slower than indexed access from its parent.

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

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
DOM: returns null. Overridden by the ElementNode2 subclass.

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

normalize

public void normalize()
DOM2: noop.

Specified by:
normalize in interface org.w3c.dom.Node
Since:
DOM Level 2 Overridden by subclasses that need to support normalization.

isSupported

public boolean isSupported(String feature,
                           String version)
DOM2:

Specified by:
isSupported in interface org.w3c.dom.Node
Since:
DOM Level 2

getNamespaceURI

public String getNamespaceURI()
DOM2: returns null. Overridden by subclasses that support namespaces, ie. ElementNode2 and AttributeNode.

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

getPrefix

public String getPrefix()
DOM2: returns null. Overridden by subclasses that support namespaces.

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

setPrefix

public void setPrefix(String prefix)
               throws org.w3c.dom.DOMException
DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces.

Specified by:
setPrefix in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getLocalName

public String getLocalName()
DOM2: returns null. Overridden by subclasses that support namespaces.

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

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes. Overridden by Element implementations

Specified by:
hasAttributes in interface org.w3c.dom.Node
Since:
DOM Level 2

getIndexOf

public int getIndexOf(org.w3c.dom.Node maybeChild)
Description copied from interface: NodeEx
Returns the index of the node in the list of children, such that item() will return that child.

Specified by:
getIndexOf in interface NodeEx
Parameters:
maybeChild - the node which may be a child of this one
Returns:
the index of the node in the set of children, or else -1 if that node is not a child of this node.

getMessage

String getMessage(String messageId)

getMessage

String getMessage(String messageId,
                  Object[] parameters)