org.apache.crimson.tree
Class XmlDocument.DocFragNode

java.lang.Object
  extended byorg.apache.crimson.tree.NodeBase
      extended byorg.apache.crimson.tree.ParentNode
          extended byorg.apache.crimson.tree.XmlDocument.DocFragNode
All Implemented Interfaces:
org.w3c.dom.DocumentFragment, org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, XmlWritable
Enclosing class:
XmlDocument

static final class XmlDocument.DocFragNode
extends ParentNode
implements org.w3c.dom.DocumentFragment


Nested Class Summary
(package private)  class ParentNode.TagList
           
(package private)  class ParentNode.TagListNS
           
 
Field Summary
(package private)  XmlDocument ownerDocument
           
(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) XmlDocument.DocFragNode()
           
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          DOM: Appends the child to the set of this node's children.
(package private)  void checkChildType(int type)
           
 org.w3c.dom.Node cloneNode(boolean deep)
           
 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.NodeList getElementsByTagName(String tagname)
          DOM: Returns a "live" list view of the elements below this one which have the specified tag name.
 org.w3c.dom.NodeList getElementsByTagNameNS(String namespaceURI, String localName)
           
 org.w3c.dom.Node getFirstChild()
          DOM: Returns the first child of this node, else null if there are no children.
 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 the last child of this node, else null if there are no children.
 int getLength()
          DOM: Returns the number of children
 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 getNodeName()
           
 short getNodeType()
           
 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 true if there are children to this node.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Inserts the new child before the specified child, which if null indicates appending the new child to the current set of children.
 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 the Nth child, or null
 void normalize()
          DOM2: noop.
(package private)  void reduceWaste()
           
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          DOM: removes child if present, returning argument.
 int removeWhiteSpaces(char[] buf)
           
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Replaces the specified child with the new node, returning the original child or throwing an exception.
 void setNodeValue(String value)
          DOM: does nothing; overridden by subclasses as needed.
protected  void setOwnerDocument(XmlDocument doc)
           
 void setParentNode(org.w3c.dom.Node p)
           
(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 trimToSize()
          Called to minimize space utilization.
 void writeChildrenXml(XmlWriteContext context)
          Writes each of the child nodes.
 void writeXml(XmlWriteContext context)
          This is the primary method used to write an object and its children as XML text.
 
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, getNextSibling, getNodeValue, getOwnerDocument, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

ownerDocument

XmlDocument ownerDocument

readonly

boolean readonly
Constructor Detail

XmlDocument.DocFragNode

XmlDocument.DocFragNode()
Method Detail

checkChildType

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

writeXml

public void writeXml(XmlWriteContext context)
              throws IOException
Description copied from interface: XmlWritable
This is the primary method used to write an object and its children as XML text. Implementations with children should use writeChildrenXml to write those children, to allow selective overriding.

Specified by:
writeXml in interface XmlWritable
Throws:
IOException

getParentNode

public org.w3c.dom.Node getParentNode()
Description copied from class: NodeBase
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
Overrides:
getParentNode in class NodeBase

setParentNode

public void setParentNode(org.w3c.dom.Node p)

getNodeType

public short getNodeType()
Specified by:
getNodeType in interface org.w3c.dom.Node

getNodeName

public String getNodeName()
Specified by:
getNodeName in interface org.w3c.dom.Node

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Specified by:
cloneNode in interface org.w3c.dom.Node

trimToSize

public void trimToSize()
Called to minimize space utilization. Affects only this node; children must be individually trimmed.


reduceWaste

void reduceWaste()

writeChildrenXml

public void writeChildrenXml(XmlWriteContext context)
                      throws IOException
Writes each of the child nodes. For element nodes, this adds whitespace to indent non-text children (it prettyprints) unless the xml:space='preserve' attribute applies, or the write context disables prettyprinting.

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

hasChildNodes

public final boolean hasChildNodes()
DOM: Returns true if there are children to this node.

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

getFirstChild

public final org.w3c.dom.Node getFirstChild()
DOM: Returns the first child of this node, else null if there are no children.

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

getLastChild

public final org.w3c.dom.Node getLastChild()
DOM: Returns the last child of this node, else null if there are no children.

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

getLength

public final int getLength()
DOM: Returns the number of children

Specified by:
getLength in interface org.w3c.dom.NodeList
Overrides:
getLength in class NodeBase

item

public final org.w3c.dom.Node item(int i)
DOM: Returns the Nth child, or null

Specified by:
item in interface org.w3c.dom.NodeList
Overrides:
item in class NodeBase

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
DOM: Appends the child to the set of this node's children. The new child must belong to this document.

Specified by:
appendChild in interface org.w3c.dom.Node
Overrides:
appendChild in class NodeBase
Parameters:
newChild - the new child to be appended
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: Inserts the new child before the specified child, which if null indicates appending the new child to the current set of children. The new child must belong to this particular document. If the newChild is already in the tree, it is first removed.

Specified by:
insertBefore in interface org.w3c.dom.Node
Overrides:
insertBefore in class NodeBase
Parameters:
newChild - the new child to be inserted
refChild - node before which newChild is to be inserted
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: Replaces the specified child with the new node, returning the original child or throwing an exception. The new child must belong to this particular document. If the newChild is already in the tree, it is first removed.

Specified by:
replaceChild in interface org.w3c.dom.Node
Overrides:
replaceChild in class NodeBase
Parameters:
newChild - the new child to be inserted
refChild - node which is to be replaced
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: removes child if present, returning argument.

Specified by:
removeChild in interface org.w3c.dom.Node
Overrides:
removeChild in class NodeBase
Parameters:
oldChild - the node which is to be removed
Throws:
org.w3c.dom.DOMException - thrown always.

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(String tagname)
DOM: Returns a "live" list view of the elements below this one which have the specified tag name. Because this is "live", this API is dangerous -- indices are not stable in the face of most tree updates. Use a TreeWalker instead.

Parameters:
tagname - the tag name to show; or "*" for all elements.
Returns:
list of such elements

getElementsByTagNameNS

public org.w3c.dom.NodeList getElementsByTagNameNS(String namespaceURI,
                                                   String localName)
Since:
DOM Level 2

getIndexOf

public final 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.

Specified by:
getIndexOf in interface NodeEx
Overrides:
getIndexOf in class NodeBase
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

normalize

public void normalize()
Description copied from class: NodeBase
DOM2: noop.

Specified by:
normalize in interface org.w3c.dom.Node
Overrides:
normalize in class NodeBase
Since:
DOM Level 2 In DOM2, normalize() was generalized and got moved to Node. XXX Comments below are old: DOM2: Merges all adjacent Text nodes in the tree rooted by this element. Avoid using this on large blocks of text not separated by markup such as elements or processing instructions, since it can require arbitrarily large blocks of contiguous memory. XXX The following extension breaks a DOM conformance test so the code has been modified to not behave as described:

As a compatible extension to DOM, this normalizes treatment of whitespace except when the xml:space='preserve' attribute value applies to a node. All whitespace is normalized to one space. This ensures that text which is pretty-printed and then reread (and normalized) retains the same content.


removeWhiteSpaces

public int removeWhiteSpaces(char[] buf)

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.

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

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

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

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

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

getMessage

String getMessage(String messageId)

getMessage

String getMessage(String messageId,
                  Object[] parameters)