APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.dom

public Class AdaptiveResultTreeImpl

extends SimpleResultTreeImpl
Class Inheritance
Imports
com.sun.org.apache.xalan.internal.xsltc.DOM, .StripFilter, .TransletException, com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary, com.sun.org.apache.xml.internal.dtm.DTMAxisIterator, .DTMAxisTraverser, .DTMWSFilter, com.sun.org.apache.xml.internal.serializer.SerializationHandler, com.sun.org.apache.xml.internal.utils.XMLString, java.util.Map, javax.xml.transform.SourceLocator, org.w3c.dom.Node, .NodeList, org.xml.sax.Attributes, .SAXException, org.xml.sax.helpers.AttributesImpl

AdaptiveResultTreeImpl is a adaptive DOM model for result tree fragments (RTF). It is used in the case where the RTF is likely to be pure text yet it can still be a DOM tree. It is designed for RTFs which have <xsl:call-template> or <xsl:apply-templates> in the contents. Example:
   <xsl:variable name = "x">
     <xsl:call-template name = "test">
        <xsl:with-param name="a" select="."/>
     </xsl:call-template>
   </xsl:variable>

In this example the result produced by <xsl:call-template> is likely to be a single Text node. But it can also be a DOM tree. This kind of RTF cannot be modelled by SimpleResultTreeImpl.

AdaptiveResultTreeImpl can be considered as a smart switcher between SimpleResultTreeImpl and SAXImpl. It treats the RTF as simple Text and uses the SimpleResultTreeImpl model at the beginning. However, if it receives a call which indicates that this is a DOM tree (e.g. startElement), it will automatically transform itself into a wrapper around a SAXImpl. In this way we can have a light-weight model when the result only contains simple text, while at the same time it still works when the RTF is a DOM tree.

All methods in this class are overridden to delegate the action to the wrapped SAXImpl object if it is non-null, or delegate the action to the SimpleResultTreeImpl if there is no wrapped SAXImpl.

%REVISIT% Can we combine this class with SimpleResultTreeImpl? I think it is possible, but it will make SimpleResultTreeImpl more expensive. I will use two separate classes at this time.

Field Summary

Modifier and TypeField and Description
private final AttributesImpl
private boolean
private static int
private SAXImpl
private int
private String
private DTMWSFilter
_wsfilter

The following fields are only used for the nested SAXImpl

private static final String
Inherited from com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl:
_dtmManager_size_textArrayNUMBER_OF_NODESRTF_ROOTRTF_TEXT

Constructor Summary

AccessConstructor and Description
public
AdaptiveResultTreeImpl(XSLTCDTMManager dtmManager, int documentID, DTMWSFilter wsfilter, int initSize, boolean buildIdIndex)

Method Summary

Modifier and TypeMethod and Description
public void
public void
addAttribute(String uri, String localName, String qname, String type, String value)

Overrides com.sun.org.apache.xml.internal.serializer.EmptySerializer.addAttribute.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.addAttribute.

Add at attribute to the current element, not from an xsl:attribute element.

public void
public void
appendChild(int newChild, boolean clone, boolean cloneDepth)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.appendChild.

Implements com.sun.org.apache.xml.internal.dtm.DTM.appendChild.

Append a child to "the end of the document".

public void
appendTextChild(String str)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.appendTextChild.

Implements com.sun.org.apache.xml.internal.dtm.DTM.appendTextChild.

Append a text node child that will be constructed from a string, to the end of the document.

public void
characters(final int node, SerializationHandler handler)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters.

Implements com.sun.org.apache.xalan.internal.xsltc.DOM.characters.

Dispatch the character content of a node to an output handler.

public void
characters(String str)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.characters.

This method is used to notify of a character event, but passing the data as a character String rather than the standard character array.

public void
characters(char[] ch, int offset, int length)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters.

Implements org.xml.sax.ContentHandler.characters.

Receive notification of character data.

public void
public void
comment(char[] chars, int offset, int length)

Overrides com.sun.org.apache.xml.internal.serializer.EmptySerializer.comment.

Implements org.xml.sax.ext.LexicalHandler.comment.

Report an XML comment anywhere in the document.

public void
public void
public void
dispatchCharactersEvents(int nodeHandle, ContentHandler ch, boolean normalize)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.dispatchCharactersEvents.

Implements com.sun.org.apache.xml.internal.dtm.DTM.dispatchCharactersEvents.

Directly call the characters method on the passed ContentHandler for the string-value of the given node (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value).

public void
dispatchToEvents(int nodeHandle, ContentHandler ch)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.dispatchToEvents.

Implements com.sun.org.apache.xml.internal.dtm.DTM.dispatchToEvents.

Directly create SAX parser events representing the XML content of a DTM subtree.

public void
public void
documentRelease()

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.documentRelease.

Implements com.sun.org.apache.xml.internal.dtm.DTM.documentRelease.

As documents are released from the DTMManager, the DTM implementation will be notified of the event.

public void
public void
public void
endElement(String uri, String localName, String qName)

Overrides com.sun.org.apache.xml.internal.serializer.EmptySerializer.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.

public int
public int
getAttributeNode(int elementHandle, String namespaceURI, String name)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getAttributeNode.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getAttributeNode.

Retrieves an attribute node by local name and namespace URI %TBD% Note that we currently have no way to support the DOM's old getAttribute() call, which accesses only the qname.

