org.apache.xalan.xsltc.dom

Class AdaptiveResultTreeImpl

public class AdaptiveResultTreeImpl extends SimpleResultTreeImpl

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

Constructor Summary
AdaptiveResultTreeImpl(XSLTCDTMManager dtmManager, int documentID, DTMWSFilter wsfilter, int initSize, boolean buildIdIndex)
Method Summary
voidaddAttribute(String name, String value)
voidaddUniqueAttribute(String qName, String value, int flags)
voidappendChild(int newChild, boolean clone, boolean cloneDepth)
voidappendTextChild(String str)
voidcharacters(int node, SerializationHandler handler)
Dispatch the character content of a node to an output handler.
voidcharacters(String str)
voidcharacters(char[] ch, int offset, int length)
voidcomment(String comment)
voidcomment(char[] chars, int offset, int length)
voidcopy(int node, SerializationHandler handler)
voidcopy(DTMAxisIterator nodes, SerializationHandler handler)
voiddispatchCharactersEvents(int nodeHandle, ContentHandler ch, boolean normalize)
voiddispatchToEvents(int nodeHandle, ContentHandler ch)
voiddocumentRegistration()
voiddocumentRelease()
voidendDocument()
voidendElement(String elementName)
voidendElement(String uri, String localName, String qName)
intgetAttributeNode(int gType, int element)
intgetAttributeNode(int elementHandle, String namespaceURI, String name)
DTMAxisIteratorgetAxisIterator(int axis)
DTMAxisTraversergetAxisTraverser(int axis)
DTMAxisIteratorgetChildren(int node)
ContentHandlergetContentHandler()
DeclHandlergetDeclHandler()
intgetDocument()
booleangetDocumentAllDeclarationsProcessed()
StringgetDocumentBaseURI()
StringgetDocumentEncoding(int nodeHandle)
intgetDocumentRoot(int nodeHandle)
StringgetDocumentStandalone(int nodeHandle)
StringgetDocumentSystemIdentifier(int nodeHandle)
StringgetDocumentTypeDeclarationPublicIdentifier()
StringgetDocumentTypeDeclarationSystemIdentifier()
StringgetDocumentURI(int node)
StringgetDocumentVersion(int documentHandle)
DTDHandlergetDTDHandler()
intgetElementById(String elementId)
HashtablegetElementsWithIDs()
EntityResolvergetEntityResolver()
ErrorHandlergetErrorHandler()
intgetExpandedTypeID(int nodeHandle)
intgetExpandedTypeID(String namespace, String localName, int type)
intgetFirstAttribute(int nodeHandle)
intgetFirstChild(int nodeHandle)
intgetFirstNamespaceNode(int nodeHandle, boolean inScope)
DTMAxisIteratorgetIterator()
StringgetLanguage(int node)
intgetLastChild(int nodeHandle)
shortgetLevel(int nodeHandle)
LexicalHandlergetLexicalHandler()
StringgetLocalName(int nodeHandle)
StringgetLocalNameFromExpandedNameID(int ExpandedNameID)
DTMAxisIteratorgetNamespaceAxisIterator(int axis, int ns)
StringgetNamespaceFromExpandedNameID(int ExpandedNameID)
StringgetNamespaceName(int node)
intgetNamespaceType(int node)
StringgetNamespaceURI(int nodeHandle)
DOMgetNestedDOM()
intgetNextAttribute(int nodeHandle)
intgetNextNamespaceNode(int baseHandle, int namespaceHandle, boolean inScope)
intgetNextSibling(int nodeHandle)
NodegetNode(int nodeHandle)
intgetNodeHandle(int nodeId)
Return the node handle from a node identity.
intgetNodeIdent(int nodehandle)
Return the node identity from a node handle.
StringgetNodeName(int node)
StringgetNodeNameX(int node)
shortgetNodeType(int nodeHandle)
StringgetNodeValue(int nodeHandle)
DTMAxisIteratorgetNodeValueIterator(DTMAxisIterator iter, int returnType, String value, boolean op)
intgetNSType(int node)
DTMAxisIteratorgetNthDescendant(int node, int n, boolean includeself)
SerializationHandlergetOutputDomBuilder()
intgetOwnerDocument(int nodeHandle)
intgetParent(int nodeHandle)
StringgetPrefix(int nodeHandle)
intgetPreviousSibling(int nodeHandle)
DOMgetResultTreeFrag(int initialSize, int rtfType)
intgetSize()
SourceLocatorgetSourceLocatorFor(int node)
StringgetStringValue()
XMLStringgetStringValue(int nodeHandle)
char[]getStringValueChunk(int nodeHandle, int chunkIndex, int[] startAndLen)
intgetStringValueChunkCount(int nodeHandle)
StringgetStringValueX(int nodeHandle)
DTMAxisIteratorgetTypedAxisIterator(int axis, int type)
DTMAxisIteratorgetTypedChildren(int type)
StringgetUnparsedEntityURI(String name)
booleanhasChildNodes(int nodeHandle)
booleanisAttribute(int node)
booleanisAttributeSpecified(int attributeHandle)
booleanisCharacterElementContentWhitespace(int nodeHandle)
booleanisDocumentAllDeclarationsProcessed(int documentHandle)
booleanisElement(int node)
booleanisNodeAfter(int firstNodeHandle, int secondNodeHandle)
booleanisSupported(String feature, String version)
booleanlessThan(int node1, int node2)
StringlookupNamespace(int node, String prefix)
NodemakeNode(int index)
NodemakeNode(DTMAxisIterator iter)
NodeListmakeNodeList(int index)
NodeListmakeNodeList(DTMAxisIterator iter)
voidnamespaceAfterStartElement(String prefix, String uri)
booleanneedsTwoThreads()
DTMAxisIteratororderNodes(DTMAxisIterator source, int node)
voidprocessingInstruction(String target, String data)
voidsetDocumentBaseURI(String baseURI)
booleansetEscaping(boolean escape)
voidsetFeature(String featureId, boolean state)
Implementation of the DTM interfaces *
voidsetFilter(StripFilter filter)
voidsetProperty(String property, Object value)
voidsetupMapping(String[] names, String[] uris, int[] types, String[] namespaces)
StringshallowCopy(int node, SerializationHandler handler)
voidstartDocument()
voidstartElement(String elementName)
voidstartElement(String uri, String localName, String qName)
voidstartElement(String uri, String localName, String qName, Attributes attributes)
booleansupportsPreStripping()

