Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.dtm.ref

public Class DTMManagerDefault

extends DTMManager
Class Inheritance
Known Direct Subclasses
com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager
Imports
javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, javax.xml.transform.Source, javax.xml.transform.dom.DOMSource, javax.xml.transform.sax.SAXSource, javax.xml.transform.stream.StreamSource, com.sun.org.apache.xml.internal.dtm.DTM, .DTMException, .DTMFilter, .DTMIterator, .DTMManager, .DTMWSFilter, com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM, com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM, .SAX2RTFDTM, com.sun.org.apache.xml.internal.res.XMLErrorResources, .XMLMessages, com.sun.org.apache.xml.internal.utils.PrefixResolver, .SystemIDResolver, .XMLReaderManager, .XMLStringFactory, jdk.xml.internal.JdkXmlUtils, org.w3c.dom.Document, .Node, org.xml.sax.InputSource, .SAXException, .SAXNotRecognizedException, .SAXNotSupportedException, .XMLReader, org.xml.sax.helpers.DefaultHandler

The default implementation for the DTMManager. %REVIEW% There is currently a reentrancy issue, since the finalizer for XRTreeFrag (which runs in the GC thread) wants to call DTMManager.release(), and may do so at the same time that the main transformation thread is accessing the manager. Our current solution is to make most of the manager's methods synchronized. Early tests suggest that doing so is not causing a significant performance hit in Xalan. However, it should be noted that there is a possible alternative solution: rewrite release() so it merely posts a request for release onto a threadsafe queue, and explicitly process that queue on an infrequent basis during main-thread activity (eg, when getDTM() is invoked). The downside of that solution would be a greater delay before the DTM's storage is actually released for reuse.

Field Summary

Modifier and TypeField and Description
private static final boolean
DEBUG

Set this to true if you want a basic diagnostics.

private static final boolean
DUMPTREE

Set this to true if you want a dump of the DTM after creation.

protected DefaultHandler
m_defaultHandler

The default implementation of ContentHandler, DTDHandler and ErrorHandler.

pack-priv int[]
m_dtm_offsets

Map from DTM identifier numbers to offsets.

protected DTM[]
m_dtms

Map from DTM identifier numbers to DTM objects that this manager manages.

private ExpandedNameTable
m_expandedNameTable

The default table for exandedNameID lookups.

protected XMLReaderManager
m_readerManager

The cache for XMLReader objects to be used if the user did not supply an XMLReader for a SAXSource or supplied a StreamSource.

Inherited from com.sun.org.apache.xml.internal.dtm.DTMManager:
IDENT_DTM_DEFAULTIDENT_DTM_NODE_BITSIDENT_MAX_DTMSIDENT_NODE_DEFAULTm_incrementalm_source_locationm_xsf

Constructor Summary

AccessConstructor and Description
public
DTMManagerDefault()

Constructor DTMManagerDefault

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addDTM(DTM
Should be a valid reference to a DTM.
dtm
,
int
Integer DTM ID to be bound to this DTM
id
)

Add a DTM to the DTM table.

public synchronized void
addDTM(DTM
Should be a valid reference to a DTM.
dtm
,
int
Integer DTM ID to be bound to this DTM.
id
,
int
Integer addressing offset. The internal DTM Node ID is obtained by adding this offset to the node-number field of the public DTM Handle. For the first DTM ID accessing each DTM, this is 0; for overflow addressing it will be a multiple of 1<offset)

Add a DTM to the DTM table.

public synchronized DTM
createDocumentFragment()

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDocumentFragment.

Method createDocumentFragment NEEDSDOC (createDocumentFragment) @return

