org.apache.batik.dom
Class AbstractNode

java.lang.Object
  |
  +--org.apache.batik.dom.AbstractNode
All Implemented Interfaces:
EventTarget, ExtendedNode, Node, NodeEventTarget, java.io.Serializable
Direct Known Subclasses:
AbstractChildNode, AbstractNotation, AbstractParentNode

public abstract class AbstractNode
extends java.lang.Object
implements ExtendedNode, java.io.Serializable

This class implements the Node interface.

See Also:
Serialized Form

Field Summary
protected static NodeList EMPTY_NODE_LIST
          An empty instance of NodeList.
protected  EventSupport eventSupport
          The event support.
protected  AbstractDocument ownerDocument
          The owner document.
 
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
AbstractNode()
           
 
Method Summary
 void addEventListener(java.lang.String type, EventListener listener, boolean useCapture)
          DOM: Implements EventTarget.addEventListener(String,EventListener,boolean).
 Node appendChild(Node newChild)
          DOM: Implements Node.appendChild(Node).
protected  void checkChildType(Node n, boolean replace)
          Checks the validity of a node to be inserted.
 Node cloneNode(boolean deep)
          DOM: Implements Node.cloneNode(boolean).
protected  Node copyInto(Node n)
          Copy the fields of the current node into the given node.
 DOMException createDOMException(short type, java.lang.String key, java.lang.Object[] args)
          Creates an exception with the appropriate error message.
protected  Node deepCopyInto(Node n)
          Deeply copy the fields of the current node into the given node.
protected  Node deepExport(Node n, AbstractDocument d)
          Deeply exports this node to the given document.
 boolean dispatchEvent(Event evt)
          DOM: Implements EventTarget.dispatchEvent(Event).
protected  Node export(Node n, AbstractDocument d)
          Exports this node to the given document.
protected  void fireDOMCharacterDataModifiedEvent(java.lang.String oldv, java.lang.String newv)
          Fires a DOMCharacterDataModified event.
 void fireDOMNodeInsertedIntoDocumentEvent()
          Recursively fires a DOMNodeInsertedIntoDocument event.
 void fireDOMNodeRemovedFromDocumentEvent()
          Recursively fires a DOMNodeRemovedFromDocument event.
 NamedNodeMap getAttributes()
          DOM: Implements Node.getAttributes().
 NodeList getChildNodes()
          DOM: Implements Node.getChildNodes().
protected  AbstractDocument getCurrentDocument()
          Returns the current document.
 EventSupport getEventSupport()
          Returns the event support instance for this node, or null if any.
 Node getFirstChild()
          DOM: Implements Node.getFirstChild().
 Node getLastChild()
          DOM: Implements Node.getLastChild().
 java.lang.String getLocalName()
          DOM: Implements Node.getLocalName().
 java.lang.String getNamespaceURI()
          DOM: Implements Node.getNamespaceURI().
 Node getNextSibling()
          DOM: Implements Node.getNextSibling().
 java.lang.String getNodeValue()
          DOM: Implements Node.getNodeValue().
 Document getOwnerDocument()
          DOM: Implements Node.getOwnerDocument().
 Node getParentNode()
          DOM: Implements Node.getParentNode().
 NodeEventTarget getParentNodeEventTarget()
          Implements NodeEventTarget.getParentNodeEventTarget().
 java.lang.String getPrefix()
          DOM: Implements Node.getPrefix().
 Node getPreviousSibling()
          DOM: Implements Node.getPreviousSibling().
 boolean hasAttributes()
          DOM: Implements Node.hasAttributes().
 boolean hasChildNodes()
          DOM: Implements Node.hasChildNodes().
 Node insertBefore(Node newChild, Node refChild)
          DOM: Implements Node.insertBefore(Node, Node).
 boolean isSupported(java.lang.String feature, java.lang.String version)
          DOM: Implements Node.isSupported(String,String).
protected abstract  Node newNode()
          Returns a new uninitialized instance of this object's class.
 void normalize()
          DOM: Implements Node.normalize().
 Node removeChild(Node oldChild)
          DOM: Implements Node.removeChild(Node).
 void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture)
          DOM: Implements EventTarget.removeEventListener(String,EventListener,boolean).
 Node replaceChild(Node newChild, Node oldChild)
          DOM: Implements Node.replaceChild(Node, Node).
 void setNextSibling(Node n)
          Sets the node immediately following this node.
 void setNodeName(java.lang.String v)
          Sets the name of this node.
 void setNodeValue(java.lang.String nodeValue)
          DOM: Implements Node.setNodeValue(String).
 void setOwnerDocument(Document doc)
          Sets the owner document of this node.
 void setParentNode(Node v)
          Sets the parent node.
 void setPrefix(java.lang.String prefix)
          DOM: Implements Node.setPrefix(String).
 void setPreviousSibling(Node n)
          Sets the node immediately preceding this node.
 void setSpecified(boolean v)
          Sets the value of the specified attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.batik.dom.ExtendedNode