Constructor Detail

AdaptiveResultTreeImpl

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

Method Detail

addAttribute

public void addAttribute(String name, String value)

addUniqueAttribute

public void addUniqueAttribute(String qName, String value, int flags)

appendChild

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

appendTextChild

public void appendTextChild(String str)

characters

public void characters(int node, SerializationHandler handler)
Dispatch the character content of a node to an output handler. The escape setting should be taken care of when outputting to a handler.

characters

public void characters(String str)

characters

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

comment

public void comment(String comment)

comment

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

copy

public void copy(int node, SerializationHandler handler)

copy

public void copy(DTMAxisIterator nodes, SerializationHandler handler)

dispatchCharactersEvents

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

dispatchToEvents

public void dispatchToEvents(int nodeHandle, ContentHandler ch)

documentRegistration

public void documentRegistration()

documentRelease

public void documentRelease()

endDocument

public void endDocument()

endElement

public void endElement(String elementName)

endElement

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

getAttributeNode

public int getAttributeNode(int gType, int element)

getAttributeNode

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

getAxisIterator

public DTMAxisIterator getAxisIterator(int axis)

getAxisTraverser

public DTMAxisTraverser getAxisTraverser(int axis)

getChildren

public DTMAxisIterator getChildren(int node)

getContentHandler

public ContentHandler getContentHandler()

getDeclHandler

public DeclHandler getDeclHandler()

getDocument

public int getDocument()

getDocumentAllDeclarationsProcessed

public boolean getDocumentAllDeclarationsProcessed()

getDocumentBaseURI

public String getDocumentBaseURI()

getDocumentEncoding

public String getDocumentEncoding(int nodeHandle)

getDocumentRoot

public int getDocumentRoot(int nodeHandle)

getDocumentStandalone

public String getDocumentStandalone(int nodeHandle)

getDocumentSystemIdentifier

public String getDocumentSystemIdentifier(int nodeHandle)

getDocumentTypeDeclarationPublicIdentifier

public String getDocumentTypeDeclarationPublicIdentifier()

getDocumentTypeDeclarationSystemIdentifier

public String getDocumentTypeDeclarationSystemIdentifier()

getDocumentURI

public String getDocumentURI(int node)

getDocumentVersion

public String getDocumentVersion(int documentHandle)

getDTDHandler

public DTDHandler getDTDHandler()

getElementById

public int getElementById(String elementId)

getElementsWithIDs

public Hashtable getElementsWithIDs()

getEntityResolver

public EntityResolver getEntityResolver()

getErrorHandler

public ErrorHandler getErrorHandler()

getExpandedTypeID

public int getExpandedTypeID(int nodeHandle)

getExpandedTypeID

public int getExpandedTypeID(String namespace, String localName, int type)

getFirstAttribute

public int getFirstAttribute(int nodeHandle)

getFirstChild

public int getFirstChild(int nodeHandle)