public synchronized DTMIterator
createDTMIterator(int
This flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.
whatToShow
,
DTMFilter
The NodeFilter to be used with this DTMFilter, or null to indicate no filter.
filter
,
boolean
The value of this flag determines whether entity reference nodes are expanded.
entityReferenceExpansion
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param whatToShow NEEDSDOC @param filter NEEDSDOC @param entityReferenceExpansion NEEDSDOC (createDTMIterator) @return

public synchronized DTMIterator
createDTMIterator(String
Must be a valid string expressing a LocationPath or a UnionExpr.
xpathString
,
PrefixResolver
An object that can resolve prefixes to namespace URLs.
presolver
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathString NEEDSDOC @param presolver NEEDSDOC (createDTMIterator) @return

public synchronized DTMIterator
createDTMIterator(int
The node handle that the DTMIterator will iterate to.
node
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param node NEEDSDOC (createDTMIterator) @return

public synchronized DTMIterator
createDTMIterator(Object
??? Somehow we need to pass in a subpart of the expression. I hate to do this with strings, since the larger expression has already been parsed.
xpathCompiler
,
int
The position in the expression.
pos
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathCompiler NEEDSDOC @param pos NEEDSDOC (createDTMIterator) @return

public synchronized DTM

Returns:

a non-null DTM reference.
getDTM
(Source
the specification of the source object.
source
,
boolean
true if the returned DTM must be unique, probably because it is going to be mutated.
unique
,
DTMWSFilter
Enables filtering of whitespace nodes, and may be null.
whiteSpaceFilter
,
boolean
true if the DTM should be built incrementally, if possible.
incremental
,
boolean
true if the caller considers it worth it to use indexing schemes.
doIndexing
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTM.

Get an instance of a DTM, loaded with the content from the specified source.

public synchronized DTM

Returns:

a reference to the DTM object containing this node.
getDTM
(int
DTM Handle indicating which node to retrieve
nodeHandle
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTM.

Return the DTM object containing a representation of this node.

public synchronized int

Returns:

a valid DTM handle.
getDTMHandleFromNode
(Node
Non-null reference to a DOM node.
node
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTMHandleFromNode.

Given a W3C DOM node, try and return a DTM handle.

public synchronized int

Returns:

The DTM ID (as the high bits of a NodeHandle, not as our internal index), or -1 if the DTM doesn't belong to this manager.
getDTMIdentity
(DTM
The DTM which (hopefully) contains this node.
dtm
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTMIdentity.

Given a DTM, find the ID number in the DTM tables which addresses the start of the document.

public ExpandedNameTable
getExpandedNameTable(DTM dtm)

return the expanded name table.

public synchronized int
getFirstFreeDTMID()

Get the first free DTM ID available.

public synchronized XMLReader

Returns:

a SAX2 XMLReader to use to resolve the inputSource argument. non-null XMLReader reference ready to parse.
getXMLReader
(Source
The value returned from the URIResolver.
inputSource
)

This method returns the SAX2 parser to use with the InputSource obtained from this URI.

public synchronized boolean

Returns:

true if the DTM was released, false if shouldHardDelete was set and we decided not to.
release
(DTM
the DTM to be released.
dtm
,
boolean
If false, this call is a suggestion rather than an order, and we may not actually release the DTM. This is intended to support intelligent caching of documents... which is not implemented in this version of the DTM manager.
shouldHardDelete
)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.release.

Release the DTMManager's reference(s) to a DTM, making it unmanaged.

public synchronized void
releaseXMLReader(XMLReader
The XMLReader to be released.
reader
)

Indicates that the XMLReader object is no longer in use for the transform.

Inherited from com.sun.org.apache.xml.internal.dtm.DTMManager:
getDTMIdentityMaskgetIncrementalgetNodeIdentityMaskgetSource_locationgetXMLStringFactorynewInstanceoverrideDefaultParsersetIncrementalsetOverrideDefaultParsersetSource_locationsetXMLStringFactory

Field Detail

DEBUGback to summary
private static final boolean DEBUG

Set this to true if you want a basic diagnostics.

DUMPTREEback to summary
private static final boolean DUMPTREE

Set this to true if you want a dump of the DTM after creation.

m_defaultHandlerback to summary
protected DefaultHandler m_defaultHandler

The default implementation of ContentHandler, DTDHandler and ErrorHandler.

m_dtm_offsetsback to summary
pack-priv int[] m_dtm_offsets

Map from DTM identifier numbers to offsets. For small DTMs with a single identifier, this will always be 0. In overflow addressing, where additional identifiers are allocated to access nodes beyond the range of a single Node Handle, this table is used to map the handle's node field into the actual node identifier. This array grows as necessary; see addDTM(). This array grows as necessary; see addDTM(). Growth is uncommon... but access needs to be blindingly fast since it's used in node addressing. (And at the moment, that includes accessing it from DTMDefaultBase, which is why this is not Protected or Private.)

m_dtmsback to summary
protected DTM[] m_dtms

Map from DTM identifier numbers to DTM objects that this manager manages. One DTM may have several prefix numbers, if extended node indexing is in use; in that case, m_dtm_offsets[] will used to control which prefix maps to which section of the DTM. This array grows as necessary; see addDTM(). This array grows as necessary; see addDTM(). Growth is uncommon... but access needs to be blindingly fast since it's used in node addressing.

m_expandedNameTableback to summary
private ExpandedNameTable m_expandedNameTable

The default table for exandedNameID lookups.

m_readerManagerback to summary
protected XMLReaderManager m_readerManager

The cache for XMLReader objects to be used if the user did not supply an XMLReader for a SAXSource or supplied a StreamSource.

Constructor Detail

DTMManagerDefaultback to summary
public DTMManagerDefault()

Constructor DTMManagerDefault

Method Detail

addDTMback to summary
public synchronized void addDTM(DTM dtm, int id)

Add a DTM to the DTM table. This convenience call adds it as the "base DTM ID", with offset 0. The other version of addDTM should be used if you want to add "extended" DTM IDs with nonzero offsets.

Parameters
dtm:DTM

Should be a valid reference to a DTM.

id:int

Integer DTM ID to be bound to this DTM

addDTMback to summary
public synchronized void addDTM(DTM dtm, int id, int offset)

Add a DTM to the DTM table.

Parameters
dtm:DTM

Should be a valid reference to a DTM.

id:int

Integer DTM ID to be bound to this DTM.

offset:int

Integer addressing offset. The internal DTM Node ID is obtained by adding this offset to the node-number field of the public DTM Handle. For the first DTM ID accessing each DTM, this is 0; for overflow addressing it will be a multiple of 1<

createDocumentFragmentback to summary
public synchronized DTM createDocumentFragment()

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDocumentFragment.

Method createDocumentFragment NEEDSDOC (createDocumentFragment) @return

Returns:DTM

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDocumentFragment.

a non-null DTM reference.

createDTMIteratorback to summary
public synchronized DTMIterator createDTMIterator(int whatToShow, DTMFilter filter, boolean entityReferenceExpansion)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param whatToShow NEEDSDOC @param filter NEEDSDOC @param entityReferenceExpansion NEEDSDOC (createDTMIterator) @return

Parameters
whatToShow:int

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

This flag specifies which node types may appear in the logical view of the tree presented by the iterator. See the description of NodeFilter for the set of possible SHOW_ values.These flags can be combined using OR.

filter:DTMFilter

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The NodeFilter to be used with this DTMFilter, or null to indicate no filter.

entityReferenceExpansion:boolean

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The value of this flag determines whether entity reference nodes are expanded.

Returns:DTMIterator

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The newly created DTMIterator.

createDTMIteratorback to summary
public synchronized DTMIterator createDTMIterator(String xpathString, PrefixResolver presolver)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathString NEEDSDOC @param presolver NEEDSDOC (createDTMIterator) @return

Parameters
xpathString:String

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

Must be a valid string expressing a LocationPath or a UnionExpr.

presolver:PrefixResolver

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

An object that can resolve prefixes to namespace URLs.

Returns:DTMIterator

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The newly created DTMIterator.

createDTMIteratorback to summary
public synchronized DTMIterator createDTMIterator(int node)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param node NEEDSDOC (createDTMIterator) @return

Parameters
node:int

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The node handle that the DTMIterator will iterate to.

Returns:DTMIterator

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The newly created DTMIterator.

createDTMIteratorback to summary
public synchronized DTMIterator createDTMIterator(Object xpathCompiler, int pos)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathCompiler NEEDSDOC @param pos NEEDSDOC (createDTMIterator) @return

Parameters
xpathCompiler:Object

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

??? Somehow we need to pass in a subpart of the expression. I hate to do this with strings, since the larger expression has already been parsed.

pos:int

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The position in the expression.

Returns:DTMIterator

Doc from com.sun.org.apache.xml.internal.dtm.DTMManager.createDTMIterator.

The newly created DTMIterator.

getDTMback to summary
public synchronized DTM getDTM(Source source, boolean unique, DTMWSFilter whiteSpaceFilter, boolean incremental, boolean doIndexing)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTM.

Get an instance of a DTM, loaded with the content from the specified source. If the unique flag is true, a new instance will always be returned. Otherwise it is up to the DTMManager to return a new instance or an instance that it already created and may be being used by someone else. A bit of magic in this implementation: If the source is null, unique is true, and incremental and doIndexing are both false, we return an instance of SAX2RTFDTM, which see. (I think more parameters will need to be added for error handling, and entity resolution, and more explicit control of the RTF situation).

Parameters
source:Source

the specification of the source object.

unique:boolean

true if the returned DTM must be unique, probably because it is going to be mutated.

whiteSpaceFilter:DTMWSFilter

Enables filtering of whitespace nodes, and may be null.

incremental:boolean

true if the DTM should be built incrementally, if possible.

doIndexing:boolean

true if the caller considers it worth it to use indexing schemes.

Returns:DTM

a non-null DTM reference.

getDTMback to summary
public synchronized DTM getDTM(int nodeHandle)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTM.

Return the DTM object containing a representation of this node.

Parameters
nodeHandle:int

DTM Handle indicating which node to retrieve

Returns:DTM

a reference to the DTM object containing this node.

getDTMHandleFromNodeback to summary
public synchronized int getDTMHandleFromNode(Node node)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTMHandleFromNode.

Given a W3C DOM node, try and return a DTM handle.

Note

calling this may be non-optimal, and there is no guarantee that the node will be found in any particular DTM.

Parameters
node:Node

Non-null reference to a DOM node.

Returns:int

a valid DTM handle.

getDTMIdentityback to summary
public synchronized int getDTMIdentity(DTM dtm)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.getDTMIdentity.

Given a DTM, find the ID number in the DTM tables which addresses the start of the document. If overflow addressing is in use, other DTM IDs may also be assigned to this DTM.

Parameters
dtm:DTM

The DTM which (hopefully) contains this node.

Returns:int

The DTM ID (as the high bits of a NodeHandle, not as our internal index), or -1 if the DTM doesn't belong to this manager.

getExpandedNameTableback to summary
public ExpandedNameTable getExpandedNameTable(DTM dtm)

return the expanded name table. NEEDSDOC @param dtm NEEDSDOC ($objectName$) @return

getFirstFreeDTMIDback to summary
public synchronized int getFirstFreeDTMID()

Get the first free DTM ID available. %OPT% Linear search is inefficient!

getXMLReaderback to summary
public synchronized XMLReader getXMLReader(Source inputSource)

This method returns the SAX2 parser to use with the InputSource obtained from this URI. It may return null if any SAX2-conformant XML parser can be used, or if getInputSource() will also return null. The parser must be free for use (i.e., not currently in use for another parse(). After use of the parser is completed, the releaseXMLReader(XMLReader) must be called.

Parameters
inputSource:Source

The value returned from the URIResolver.

Returns:XMLReader

a SAX2 XMLReader to use to resolve the inputSource argument. non-null XMLReader reference ready to parse.

releaseback to summary
public synchronized boolean release(DTM dtm, boolean shouldHardDelete)

Implements abstract com.sun.org.apache.xml.internal.dtm.DTMManager.release.

Release the DTMManager's reference(s) to a DTM, making it unmanaged. This is typically done as part of returning the DTM to the heap after we're done with it.

Parameters
dtm:DTM

the DTM to be released.

shouldHardDelete:boolean

If false, this call is a suggestion rather than an order, and we may not actually release the DTM. This is intended to support intelligent caching of documents... which is not implemented in this version of the DTM manager.

Returns:boolean

true if the DTM was released, false if shouldHardDelete was set and we decided not to.

releaseXMLReaderback to summary
public synchronized void releaseXMLReader(XMLReader reader)

Indicates that the XMLReader object is no longer in use for the transform. Note that the getXMLReader method may return an XMLReader that was specified on the SAXSource object by the application code. Such a reader should still be passed to releaseXMLReader, but the reader manager will only re-use XMLReaders that it created.

Parameters
reader:XMLReader

The XMLReader to be released.