FileDocCategorySizeDatePackage
XSLTCDTMManager.javaAPI DocJava SE 5 API17111Fri Aug 26 14:55:40 BST 2005com.sun.org.apache.xalan.internal.xsltc.dom

XSLTCDTMManager

public class XSLTCDTMManager extends DTMManagerDefault
The default implementation for the DTMManager.

Fields Summary
private static final String
DEFAULT_CLASS_NAME
The default class name to use as the manager.
private static final String
DEFAULT_PROP_NAME
private static final boolean
DUMPTREE
Set this to true if you want a dump of the DTM after creation
private static final boolean
DEBUG
Set this to true if you want basic diagnostics
Constructors Summary
public XSLTCDTMManager()
Constructor DTMManagerDefault


           
     
    
        super();
    
Methods Summary
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(javax.xml.transform.Source source, boolean unique, com.sun.org.apache.xml.internal.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. (I think more parameters will need to be added for error handling, and entity resolution).

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

        return getDTM(source, unique, whiteSpaceFilter, incremental,
		      doIndexing, false, 0, true, false);
    
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(javax.xml.transform.Source source, boolean unique, com.sun.org.apache.xml.internal.dtm.DTMWSFilter whiteSpaceFilter, boolean incremental, boolean doIndexing, boolean buildIdIndex)
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. (I think more parameters will need to be added for error handling, and entity resolution).

param
source the specification of the source object.
param
unique true if the returned DTM must be unique, probably because it is going to be mutated.
param
whiteSpaceFilter Enables filtering of whitespace nodes, and may be null.
param
incremental true if the DTM should be built incrementally, if possible.
param
doIndexing true if the caller considers it worth it to use indexing schemes.
param
buildIdIndex true if the id index table should be built.
return
a non-null DTM reference.

        return getDTM(source, unique, whiteSpaceFilter, incremental,
		      doIndexing, false, 0, buildIdIndex, false);
    
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(javax.xml.transform.Source source, boolean unique, com.sun.org.apache.xml.internal.dtm.DTMWSFilter whiteSpaceFilter, boolean incremental, boolean doIndexing, boolean buildIdIndex, boolean newNameTable)
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. (I think more parameters will need to be added for error handling, and entity resolution).

param
source the specification of the source object.
param
unique true if the returned DTM must be unique, probably because it is going to be mutated.
param
whiteSpaceFilter Enables filtering of whitespace nodes, and may be null.
param
incremental true if the DTM should be built incrementally, if possible.
param
doIndexing true if the caller considers it worth it to use indexing schemes.
param
buildIdIndex true if the id index table should be built.
param
newNameTable true if we want to use a separate ExpandedNameTable for this DTM.
return
a non-null DTM reference.

    return getDTM(source, unique, whiteSpaceFilter, incremental,
		  doIndexing, false, 0, buildIdIndex, newNameTable);
  
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(javax.xml.transform.Source source, boolean unique, com.sun.org.apache.xml.internal.dtm.DTMWSFilter whiteSpaceFilter, boolean incremental, boolean doIndexing, boolean hasUserReader, int size, boolean buildIdIndex)
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. (I think more parameters will need to be added for error handling, and entity resolution).

param
source the specification of the source object.
param
unique true if the returned DTM must be unique, probably because it is going to be mutated.
param
whiteSpaceFilter Enables filtering of whitespace nodes, and may be null.
param
incremental true if the DTM should be built incrementally, if possible.
param
doIndexing true if the caller considers it worth it to use indexing schemes.
param
hasUserReader true if source is a SAXSource object that has an XMLReader, that was specified by the user.
param
size Specifies initial size of tables that represent the DTM
param
buildIdIndex true if the id index table should be built.
return
a non-null DTM reference.

      return getDTM(source, unique, whiteSpaceFilter, incremental,
                    doIndexing, hasUserReader, size,
                    buildIdIndex, false);
  
public com.sun.org.apache.xml.internal.dtm.DTMgetDTM(javax.xml.transform.Source source, boolean unique, com.sun.org.apache.xml.internal.dtm.DTMWSFilter whiteSpaceFilter, boolean incremental, boolean doIndexing, boolean hasUserReader, int size, boolean buildIdIndex, boolean newNameTable)
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. (I think more parameters will need to be added for error handling, and entity resolution).

param
source the specification of the source object.
param
unique true if the returned DTM must be unique, probably because it is going to be mutated.
param
whiteSpaceFilter Enables filtering of whitespace nodes, and may be null.
param
incremental true if the DTM should be built incrementally, if possible.
param
doIndexing true if the caller considers it worth it to use indexing schemes.
param
hasUserReader true if source is a SAXSource object that has an XMLReader, that was specified by the user.
param
size Specifies initial size of tables that represent the DTM
param
buildIdIndex true if the id index table should be built.
param
newNameTable true if we want to use a separate ExpandedNameTable for this DTM.
return
a non-null DTM reference.

        if(DEBUG && null != source) {
            System.out.println("Starting "+
			 (unique ? "UNIQUE" : "shared")+
			 " source: "+source.getSystemId());
        }

        int dtmPos = getFirstFreeDTMID();
        int documentID = dtmPos << IDENT_DTM_NODE_BITS;

        if ((null != source) && source instanceof DOMSource)
        {
            final DOMSource domsrc = (DOMSource) source;
            final org.w3c.dom.Node node = domsrc.getNode();
            final DOM2SAX dom2sax = new DOM2SAX(node);
      
            SAXImpl dtm;

            if (size <= 0) {
                dtm = new SAXImpl(this, source, documentID,
                                  whiteSpaceFilter, null, doIndexing, 
                                  DTMDefaultBase.DEFAULT_BLOCKSIZE,
                                  buildIdIndex, newNameTable);
            } else {
                dtm = new SAXImpl(this, source, documentID,
                                  whiteSpaceFilter, null, doIndexing, 
                                  size, buildIdIndex, newNameTable);
            }
      
            dtm.setDocumentURI(source.getSystemId());

            addDTM(dtm, dtmPos, 0);
      
            dom2sax.setContentHandler(dtm);
      
            try {
                dom2sax.parse();
            }
            catch (RuntimeException re) {
                throw re;
            }
            catch (Exception e) {
                throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
            }
      
            return dtm;
        }
        else
        {
            boolean isSAXSource = (null != source)
                                  ? (source instanceof SAXSource) : true;
            boolean isStreamSource = (null != source)
                                  ? (source instanceof StreamSource) : false;

            if (isSAXSource || isStreamSource) {
                XMLReader reader;
                InputSource xmlSource;

                if (null == source) {
                    xmlSource = null;
                    reader = null;
                    hasUserReader = false;  // Make sure the user didn't lie
                }
                else {
                    reader = getXMLReader(source);
                    xmlSource = SAXSource.sourceToInputSource(source);

                    String urlOfSource = xmlSource.getSystemId();

                    if (null != urlOfSource) {
                        try {
                            urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
                        }
                        catch (Exception e) {
                            // %REVIEW% Is there a better way to send a warning?
                            System.err.println("Can not absolutize URL: " + urlOfSource);
                        }

                        xmlSource.setSystemId(urlOfSource);
                    }
                }

                // Create the basic SAX2DTM.
                SAXImpl dtm;
                if (size <= 0) {
                    dtm = new SAXImpl(this, source, documentID, whiteSpaceFilter,
			              null, doIndexing, 
			              DTMDefaultBase.DEFAULT_BLOCKSIZE,
			              buildIdIndex, newNameTable);
                } else {
                    dtm = new SAXImpl(this, source, documentID, whiteSpaceFilter,
			    null, doIndexing, size, buildIdIndex, newNameTable);
                }

                // Go ahead and add the DTM to the lookup table.  This needs to be
                // done before any parsing occurs. Note offset 0, since we've just
                // created a new DTM.
                addDTM(dtm, dtmPos, 0);

                if (null == reader) {
                    // Then the user will construct it themselves.
                    return dtm;
                }

                reader.setContentHandler(dtm.getBuilder());
                
                if (!hasUserReader || null == reader.getDTDHandler()) {
                    reader.setDTDHandler(dtm);
                }
                
                if(!hasUserReader || null == reader.getErrorHandler()) {
                    reader.setErrorHandler(dtm);
                }

                try {
                    reader.setProperty("http://xml.org/sax/properties/lexical-handler", dtm);
                }
                catch (SAXNotRecognizedException e){}
                catch (SAXNotSupportedException e){}

                try {
                    reader.parse(xmlSource);
                }
                catch (RuntimeException re) {
                    throw re;
                }
                catch (Exception e) {
                    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
                } finally {
                    if (!hasUserReader) {
                        releaseXMLReader(reader);
                    }
                }

                if (DUMPTREE) {
                    System.out.println("Dumping SAX2DOM");
                    dtm.dumpDTM(System.err);
                }

                return dtm;
            }
            else {
                // It should have been handled by a derived class or the caller
                // made a mistake.
                throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NOT_SUPPORTED, new Object[]{source}));
            }
        }
    
public static java.lang.ClassgetDTMManagerClass()
Look up the class that provides the XSLTC DTM Manager service. The following lookup procedure is used to find the service provider.
  1. The value of the com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager property, is checked.
  2. The xalan.propeties file is checked for a property of the same name.
  3. The META-INF/services/com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager file is checked.
The default is com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.

        Class mgrClass = ObjectFactory.lookUpFactoryClass(DEFAULT_PROP_NAME,
                                                          null,
                                                          DEFAULT_CLASS_NAME);
        // If no class found, default to this one.  (This should never happen -
        // the ObjectFactory has already been told that the current class is
        // the default).
        return (mgrClass != null) ? mgrClass : XSLTCDTMManager.class;
    
public static com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManagernewInstance()
Obtain a new instance of a DTMManager. This static method creates a new factory instance. The current implementation just returns a new XSLTCDTMManager instance.

        return new XSLTCDTMManager();