--- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Thu Jun 06 20:40:43 2013 +0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Thu Jun 06 20:47:13 2013 +0200
@@ -23,6 +23,17 @@
package com.sun.org.apache.xalan.internal.xsltc.trax;
+import com.sun.org.apache.xalan.internal.XalanConstants;
+import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
+import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
+import com.sun.org.apache.xml.internal.utils.StopParseException;
+import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -37,11 +48,9 @@
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-
import javax.xml.XMLConstants;
+import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
@@ -58,23 +67,9 @@
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TemplatesHandler;
import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stax.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import javax.xml.transform.stax.*;
-
-import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
-import com.sun.org.apache.xml.internal.utils.StopParseException;
-
-import com.sun.org.apache.xalan.internal.XalanConstants;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
-import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
-import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
-
import org.xml.sax.InputSource;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
@@ -201,14 +196,6 @@
private int _indentNumber = -1;
/**
- * The provider of the XSLTC DTM Manager service. This is fixed for any
- * instance of this class. In order to change service providers, a new
- * XSLTC <code>TransformerFactory</code> must be instantiated.
- * @see XSLTCDTMManager#getDTMManagerClass()
- */
- private Class m_DTMManagerClass;
-
- /**
* <p>State of secure processing feature.</p>
*/
private boolean _isNotSecureProcessing = true;
@@ -246,7 +233,6 @@
}
private TransformerFactoryImpl(boolean useServicesMechanism) {
- this.m_DTMManagerClass = XSLTCDTMManager.getDTMManagerClass(useServicesMechanism);
this._useServicesMechanism = useServicesMechanism;
String defaultAccess = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
@@ -269,6 +255,7 @@
* @param listener The error listener to use with the TransformerFactory
* @throws IllegalArgumentException
*/
+ @Override
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException
{
@@ -286,6 +273,7 @@
*
* @return The error listener used with the TransformerFactory
*/
+ @Override
public ErrorListener getErrorListener() {
return _errorListener;
}
@@ -298,6 +286,7 @@
* @return An object representing the attribute value
* @throws IllegalArgumentException
*/
+ @Override
public Object getAttribute(String name)
throws IllegalArgumentException
{
@@ -337,6 +326,7 @@
* @param value An object representing the attribute value
* @throws IllegalArgumentException
*/
+ @Override
public void setAttribute(String name, Object value)
throws IllegalArgumentException
{
@@ -459,6 +449,7 @@
* or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature.
* @throws NullPointerException If the <code>name</code> parameter is null.
*/
+ @Override
public void setFeature(String name, boolean value)
throws TransformerConfigurationException {
@@ -503,6 +494,7 @@
* @param name The feature name
* @return 'true' if feature is supported, 'false' if not
*/
+ @Override
public boolean getFeature(String name) {
// All supported features should be listed here
String[] features = {
@@ -554,6 +546,7 @@
* @return The URLResolver used for this TransformerFactory and all
* Templates and Transformer objects created using this factory
*/
+ @Override
public URIResolver getURIResolver() {
return _uriResolver;
}
@@ -568,6 +561,7 @@
* @param resolver The URLResolver used for this TransformerFactory and all
* Templates and Transformer objects created using this factory
*/
+ @Override
public void setURIResolver(URIResolver resolver) {
_uriResolver = resolver;
}
@@ -587,13 +581,14 @@
* @return A Source object suitable for passing to the TransformerFactory.
* @throws TransformerConfigurationException
*/
+ @Override
public Source getAssociatedStylesheet(Source source, String media,
String title, String charset)
throws TransformerConfigurationException {
String baseId;
- XMLReader reader = null;
- InputSource isource = null;
+ XMLReader reader;
+ InputSource isource;
/**
@@ -675,6 +670,7 @@
* @return A Transformer object that simply copies the source to the result.
* @throws TransformerConfigurationException
*/
+ @Override
public Transformer newTransformer()
throws TransformerConfigurationException
{
@@ -700,6 +696,7 @@
* @return A Templates object that can be used to create Transformers.
* @throws TransformerConfigurationException
*/
+ @Override
public Transformer newTransformer(Source source) throws
TransformerConfigurationException
{
@@ -763,6 +760,7 @@
* @return A Templates object that can be used to create Transformers.
* @throws TransformerConfigurationException
*/
+ @Override
public Templates newTemplates(Source source)
throws TransformerConfigurationException
{
@@ -796,7 +794,7 @@
// If _autoTranslet is true, we will try to load the bytecodes
// from the translet classes without compiling the stylesheet.
if (_autoTranslet) {
- byte[][] bytecodes = null;
+ byte[][] bytecodes;
String transletClassName = getTransletBaseName(source);
if (_packageName != null)
@@ -918,7 +916,7 @@
// Check that the transformation went well before returning
if (bytecodes == null) {
Vector errs = xsltc.getErrors();
- ErrorMsg err = null;
+ ErrorMsg err;
if (errs != null) {
err = (ErrorMsg)errs.elementAt(errs.size()-1);
} else {
@@ -963,6 +961,7 @@
* @return A TemplatesHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TemplatesHandler newTemplatesHandler()
throws TransformerConfigurationException
{
@@ -982,6 +981,7 @@
* @return A TransformerHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TransformerHandler newTransformerHandler()
throws TransformerConfigurationException
{
@@ -1002,6 +1002,7 @@
* @return A TransformerHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TransformerHandler newTransformerHandler(Source src)
throws TransformerConfigurationException
{
@@ -1022,6 +1023,7 @@
* @return A TransformerHandler object that can handle SAX events
* @throws TransformerConfigurationException
*/
+ @Override
public TransformerHandler newTransformerHandler(Templates templates)
throws TransformerConfigurationException
{
@@ -1039,6 +1041,7 @@
* @return An XMLFilter object, or null if this feature is not supported.
* @throws TransformerConfigurationException
*/
+ @Override
public XMLFilter newXMLFilter(Source src)
throws TransformerConfigurationException
{
@@ -1056,6 +1059,7 @@
* @return An XMLFilter object, or null if this feature is not supported.
* @throws TransformerConfigurationException
*/
+ @Override
public XMLFilter newXMLFilter(Templates templates)
throws TransformerConfigurationException
{
@@ -1087,6 +1091,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void error(TransformerException e)
throws TransformerException
{
@@ -1115,6 +1120,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (always does in our case).
*/
+ @Override
public void fatalError(TransformerException e)
throws TransformerException
{
@@ -1143,6 +1149,7 @@
* @throws TransformerException if the application chooses to discontinue
* the transformation (never does in our case).
*/
+ @Override
public void warning(TransformerException e)
throws TransformerException
{
@@ -1166,6 +1173,7 @@
* @param xsltc The compiler that resuests the document
* @return An InputSource with the loaded document
*/
+ @Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
try {
if (_uriResolver != null) {
@@ -1252,7 +1260,7 @@
Vector bytecodes = new Vector();
int fileLength = (int)transletFile.length();
if (fileLength > 0) {
- FileInputStream input = null;
+ FileInputStream input;
try {
input = new FileInputStream(transletFile);
}
@@ -1284,6 +1292,7 @@
// Find all the auxiliary files which have a name pattern of "transletClass$nnn.class".
final String transletAuxPrefix = transletName + "$";
File[] auxfiles = transletParentFile.listFiles(new FilenameFilter() {
+ @Override
public boolean accept(File dir, String name)
{
return (name.endsWith(".class") && name.startsWith(transletAuxPrefix));
@@ -1347,7 +1356,7 @@
xslFile = new File(xslFileName);
// Construct the path for the jar file
- String jarPath = null;
+ String jarPath;
if (_destinationDirectory != null)
jarPath = _destinationDirectory + "/" + _jarFileName;
else {
@@ -1372,7 +1381,7 @@
}
// Create a ZipFile object for the jar file
- ZipFile jarFile = null;
+ ZipFile jarFile;
try {
jarFile = new ZipFile(file);
}
@@ -1490,7 +1499,7 @@
if (file.exists())
return systemId;
else {
- URL url = null;
+ URL url;
try {
url = new URL(systemId);
}
@@ -1509,9 +1518,9 @@
}
/**
- * Returns the Class object the provides the XSLTC DTM Manager service.
+ * Returns a new instance of the XSLTC DTM Manager service.
*/
- protected Class getDTMManagerClass() {
- return m_DTMManagerClass;
+ protected final XSLTCDTMManager createNewDTMManagerInstance() {
+ return XSLTCDTMManager.createNewDTMManagerInstance();
}
}