isReadonly, setReadonly
 
Methods inherited from interface org.w3c.dom.Node
getNodeName, getNodeType
 

Field Detail

EMPTY_NODE_LIST

protected static final NodeList EMPTY_NODE_LIST
An empty instance of NodeList.

ownerDocument

protected AbstractDocument ownerDocument
The owner document.

eventSupport

protected transient EventSupport eventSupport
The event support.
Constructor Detail

AbstractNode

public AbstractNode()
Method Detail

setNodeName

public void setNodeName(java.lang.String v)
Sets the name of this node. Do nothing.
Specified by:
setNodeName in interface ExtendedNode

setOwnerDocument

public void setOwnerDocument(Document doc)
Sets the owner document of this node.
Specified by:
setOwnerDocument in interface ExtendedNode

setSpecified

public void setSpecified(boolean v)
Sets the value of the specified attribute. This method only applies to Attr objects.
Specified by:
setSpecified in interface ExtendedNode

getNodeValue

public java.lang.String getNodeValue()
                              throws DOMException
DOM: Implements Node.getNodeValue().
Specified by:
getNodeValue in interface Node
Returns:
null.

setNodeValue

public void setNodeValue(java.lang.String nodeValue)
                  throws DOMException
DOM: Implements Node.setNodeValue(String). Do nothing.
Specified by:
setNodeValue in interface Node

getParentNode

public Node getParentNode()
DOM: Implements Node.getParentNode().
Specified by:
getParentNode in interface Node
Returns:
null.

setParentNode

public void setParentNode(Node v)
Sets the parent node. Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
setParentNode in interface ExtendedNode

getChildNodes

public NodeList getChildNodes()
DOM: Implements Node.getChildNodes().
Specified by:
getChildNodes in interface Node
Returns:
EMPTY_NODE_LIST.

getFirstChild

public Node getFirstChild()
DOM: Implements Node.getFirstChild().
Specified by:
getFirstChild in interface Node
Returns:
null.

getLastChild

public Node getLastChild()
DOM: Implements Node.getLastChild().
Specified by:
getLastChild in interface Node
Returns:
null.

setPreviousSibling

public void setPreviousSibling(Node n)
Sets the node immediately preceding this node. Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
setPreviousSibling in interface ExtendedNode

getPreviousSibling

public Node getPreviousSibling()
DOM: Implements Node.getPreviousSibling().
Specified by:
getPreviousSibling in interface Node
Returns:
null.

setNextSibling

public void setNextSibling(Node n)
Sets the node immediately following this node. Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
setNextSibling in interface ExtendedNode

getNextSibling

public Node getNextSibling()
DOM: Implements Node.getNextSibling().
Specified by:
getNextSibling in interface Node
Returns:
null.

hasAttributes

public boolean hasAttributes()
DOM: Implements Node.hasAttributes().
Specified by:
hasAttributes in interface Node
Returns:
false.

getAttributes

public NamedNodeMap getAttributes()
DOM: Implements Node.getAttributes().
Specified by:
getAttributes in interface Node
Returns:
null.

getOwnerDocument

public Document getOwnerDocument()
DOM: Implements Node.getOwnerDocument().
Specified by:
getOwnerDocument in interface Node
Returns:
ownerDocument.

getNamespaceURI

public java.lang.String getNamespaceURI()
DOM: Implements Node.getNamespaceURI().
Specified by:
getNamespaceURI in interface Node
Returns:
null.

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
DOM: Implements Node.insertBefore(Node, Node). Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
insertBefore in interface Node
Following copied from interface: org.w3c.dom.Node
Parameters:
newChildThe - node to insert.
refChildThe - reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild is not a child of this node.

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
DOM: Implements Node.replaceChild(Node, Node). Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
replaceChild in interface Node
Following copied from interface: org.w3c.dom.Node
Parameters:
newChildThe - new node to put in the child list.
oldChildThe - node being replaced in the list.
Returns:
The node replaced.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to put in is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
DOM: Implements Node.removeChild(Node). Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
removeChild in interface Node
Following copied from interface: org.w3c.dom.Node
Parameters:
oldChildThe - node being removed.
Returns:
The node removed.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
DOM: Implements Node.appendChild(Node). Throws a HIERARCHY_REQUEST_ERR DOMException.
Specified by:
appendChild in interface Node
Following copied from interface: org.w3c.dom.Node
Parameters:
newChildThe - node to add.If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node
Returns:
The node added.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

hasChildNodes

public boolean hasChildNodes()
DOM: Implements Node.hasChildNodes().
Specified by:
hasChildNodes in interface Node
Returns:
false.

cloneNode

public Node cloneNode(boolean deep)
DOM: Implements Node.cloneNode(boolean).
Specified by:
cloneNode in interface Node
Following copied from interface: org.w3c.dom.Node
Parameters:
deepIf - true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
Returns:
The duplicate node.