public DTMAxisIterator
public DTMAxisTraverser
getAxisTraverser(final int axis)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getAxisTraverser.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getAxisTraverser.

This returns a stateless "traverser", that can navigate over an XPath axis, though not in document order.

public DTMAxisIterator
public ContentHandler
public DeclHandler
public int
public boolean
public String
public String
getDocumentEncoding(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getDocumentEncoding.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getDocumentEncoding.

Return the name of the character encoding scheme in which the document entity is expressed.

public int
public String
getDocumentStandalone(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getDocumentStandalone.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getDocumentStandalone.

Return an indication of the standalone status of the document, either "yes" or "no".

public String
public String
public String
public String
public String
getDocumentVersion(int documentHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getDocumentVersion.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getDocumentVersion.

Return a string representing the XML version of the document.

public DTDHandler
public int
public Map<String, Integer>
public EntityResolver
public ErrorHandler
public int
public int
getExpandedTypeID(String namespace, String localName, int type)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getExpandedTypeID.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getExpandedTypeID.

Given an expanded name, return an ID. If the expanded-name does not exist in the internal tables, the entry will be created, and the ID will be returned.

public int
getFirstAttribute(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getFirstAttribute.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getFirstAttribute.

Given a node handle, get the index of the node's first attribute.

public int
getFirstChild(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getFirstChild.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getFirstChild.

Given a node handle, get the handle of the node's first child.

public int
getFirstNamespaceNode(int nodeHandle, boolean inScope)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getFirstNamespaceNode.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getFirstNamespaceNode.

Given a node handle, get the index of the node's first namespace node.

public DTMAxisIterator
public String
public int
getLastChild(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getLastChild.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getLastChild.

Given a node handle, get the handle of the node's last child.

public short
getLevel(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getLevel.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getLevel.

Get the depth level of this node in the tree (equals 1 for a parentless node).

public LexicalHandler
public String
getLocalName(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getLocalName.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getLocalName.

Given a node handle, return its DOM-style localname.

public String
public DTMAxisIterator
public String
public String
public int
public String
getNamespaceURI(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getNamespaceURI.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getNamespaceURI.

Given a node handle, return its DOM-style namespace URI (As defined in Namespaces, this is the declared URI which this node's prefix -- or default in lieu thereof -- was mapped to.)

public DOM
public int
public int
getNextNamespaceNode(int baseHandle, int namespaceHandle, boolean inScope)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getNextNamespaceNode.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getNextNamespaceNode.

Given a namespace handle, advance to the next namespace in the same scope (local or local-plus-inherited, as selected by getFirstNamespaceNode)

public int
public Node
public final int
public final int
public String
public String
public short
getNodeType(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getNodeType.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getNodeType.

Given a node handle, return its DOM-style node type.

public String
public DTMAxisIterator
public int
public DTMAxisIterator
public SerializationHandler
public int
public int
public String
getPrefix(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getPrefix.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getPrefix.

Given a namespace handle, return the prefix that the namespace decl is mapping.

public int
public DOM
public int
public SourceLocator
public String
public XMLString
getStringValue(int nodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getStringValue.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getStringValue.

Get the string-value of a node as a String object (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value).

public char[]
getStringValueChunk(int nodeHandle, int chunkIndex, int[] startAndLen)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getStringValueChunk.

Implements com.sun.org.apache.xml.internal.dtm.DTM.getStringValueChunk.

Get a character array chunk in the string-value of a node.

public int
public String
public DTMAxisIterator
public DTMAxisIterator
public String
getUnparsedEntityURI(String name)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.getUnparsedEntityURI.

Implements com.sun.org.apache.xalan.internal.xsltc.DOM.getUnparsedEntityURI, com.sun.org.apache.xml.internal.dtm.DTM.getUnparsedEntityURI.

The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in the same document as the context node (see [3.3 Unparsed Entities]).

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isNodeAfter(int firstNodeHandle, int secondNodeHandle)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.isNodeAfter.

Implements com.sun.org.apache.xml.internal.dtm.DTM.isNodeAfter.

Figure out whether nodeHandle2 should be considered as being later in the document than nodeHandle1, in Document Order as defined by the XPath model.

public boolean
isSupported(String feature, String version)

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.isSupported.

Implements com.sun.org.apache.xml.internal.dtm.DTM.isSupported.

Tests whether DTM DOM implementation implements a specific feature and that feature is supported by this node.

public boolean
public String
public Node
public Node
public NodeList
public NodeList
private void
maybeEmitStartElement()

The code in some of the following interfaces are copied from SAXAdapter.

public void
public boolean
public DTMAxisIterator
private void
public void
public void
public void
public boolean
public void
public void
public void
public void
public String
public void
startDocument()

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.startDocument.

Implements org.xml.sax.ContentHandler.startDocument.

We only need to override the endDocument, characters, and setEscaping interfaces.

public void
public void
public void
startElement(String uri, String localName, String qName, Attributes attributes)

Overrides com.sun.org.apache.xml.internal.serializer.EmptySerializer.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element.

public boolean
supportsPreStripping()

Overrides com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.supportsPreStripping.

Implements com.sun.org.apache.xml.internal.dtm.DTM.supportsPreStripping.

Return true if the xsl:strip-space or xsl:preserve-space was processed during construction of the document contained in this DTM.

Inherited from com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl:
getDTMManagergetResultTreeFragmigrateTo