Class DTMManagerDefault
- java.lang.Object
-
- org.htmlunit.xpath.xml.dtm.DTMManager
-
- org.htmlunit.xpath.xml.dtm.ref.DTMManagerDefault
-
public class DTMManagerDefault extends DTMManager
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
Fields Modifier and Type Field Description private static boolean
DEBUG
Set this to true if you want a basic diagnostics.private static boolean
DUMPTREE
Set this to true if you want a dump of the DTM after creation.(package private) 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.-
Fields inherited from class org.htmlunit.xpath.xml.dtm.DTMManager
IDENT_DTM_DEFAULT, IDENT_DTM_NODE_BITS, IDENT_MAX_DTMS, IDENT_NODE_DEFAULT
-
-
Constructor Summary
Constructors Constructor Description DTMManagerDefault()
Constructor DTMManagerDefault
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDTM(DTM dtm, int id, int offset)
Add a DTM to the DTM table.DTM
getDTM(int nodeHandle)
Get the instance of DTM that "owns" a node handle.DTM
getDTM(javax.xml.transform.Source source, boolean unique, boolean incremental, boolean doIndexing)
Get an instance of a DTM, loaded with the content from the specified source.int
getDTMHandleFromNode(org.w3c.dom.Node node)
Given a W3C DOM node, try and return a DTM handle.ExpandedNameTable
getExpandedNameTable()
int
getFirstFreeDTMID()
-
Methods inherited from class org.htmlunit.xpath.xml.dtm.DTMManager
newInstance
-
-
-
-
Field Detail
-
DUMPTREE
private static final boolean DUMPTREE
Set this to true if you want a dump of the DTM after creation.- See Also:
- Constant Field Values
-
DEBUG
private static final boolean DEBUG
Set this to true if you want a basic diagnostics.- See Also:
- Constant Field Values
-
m_dtms
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_dtm_offsets
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_expandedNameTable
private final ExpandedNameTable m_expandedNameTable
The default table for exandedNameID lookups.
-
-
Method Detail
-
addDTM
public void addDTM(DTM dtm, int id, int offset)
Add a DTM to the DTM table.- Parameters:
dtm
- Should be a valid reference to a DTM.id
- Integer DTM ID to be bound to this DTM.offset
- 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<<IDENT_DTM_NODE_BITS.
-
getFirstFreeDTMID
public int getFirstFreeDTMID()
- Returns:
- the first free DTM ID available. %OPT% Linear search is inefficient!
-
getDTM
public DTM getDTM(javax.xml.transform.Source source, boolean unique, boolean incremental, boolean doIndexing)
Description copied from class:DTMManager
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.(More parameters may eventually need to be added for error handling and entity resolution, and to better control selection of implementations.)
- Specified by:
getDTM
in classDTMManager
- Parameters:
source
- the specification of the source object, which may be null, in which case it is assumed that node construction will take by some other means.unique
- true if the returned DTM must be unique, probably because it is going to be mutated.incremental
- true if the DTM should be built incrementally, if possible.doIndexing
- true if the caller considers it worth it to use indexing schemes.- Returns:
- a non-null DTM reference.
-
getDTMHandleFromNode
public int getDTMHandleFromNode(org.w3c.dom.Node node)
Given a W3C DOM node, try and return a DTM handle. Note: calling this may be non-optimal.- Specified by:
getDTMHandleFromNode
in classDTMManager
- Parameters:
node
- Non-null reference to a DOM node.- Returns:
- a valid DTM handle.
-
getDTM
public DTM getDTM(int nodeHandle)
Get the instance of DTM that "owns" a node handle.- Specified by:
getDTM
in classDTMManager
- Parameters:
nodeHandle
- the nodeHandle.- Returns:
- a non-null DTM reference.
-
getExpandedNameTable
public ExpandedNameTable getExpandedNameTable()
- Returns:
- the expanded name table.
NEEDSDOC @param dtm
NEEDSDOC ($objectName$) @return
-
-