|
Java example source code file (DTMManagerDefault.java)
The DTMManagerDefault.java Java example source code/* * reserved comment block * DO NOT REMOVE OR ALTER! */ /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: DTMManagerDefault.java,v 1.2.4.1 2005/09/15 08:15:02 suresh_emailid Exp $ */ package com.sun.org.apache.xml.internal.dtm.ref; import com.sun.org.apache.xalan.internal.utils.FactoryImpl; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; import com.sun.org.apache.xml.internal.dtm.DTM; import com.sun.org.apache.xml.internal.dtm.DTMException; import com.sun.org.apache.xml.internal.dtm.DTMFilter; import com.sun.org.apache.xml.internal.dtm.DTMIterator; import com.sun.org.apache.xml.internal.dtm.DTMManager; import com.sun.org.apache.xml.internal.dtm.DTMWSFilter; import com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM; import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM; import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2RTFDTM; import com.sun.org.apache.xml.internal.res.XMLErrorResources; import com.sun.org.apache.xml.internal.res.XMLMessages; import com.sun.org.apache.xml.internal.utils.PrefixResolver; import com.sun.org.apache.xml.internal.utils.SystemIDResolver; import com.sun.org.apache.xml.internal.utils.XMLReaderManager; import com.sun.org.apache.xml.internal.utils.XMLStringFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.XMLReader; import 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 <code>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. * */ public class DTMManagerDefault extends DTMManager { //static final boolean JKESS_XNI_EXPERIMENT=true; /** Set this to true if you want a dump of the DTM after creation. */ private static final boolean DUMPTREE = false; /** Set this to true if you want a basic diagnostics. */ private static final boolean DEBUG = false; /** * 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. */ protected DTM m_dtms[] = new DTM[256]; /** 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.) */ int m_dtm_offsets[] = new int[256]; /** * The cache for XMLReader objects to be used if the user did not * supply an XMLReader for a SAXSource or supplied a StreamSource. */ protected XMLReaderManager m_readerManager = null; /** * The default implementation of ContentHandler, DTDHandler and ErrorHandler. */ protected DefaultHandler m_defaultHandler = new DefaultHandler(); /** * 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. * * @param dtm Should be a valid reference to a DTM. * @param id Integer DTM ID to be bound to this DTM */ synchronized public void addDTM(DTM dtm, int id) { addDTM(dtm,id,0); } /** * Add a DTM to the DTM table. * * @param dtm Should be a valid reference to a DTM. * @param id Integer DTM ID to be bound to this DTM. * @param 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< Other Java examples (source code examples)Here is a short list of links related to this Java DTMManagerDefault.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.