getFirstNamespaceNode

public int getFirstNamespaceNode(int nodeHandle, boolean inScope)

getIterator

public DTMAxisIterator getIterator()

getLanguage

public String getLanguage(int node)

getLastChild

public int getLastChild(int nodeHandle)

getLevel

public short getLevel(int nodeHandle)

getLexicalHandler

public LexicalHandler getLexicalHandler()

getLocalName

public String getLocalName(int nodeHandle)

getLocalNameFromExpandedNameID

public String getLocalNameFromExpandedNameID(int ExpandedNameID)

getNamespaceAxisIterator

public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)

getNamespaceFromExpandedNameID

public String getNamespaceFromExpandedNameID(int ExpandedNameID)

getNamespaceName

public String getNamespaceName(int node)

getNamespaceType

public int getNamespaceType(int node)

getNamespaceURI

public String getNamespaceURI(int nodeHandle)

getNestedDOM

public DOM getNestedDOM()

getNextAttribute

public int getNextAttribute(int nodeHandle)

getNextNamespaceNode

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

getNextSibling

public int getNextSibling(int nodeHandle)

getNode

public Node getNode(int nodeHandle)

getNodeHandle

public final int getNodeHandle(int nodeId)
Return the node handle from a node identity.

getNodeIdent

public final int getNodeIdent(int nodehandle)
Return the node identity from a node handle.

getNodeName

public String getNodeName(int node)

getNodeNameX

public String getNodeNameX(int node)

getNodeType

public short getNodeType(int nodeHandle)

getNodeValue

public String getNodeValue(int nodeHandle)

getNodeValueIterator

public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType, String value, boolean op)

getNSType

public int getNSType(int node)

getNthDescendant

public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself)

getOutputDomBuilder

public SerializationHandler getOutputDomBuilder()

getOwnerDocument

public int getOwnerDocument(int nodeHandle)

getParent

public int getParent(int nodeHandle)

getPrefix

public String getPrefix(int nodeHandle)

getPreviousSibling

public int getPreviousSibling(int nodeHandle)

getResultTreeFrag

public DOM getResultTreeFrag(int initialSize, int rtfType)

getSize

public int getSize()

getSourceLocatorFor

public SourceLocator getSourceLocatorFor(int node)

getStringValue

public String getStringValue()

getStringValue

public XMLString getStringValue(int nodeHandle)

getStringValueChunk

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

getStringValueChunkCount

public int getStringValueChunkCount(int nodeHandle)

getStringValueX

public String getStringValueX(int nodeHandle)

getTypedAxisIterator

public DTMAxisIterator getTypedAxisIterator(int axis, int type)

getTypedChildren

public DTMAxisIterator getTypedChildren(int type)

getUnparsedEntityURI

public String getUnparsedEntityURI(String name)

hasChildNodes

public boolean hasChildNodes(int nodeHandle)

isAttribute

public boolean isAttribute(int node)

isAttributeSpecified

public boolean isAttributeSpecified(int attributeHandle)

isCharacterElementContentWhitespace

public boolean isCharacterElementContentWhitespace(int nodeHandle)

isDocumentAllDeclarationsProcessed

public boolean isDocumentAllDeclarationsProcessed(int documentHandle)

isElement

public boolean isElement(int node)

isNodeAfter

public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle)

isSupported

public boolean isSupported(String feature, String version)

lessThan

public boolean lessThan(int node1, int node2)

lookupNamespace

public String lookupNamespace(int node, String prefix)

makeNode

public Node makeNode(int index)

makeNode

public Node makeNode(DTMAxisIterator iter)

makeNodeList

public NodeList makeNodeList(int index)

makeNodeList

public NodeList makeNodeList(DTMAxisIterator iter)

namespaceAfterStartElement

public void namespaceAfterStartElement(String prefix, String uri)

needsTwoThreads

public boolean needsTwoThreads()

orderNodes

public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)

processingInstruction

public void processingInstruction(String target, String data)

setDocumentBaseURI

public void setDocumentBaseURI(String baseURI)

setEscaping

public boolean setEscaping(boolean escape)

setFeature

public void setFeature(String featureId, boolean state)
Implementation of the DTM interfaces *

setFilter

public void setFilter(StripFilter filter)

setProperty

public void setProperty(String property, Object value)

setupMapping

public void setupMapping(String[] names, String[] uris, int[] types, String[] namespaces)

shallowCopy

public String shallowCopy(int node, SerializationHandler handler)

startDocument

public void startDocument()

startElement

public void startElement(String elementName)

startElement

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

startElement

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

supportsPreStripping

public boolean supportsPreStripping()
Copyright © 2005 Apache XML Project. All Rights Reserved.