Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xml.dtm.ref
Class DTMManagerDefault  view DTMManagerDefault download DTMManagerDefault.java

java.lang.Object
  extended byorg.apache.xml.dtm.DTMManager
      extended byorg.apache.xml.dtm.ref.DTMManagerDefault

public class DTMManagerDefault
extends org.apache.xml.dtm.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
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  org.apache.xml.dtm.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  org.apache.xml.utils.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.
 
Fields inherited from class org.apache.xml.dtm.DTMManager
IDENT_DTM_DEFAULT, IDENT_DTM_NODE_BITS, IDENT_MAX_DTMS, IDENT_NODE_DEFAULT, m_incremental, m_xsf
 
Constructor Summary
DTMManagerDefault()
          Constructor DTMManagerDefault
 
Method Summary
 void addDTM(org.apache.xml.dtm.DTM dtm, int id)
          Add a DTM to the DTM table.
 void addDTM(org.apache.xml.dtm.DTM dtm, int id, int offset)
          Add a DTM to the DTM table.
 org.apache.xml.dtm.DTM createDocumentFragment()
          Method createDocumentFragment NEEDSDOC (createDocumentFragment) @return
 org.apache.xml.dtm.DTMIterator createDTMIterator(int node)
          NEEDSDOC Method createDTMIterator NEEDSDOC @param node NEEDSDOC (createDTMIterator) @return
 org.apache.xml.dtm.DTMIterator createDTMIterator(int whatToShow, org.apache.xml.dtm.DTMFilter filter, boolean entityReferenceExpansion)
          NEEDSDOC Method createDTMIterator NEEDSDOC @param whatToShow NEEDSDOC @param filter NEEDSDOC @param entityReferenceExpansion NEEDSDOC (createDTMIterator) @return
 org.apache.xml.dtm.DTMIterator createDTMIterator(java.lang.Object xpathCompiler, int pos)
          NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathCompiler NEEDSDOC @param pos NEEDSDOC (createDTMIterator) @return
 org.apache.xml.dtm.DTMIterator createDTMIterator(java.lang.String xpathString, org.apache.xml.utils.PrefixResolver presolver)
          NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathString NEEDSDOC @param presolver NEEDSDOC (createDTMIterator) @return
 org.apache.xml.dtm.DTM getDTM(int nodeHandle)
          Return the DTM object containing a representation of this node.
 org.apache.xml.dtm.DTM getDTM(javax.xml.transform.Source source, boolean unique, org.apache.xml.dtm.DTMWSFilter whiteSpaceFilter, 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.
 int getDTMIdentity(org.apache.xml.dtm.DTM dtm)
          Given a DTM, find the ID number in the DTM tables which addresses the start of the document.
 ExpandedNameTable getExpandedNameTable(org.apache.xml.dtm.DTM dtm)
          return the expanded name table.
 int getFirstFreeDTMID()
          Get the first free DTM ID available.
 org.xml.sax.XMLReader getXMLReader(javax.xml.transform.Source inputSource)
          This method returns the SAX2 parser to use with the InputSource obtained from this URI.
 boolean release(org.apache.xml.dtm.DTM dtm, boolean shouldHardDelete)
          Release the DTMManager's reference(s) to a DTM, making it unmanaged.
 void releaseXMLReader(org.xml.sax.XMLReader reader)
          Indicates that the XMLReader object is no longer in use for the transform.
 
Methods inherited from class org.apache.xml.dtm.DTMManager
getDTMIdentityMask, getIncremental, getNodeIdentityMask, getXMLStringFactory, newInstance, setIncremental, setXMLStringFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 org.apache.xml.dtm.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_readerManager

protected org.apache.xml.utils.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.


m_expandedNameTable

private ExpandedNameTable m_expandedNameTable
The default table for exandedNameID lookups.

Constructor Detail

DTMManagerDefault

public DTMManagerDefault()
Constructor DTMManagerDefault

Method Detail

addDTM

public void addDTM(org.apache.xml.dtm.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.


addDTM

public void addDTM(org.apache.xml.dtm.DTM dtm,
                   int id,
                   int offset)
Add a DTM to the DTM table.


getFirstFreeDTMID

public int getFirstFreeDTMID()
Get the first free DTM ID available. %OPT% Linear search is inefficient!


getDTM

public org.apache.xml.dtm.DTM getDTM(javax.xml.transform.Source source,
                                     boolean unique,
                                     org.apache.xml.dtm.DTMWSFilter whiteSpaceFilter,
                                     boolean incremental,
                                     boolean doIndexing)
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).


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, and there is no guarantee that the node will be found in any particular DTM.


getXMLReader

public org.xml.sax.XMLReader getXMLReader(javax.xml.transform.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.


releaseXMLReader

public void releaseXMLReader(org.xml.sax.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.


getDTM

public org.apache.xml.dtm.DTM getDTM(int nodeHandle)
Return the DTM object containing a representation of this node.


getDTMIdentity

public int getDTMIdentity(org.apache.xml.dtm.DTM dtm)
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.


release

public boolean release(org.apache.xml.dtm.DTM dtm,
                       boolean shouldHardDelete)
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.


createDocumentFragment

public org.apache.xml.dtm.DTM createDocumentFragment()
Method createDocumentFragment NEEDSDOC (createDocumentFragment) @return


createDTMIterator

public org.apache.xml.dtm.DTMIterator createDTMIterator(int whatToShow,
                                                        org.apache.xml.dtm.DTMFilter filter,
                                                        boolean entityReferenceExpansion)
NEEDSDOC Method createDTMIterator NEEDSDOC @param whatToShow NEEDSDOC @param filter NEEDSDOC @param entityReferenceExpansion NEEDSDOC (createDTMIterator) @return


createDTMIterator

public org.apache.xml.dtm.DTMIterator createDTMIterator(java.lang.String xpathString,
                                                        org.apache.xml.utils.PrefixResolver presolver)
NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathString NEEDSDOC @param presolver NEEDSDOC (createDTMIterator) @return


createDTMIterator

public org.apache.xml.dtm.DTMIterator createDTMIterator(int node)
NEEDSDOC Method createDTMIterator NEEDSDOC @param node NEEDSDOC (createDTMIterator) @return


createDTMIterator

public org.apache.xml.dtm.DTMIterator createDTMIterator(java.lang.Object xpathCompiler,
                                                        int pos)
NEEDSDOC Method createDTMIterator NEEDSDOC @param xpathCompiler NEEDSDOC @param pos NEEDSDOC (createDTMIterator) @return


getExpandedNameTable

public ExpandedNameTable getExpandedNameTable(org.apache.xml.dtm.DTM dtm)
return the expanded name table. NEEDSDOC @param dtm NEEDSDOC ($objectName$) @return