org.apache.xalan.xsltc.dom
Class DOMImpl

java.lang.Object
  |
  +--org.apache.xalan.xsltc.dom.DOMImpl

public final class DOMImpl
extends java.lang.Object
implements DOM, java.io.Externalizable

See Also:
Serialized Form

Constructor Summary
DOMImpl()
          Constructor - defaults to 32K nodes
DOMImpl(int size)
          Constructor - defines initial size
 
Method Summary
 void characters(int textNode, TransletOutputHandler handler)
          Copy the contents of a text-node to an output handler
 void copy(int node, TransletOutputHandler handler)
          Performs a deep copy (ref.
 void copy(NodeIterator nodes, TransletOutputHandler handler)
          Copy a node-set to an output handler
 void copy(TransletOutputHandler handler)
          Copy the whole tree to an output handler
 int getAttributeNode(int type, int element)
          Returns the attribute node of a given type (if any) for an element
 int getAttributePosition(int attr)
           
 java.lang.String getAttributeValue(int type, int element)
          Returns the value of a given attribute type of a given element
 java.lang.String getAttributeValue(java.lang.String name, int element)
          This method is for testing/debugging only
 NodeIterator getAxisIterator(int axis)
          This is a shortcut to the iterators that implement the supported XPath axes (only namespace::) is not supported.
 DOMBuilder getBuilder()
          Returns an instance of the DOMBuilder inner class This class will consume the input document through a SAX2 interface and populate the tree.
 NodeIterator getChildren(int node)
          Returns an iterator with all the children of a given node
 java.lang.String getDocumentURI()
          Returns the origin of the document from which the tree was built
 java.lang.String getDocumentURI(int node)
           
 int getElementPosition(int node)
           
 java.lang.String getElementValue(int element)
          Returns the string value of any element
 int getGeneralizedType(java.lang.String name)
          Returns the internal type associated with an expaneded QName
 NodeIterator getIterator()
          Returns singleton iterator containg the document root Works for them main document (mark == 0)
 java.lang.String getLanguage(int node)
          Returns a node' defined language for a node (if any)
 short[] getMapping(java.lang.String[] names)
          Get mapping from DOM element/attribute types to external types
 NodeIterator getNamespaceAxisIterator(int axis, int ns)
          Do not thing that this returns an iterator for the namespace axis.
 short[] getNamespaceMapping(java.lang.String[] namespaces)
          Get mapping from DOM namespace types to external namespace types
 java.lang.String getNamespaceName(int node)
          Returns the namespace URI to which a node belongs
 int getNamespaceType(int node)
          Returns the namespace type of a specific node
 java.lang.String getNodeName(int node)
          Returns the name of a node (attribute or element).
 java.lang.String getNodeValue(int node)
          Returns the (String) value of any node in the tree
 NodeIterator getNodeValueIterator(NodeIterator iterator, int type, java.lang.String value, boolean op)
           
 NodeIterator getNthDescendant(int type, int n, boolean includeself)
          Returns the nth descendant of a node
 TransletOutputHandler getOutputDomBuilder()
          Returns a DOMBuilder class wrapped in a SAX adapter.
 int getParent(int node)
          Returns the parent of a node
 short[] getReverseMapping(java.lang.String[] names)
          Get mapping from external element/attribute types to DOM types
 short[] getReverseNamespaceMapping(java.lang.String[] namespaces)
          Get mapping from external namespace types to DOM namespace types
 int getSize()
          Returns the number of nodes in the tree (used for indexing)
 java.lang.String getStringValue()
          Returns the string value of the entire tree
 java.lang.String getTreeString()
           
 int getType(int node)
          Returns the type of a specific node
 short[] getTypeArray()
          Returns the node-to-type mapping array
 NodeIterator getTypedAxisIterator(int axis, int type)
          Similar to getAxisIterator, but this one returns an iterator containing nodes of a typed axis (ex.: child::foo)
 NodeIterator getTypedChildren(int type)
          Returns an iterator with all children of a specific type for a given node (element)
 NodeIterator getTypedDescendantIterator(int type)
          Returns an iterator with all descendants of a node that are of a given type.
 int getTypedLast(int type, int node)
          Returns an iterator's last node of a given type
 int getTypedPosition(int type, int node)
          Returns a node's position amongst other nodes of the same type
 Filter getTypeFilter(int type)
          Returns a node type filter (implementation of Filter)
 boolean hasAttribute(int type, int node)
          Returns true if a given element has an attribute of a given type
 boolean isAttribute(int node)
          Returns 'true' if a specific node is an element (of any type)
 boolean isElement(int node)
          Returns 'true' if a specific node is an element (of any type)
 boolean lessThan(int node1, int node2)
          Returns true if node1 comes before node2 in document order
 Node makeNode(int index)
          Create an org.w3c.dom.Node from a node in the tree
 Node makeNode(NodeIterator iter)
          Create an org.w3c.dom.Node from a node in an iterator The iterator most be started before this method is called
 NodeList makeNodeList(int index)
          Create an org.w3c.dom.NodeList from a node in the tree
 NodeList makeNodeList(NodeIterator iter)
          Create an org.w3c.dom.NodeList from a node iterator The iterator most be started before this method is called
 NodeIterator orderNodes(NodeIterator source, int node)
          Encapsulates an iterator in an OrderedIterator to ensure node order
 void print(int node, int level)
          Prints the whole tree to standard output
 void readExternal(java.io.ObjectInput in)
          Read the whole tree from a file (serialized)
 void setDocumentURI(java.lang.String uri)
          Define the origin of the document from which the tree was built
 void setFilter(StripFilter filter)
          Part of the DOM interface - no function here.
 void setupMapping(java.lang.String[] names, java.lang.String[] namespaces)
           
 java.lang.String shallowCopy(int node, TransletOutputHandler handler)
          Performs a shallow copy (ref.
 NodeIterator strippingIterator(NodeIterator iterator, short[] mapping, StripFilter filter)
           
 void writeExternal(java.io.ObjectOutput out)
          Dump the whole tree to a file (serialized)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMImpl

public DOMImpl()
Constructor - defaults to 32K nodes

DOMImpl

public DOMImpl(int size)
Constructor - defines initial size
Method Detail

setDocumentURI

public void setDocumentURI(java.lang.String uri)
Define the origin of the document from which the tree was built

getDocumentURI

public java.lang.String getDocumentURI()
Returns the origin of the document from which the tree was built

getDocumentURI

public java.lang.String getDocumentURI(int node)
Specified by:
getDocumentURI in interface DOM

setupMapping

public void setupMapping(java.lang.String[] names,
                         java.lang.String[] namespaces)
Specified by:
setupMapping in interface DOM

isElement

public boolean isElement(int node)
Returns 'true' if a specific node is an element (of any type)
Specified by:
isElement in interface DOM

isAttribute

public boolean isAttribute(int node)
Returns 'true' if a specific node is an element (of any type)
Specified by:
isAttribute in interface DOM

getSize

public int getSize()
Returns the number of nodes in the tree (used for indexing)
Specified by:
getSize in interface DOM

setFilter

public void setFilter(StripFilter filter)
Part of the DOM interface - no function here.
Specified by:
setFilter in interface DOM

lessThan

public boolean lessThan(int node1,
                        int node2)
Returns true if node1 comes before node2 in document order
Specified by:
lessThan in interface DOM

makeNode

public Node makeNode(int index)
Create an org.w3c.dom.Node from a node in the tree
Specified by:
makeNode in interface DOM

makeNode

public Node makeNode(NodeIterator iter)
Create an org.w3c.dom.Node from a node in an iterator The iterator most be started before this method is called
Specified by:
makeNode in interface DOM

makeNodeList

public NodeList makeNodeList(int index)
Create an org.w3c.dom.NodeList from a node in the tree
Specified by:
makeNodeList in interface DOM

makeNodeList

public NodeList makeNodeList(NodeIterator iter)
Create an org.w3c.dom.NodeList from a node iterator The iterator most be started before this method is called
Specified by:
makeNodeList in interface DOM

getTypeFilter

public Filter getTypeFilter(int type)
Returns a node type filter (implementation of Filter)

strippingIterator

public NodeIterator strippingIterator(NodeIterator iterator,
                                      short[] mapping,
                                      StripFilter filter)

getNodeValueIterator

public NodeIterator getNodeValueIterator(NodeIterator iterator,
                                         int type,
                                         java.lang.String value,
                                         boolean op)
Specified by:
getNodeValueIterator in interface DOM

orderNodes

public NodeIterator orderNodes(NodeIterator source,
                               int node)
Encapsulates an iterator in an OrderedIterator to ensure node order
Specified by:
orderNodes in interface DOM

getParent

public int getParent(int node)
Returns the parent of a node
Specified by:
getParent in interface DOM

getElementPosition

public int getElementPosition(int node)

getAttributePosition

public int getAttributePosition(int attr)

getTypedPosition

public int getTypedPosition(int type,
                            int node)
Returns a node's position amongst other nodes of the same type
Specified by:
getTypedPosition in interface DOM

getTypedLast

public int getTypedLast(int type,
                        int node)
Returns an iterator's last node of a given type
Specified by:
getTypedLast in interface DOM

getIterator

public NodeIterator getIterator()
Returns singleton iterator containg the document root Works for them main document (mark == 0)
Specified by:
getIterator in interface DOM

getType

public int getType(int node)
Returns the type of a specific node
Specified by:
getType in interface DOM

getNamespaceType

public int getNamespaceType(int node)
Returns the namespace type of a specific node
Specified by:
getNamespaceType in interface DOM

getTypeArray

public short[] getTypeArray()
Returns the node-to-type mapping array

getNodeValue

public java.lang.String getNodeValue(int node)
Returns the (String) value of any node in the tree
Specified by:
getNodeValue in interface DOM

getGeneralizedType

public int getGeneralizedType(java.lang.String name)
Returns the internal type associated with an expaneded QName

getMapping

public short[] getMapping(java.lang.String[] names)
Get mapping from DOM element/attribute types to external types

getReverseMapping

public short[] getReverseMapping(java.lang.String[] names)
Get mapping from external element/attribute types to DOM types

getNamespaceMapping

public short[] getNamespaceMapping(java.lang.String[] namespaces)
Get mapping from DOM namespace types to external namespace types

getReverseNamespaceMapping

public short[] getReverseNamespaceMapping(java.lang.String[] namespaces)
Get mapping from external namespace types to DOM namespace types

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Dump the whole tree to a file (serialized)
Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read the whole tree from a file (serialized)
Specified by:
readExternal in interface java.io.Externalizable

print

public void print(int node,
                  int level)
Prints the whole tree to standard output

getNodeName

public java.lang.String getNodeName(int node)
Returns the name of a node (attribute or element).
Specified by:
getNodeName in interface DOM

getNamespaceName

public java.lang.String getNamespaceName(int node)
Returns the namespace URI to which a node belongs
Specified by:
getNamespaceName in interface DOM

getAttributeNode

public int getAttributeNode(int type,
                            int element)
Returns the attribute node of a given type (if any) for an element
Specified by:
getAttributeNode in interface DOM

getAttributeValue

public java.lang.String getAttributeValue(int type,
                                          int element)
Returns the value of a given attribute type of a given element

hasAttribute

public boolean hasAttribute(int type,
                            int node)
Returns true if a given element has an attribute of a given type

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name,
                                          int element)
This method is for testing/debugging only

getChildren

public NodeIterator getChildren(int node)
Returns an iterator with all the children of a given node
Specified by:
getChildren in interface DOM

getTypedChildren

public NodeIterator getTypedChildren(int type)
Returns an iterator with all children of a specific type for a given node (element)
Specified by:
getTypedChildren in interface DOM

getAxisIterator

public NodeIterator getAxisIterator(int axis)
This is a shortcut to the iterators that implement the supported XPath axes (only namespace::) is not supported. Returns a bare-bones iterator that must be initialized with a start node (using iterator.setStartNode()).
Specified by:
getAxisIterator in interface DOM

getTypedAxisIterator

public NodeIterator getTypedAxisIterator(int axis,
                                         int type)
Similar to getAxisIterator, but this one returns an iterator containing nodes of a typed axis (ex.: child::foo)
Specified by:
getTypedAxisIterator in interface DOM

getNamespaceAxisIterator

public NodeIterator getNamespaceAxisIterator(int axis,
                                             int ns)
Do not thing that this returns an iterator for the namespace axis. It returns an iterator with nodes that belong in a certain namespace, such as with The 'axis' specifies the axis for the base iterator from which the nodes are taken, while 'ns' specifies the namespace URI type.
Specified by:
getNamespaceAxisIterator in interface DOM

getTypedDescendantIterator

public NodeIterator getTypedDescendantIterator(int type)
Returns an iterator with all descendants of a node that are of a given type.

getNthDescendant

public NodeIterator getNthDescendant(int type,
                                     int n,
                                     boolean includeself)
Returns the nth descendant of a node
Specified by:
getNthDescendant in interface DOM

characters

public void characters(int textNode,
                       TransletOutputHandler handler)
                throws TransletException
Copy the contents of a text-node to an output handler
Specified by:
characters in interface DOM

copy

public void copy(NodeIterator nodes,
                 TransletOutputHandler handler)
          throws TransletException
Copy a node-set to an output handler
Specified by:
copy in interface DOM

copy

public void copy(TransletOutputHandler handler)
          throws TransletException
Copy the whole tree to an output handler

copy

public void copy(int node,
                 TransletOutputHandler handler)
          throws TransletException
Performs a deep copy (ref. XSLs copy-of()) TODO: Copy namespace declarations. Can't be done until we add namespace nodes and keep track of NS prefixes TODO: Copy comment nodes
Specified by:
copy in interface DOM

shallowCopy

public java.lang.String shallowCopy(int node,
                                    TransletOutputHandler handler)
                             throws TransletException
Performs a shallow copy (ref. XSLs copy())
Specified by:
shallowCopy in interface DOM

getStringValue

public java.lang.String getStringValue()
Returns the string value of the entire tree
Specified by:
getStringValue in interface DOM

getElementValue

public java.lang.String getElementValue(int element)
Returns the string value of any element

getTreeString

public java.lang.String getTreeString()
Specified by:
getTreeString in interface DOM

getLanguage

public java.lang.String getLanguage(int node)
Returns a node' defined language for a node (if any)
Specified by:
getLanguage in interface DOM

getBuilder

public DOMBuilder getBuilder()
Returns an instance of the DOMBuilder inner class This class will consume the input document through a SAX2 interface and populate the tree.

getOutputDomBuilder

public TransletOutputHandler getOutputDomBuilder()
Returns a DOMBuilder class wrapped in a SAX adapter. I am not sure if we need this one anymore now that the DOM builder's interface is pure SAX2 (must investigate)


Copyright © 2001 Apache XML Project. All Rights Reserved.