normalize

public void normalize()
DOM: Implements Node.normalize(). Do nothing.
Specified by:
normalize in interface Node

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
DOM: Implements Node.isSupported(String,String).
Specified by:
isSupported in interface Node
Following copied from interface: org.w3c.dom.Node
Parameters:
featureThe - name of the feature to test. This is the same name which can be passed to the method hasFeature on DOMImplementation.
versionThis - is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return true.
Returns:
Returns true if the specified feature is supported on this node, false otherwise.

getPrefix

public java.lang.String getPrefix()
DOM: Implements Node.getPrefix().
Specified by:
getPrefix in interface Node
Following copied from interface: org.w3c.dom.Node
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the specified prefix is malformed, if the namespaceURI of this node is null, if the specified prefix is "xml" and the namespaceURI of this node is different from " http://www.w3.org/XML/1998/namespace", if this node is an attribute and the specified prefix is "xmlns" and the namespaceURI of this node is different from " http://www.w3.org/2000/xmlns/", or if this node is an attribute and the qualifiedName of this node is "xmlns" .

setPrefix

public void setPrefix(java.lang.String prefix)
               throws DOMException
DOM: Implements Node.setPrefix(String).
Specified by:
setPrefix in interface Node

getLocalName

public java.lang.String getLocalName()
DOM: Implements Node.getLocalName().
Specified by:
getLocalName in interface Node

createDOMException

public DOMException createDOMException(short type,
                                       java.lang.String key,
                                       java.lang.Object[] args)
Creates an exception with the appropriate error message.

addEventListener

public void addEventListener(java.lang.String type,
                             EventListener listener,
                             boolean useCapture)
DOM: Implements EventTarget.addEventListener(String,EventListener,boolean).
Specified by:
addEventListener in interface EventTarget
Following copied from interface: org.w3c.dom.events.EventTarget
Parameters:
typeThe - event type for which the user is registering
listenerThe - listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
useCaptureIf - true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.

removeEventListener

public void removeEventListener(java.lang.String type,
                                EventListener listener,
                                boolean useCapture)
DOM: Implements EventTarget.removeEventListener(String,EventListener,boolean).
Specified by:
removeEventListener in interface EventTarget
Following copied from interface: org.w3c.dom.events.EventTarget
Parameters:
typeSpecifies - the event type of the EventListener being removed.
listenerThe - EventListener parameter indicates the EventListener to be removed.
useCaptureSpecifies - whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.

getParentNodeEventTarget

public NodeEventTarget getParentNodeEventTarget()
Implements NodeEventTarget.getParentNodeEventTarget().
Specified by:
getParentNodeEventTarget in interface NodeEventTarget

dispatchEvent

public boolean dispatchEvent(Event evt)
                      throws EventException
DOM: Implements EventTarget.dispatchEvent(Event).
Specified by:
dispatchEvent in interface EventTarget
Following copied from interface: org.w3c.dom.events.EventTarget
Parameters:
evtSpecifies - the event type, behavior, and contextual information to be used in processing the event.
Returns:
The return value of dispatchEvent indicates whether any of the listeners which handled the event called preventDefault. If preventDefault was called the value is false, else the value is true.
Throws:
EventException - UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type was not specified by initializing the event before dispatchEvent was called. Specification of the Event's type as null or an empty string will also trigger this exception.

getEventSupport

public EventSupport getEventSupport()
Returns the event support instance for this node, or null if any.
Specified by:
getEventSupport in interface NodeEventTarget

fireDOMNodeInsertedIntoDocumentEvent

public void fireDOMNodeInsertedIntoDocumentEvent()
Recursively fires a DOMNodeInsertedIntoDocument event.

fireDOMNodeRemovedFromDocumentEvent

public void fireDOMNodeRemovedFromDocumentEvent()
Recursively fires a DOMNodeRemovedFromDocument event.

fireDOMCharacterDataModifiedEvent

protected void fireDOMCharacterDataModifiedEvent(java.lang.String oldv,
                                                 java.lang.String newv)
Fires a DOMCharacterDataModified event.

getCurrentDocument

protected AbstractDocument getCurrentDocument()
Returns the current document.

newNode

protected abstract Node newNode()
Returns a new uninitialized instance of this object's class.

export

protected Node export(Node n,
                      AbstractDocument d)
Exports this node to the given document.

deepExport

protected Node deepExport(Node n,
                          AbstractDocument d)
Deeply exports this node to the given document.

copyInto

protected Node copyInto(Node n)
Copy the fields of the current node into the given node.
Parameters:
n - a node of the type of this.

deepCopyInto

protected Node deepCopyInto(Node n)
Deeply copy the fields of the current node into the given node.
Parameters:
n - a node of the type of this.

checkChildType

protected void checkChildType(Node n,
                              boolean replace)
Checks the validity of a node to be inserted.


Copyright © 2002 Apache Software Foundation. All Rights Reserved.