src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java

Print this page

        

@@ -97,14 +97,10 @@
  * @author Santiago Pericas-Geertsen
  */
 public final class TransformerImpl extends Transformer
     implements DOMCache, ErrorListener
 {
-    private final static String EMPTY_STRING = "";
-    private final static String NO_STRING    = "no";
-    private final static String YES_STRING   = "yes";
-    private final static String XML_STRING   = "xml";
 
     private final static String LEXICAL_HANDLER_PROPERTY =
         "http://xml.org/sax/properties/lexical-handler";
     private static final String NAMESPACE_FEATURE =
         "http://xml.org/sax/features/namespaces";

@@ -154,11 +150,11 @@
      * A reference to an output handler factory.
      */
     private TransletOutputHandlerFactory _tohFactory = null;
 
     /**
-     * A reference to a internal DOM represenation of the input.
+     * A reference to a internal DOM representation of the input.
      */
     private DOM _dom = null;
 
     /**
      * Number of indent spaces to add when indentation is on.

@@ -236,10 +232,11 @@
 
         public MessageHandler(ErrorListener errorListener) {
             _errorListener = errorListener;
         }
 
+        @Override
         public void displayMessage(String msg) {
             if(_errorListener == null) {
                 System.err.println(msg);
             }
             else {

@@ -321,10 +318,11 @@
      *
      * @param source Contains the input XML document
      * @param result Will contain the output from the transformation
      * @throws TransformerException
      */
+    @Override
     public void transform(Source source, Result result)
         throws TransformerException
     {
         if (!_isIdentity) {
             if (_translet == null) {

@@ -463,11 +461,11 @@
                 }
 
                 // System Id may be in one of several forms, (1) a uri
                 // that starts with 'file:', (2) uri that starts with 'http:'
                 // or (3) just a filename on the local system.
-                URL url = null;
+                URL url;
                 if (systemId.startsWith("file:")) {
                     // if StreamResult(File) or setSystemID(File) was used,
                     // the systemId will be URI encoded as a result of File.toURI(),
                     // it must be decoded for use by URL
                     try{

@@ -535,11 +533,11 @@
     /**
      * Builds an internal DOM from a TrAX Source object
      */
     private DOM getDOM(Source source) throws TransformerException {
         try {
-            DOM dom = null;
+            DOM dom;
 
             if (source != null) {
                 DTMWSFilter wsfilter;
                 if (_translet != null && _translet instanceof StripFilter) {
                     wsfilter = new DOMWSFilter(_translet);

@@ -550,12 +548,11 @@
                  boolean hasIdCall = (_translet != null) ? _translet.hasIdCall()
                                                          : false;
 
                  if (_dtmManager == null) {
                      _dtmManager =
-                         (XSLTCDTMManager)_tfactory.getDTMManagerClass()
-                                                   .newInstance();
+                         _tfactory.createNewDTMManagerInstance();
                      _dtmManager.setServicesMechnism(_useServicesMechanism);
                  }
                  dom = (DOM)_dtmManager.getDTM(source, false, wsfilter, true,
                                               false, false, 0, hasIdCall);
             } else if (_dom != null) {

@@ -674,12 +671,12 @@
                     _readerManager.releaseXMLReader(reader);
                 }
             }
         } else if (source instanceof StAXSource) {
             final StAXSource staxSource = (StAXSource)source;
-            StAXEvent2SAX staxevent2sax = null;
-            StAXStream2SAX staxStream2SAX = null;
+            StAXEvent2SAX staxevent2sax;
+            StAXStream2SAX staxStream2SAX;
             if (staxSource.getXMLEventReader() != null) {
                 final XMLEventReader xmlEventReader = staxSource.getXMLEventReader();
                 staxevent2sax = new StAXEvent2SAX(xmlEventReader);
                 staxevent2sax.setContentHandler(handler);
                 staxevent2sax.parse();

@@ -768,10 +765,11 @@
      * Implements JAXP's Transformer.getErrorListener()
      * Get the error event handler in effect for the transformation.
      *
      * @return The error event handler currently in effect
      */
+    @Override
     public ErrorListener getErrorListener() {
         return _errorListener;
     }
 
     /**

@@ -781,10 +779,11 @@
      * xsl:messages to error listener.
      *
      * @param listener The error event listener to use
      * @throws IllegalArgumentException
      */
+    @Override
     public void setErrorListener(ErrorListener listener)
         throws IllegalArgumentException {
         if (listener == null) {
             ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
                                         "Transformer");

@@ -828,11 +827,11 @@
      */
     private String makeCDATAString(Hashtable cdata) {
         // Return a 'null' string if no CDATA section elements were specified
         if (cdata == null) return null;
 
-        StringBuffer result = new StringBuffer();
+        final StringBuilder result = new StringBuilder();
 
         // Get an enumeration of all the elements in the hashtable
         Enumeration elements = cdata.keys();
         if (elements.hasMoreElements()) {
             result.append((String)elements.nextElement());

@@ -855,10 +854,11 @@
      * element makes up the second level, while the default XSLT output
      * settings are returned on the third level.
      *
      * @return Properties in effect for this Transformer
      */
+    @Override
     public Properties getOutputProperties() {
         return (Properties) _properties.clone();
     }
 
     /**

@@ -868,10 +868,11 @@
      * or it may be a property specified in the stylesheet.
      *
      * @param name A non-null string that contains the name of the property
      * @throws IllegalArgumentException if the property name is not known
      */
+    @Override
     public String getOutputProperty(String name)
         throws IllegalArgumentException
     {
         if (!validOutputProperty(name)) {
             ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);

@@ -887,10 +888,11 @@
      * Unrecognised properties will be quitely ignored.
      *
      * @param properties The properties to use for the Transformer
      * @throws IllegalArgumentException Never, errors are ignored
      */
+    @Override
     public void setOutputProperties(Properties properties)
         throws IllegalArgumentException
     {
         if (properties != null) {
             final Enumeration names = properties.propertyNames();

@@ -923,10 +925,11 @@
      *
      * @param name The name of the property to set
      * @param value The value to assign to the property
      * @throws IllegalArgumentException Never, errors are ignored
      */
+    @Override
     public void setOutputProperty(String name, String value)
         throws IllegalArgumentException
     {
         if (!validOutputProperty(name)) {
             ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNKNOWN_PROP_ERR, name);

@@ -1203,10 +1206,11 @@
      * parameters are quitely ignored by the translet.
      *
      * @param name The name of the parameter
      * @param value The value to assign to the parameter
      */
+    @Override
     public void setParameter(String name, Object value) {
 
         if (value == null) {
             ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_SET_PARAM_VALUE, name);
             throw new IllegalArgumentException(err.toString());

@@ -1226,10 +1230,11 @@
     /**
      * Implements JAXP's Transformer.clearParameters()
      * Clear all parameters set with setParameter. Clears the translet's
      * parameter stack.
      */
+    @Override
     public void clearParameters() {
         if (_isIdentity && _parameters != null) {
             _parameters.clear();
         }
         else {

@@ -1243,10 +1248,11 @@
      * keep values for parameters that were not defined in the stylesheet.
      *
      * @param name The name of the parameter
      * @return An object that contains the value assigned to the parameter
      */
+    @Override
     public final Object getParameter(String name) {
         if (_isIdentity) {
             return (_parameters != null) ? _parameters.get(name) : null;
         }
         else {

@@ -1258,20 +1264,22 @@
      * Implements JAXP's Transformer.getURIResolver()
      * Set the object currently used to resolve URIs used in document().
      *
      * @return  The URLResolver object currently in use
      */
+    @Override
     public URIResolver getURIResolver() {
         return _uriResolver;
     }
 
     /**
      * Implements JAXP's Transformer.setURIResolver()
      * Set an object that will be used to resolve URIs used in document().
      *
      * @param resolver The URIResolver to use in document()
      */
+    @Override
     public void setURIResolver(URIResolver resolver) {
         _uriResolver = resolver;
     }
 
     /**

@@ -1286,10 +1294,11 @@
      *
      * @param baseURI The base URI used by the document call.
      * @param href The href argument passed to the document function.
      * @param translet A reference to the translet requesting the document
      */
+    @Override
     public DOM retrieveDocument(String baseURI, String href, Translet translet) {
         try {
             // Argument to document function was: document('');
             if (href.length() == 0) {
                 href = baseURI;

@@ -1328,10 +1337,11 @@
      * @param e The warning information encapsulated in a transformer
      * exception.
      * @throws TransformerException if the application chooses to discontinue
      * the transformation (always does in our case).
      */
+    @Override
     public void error(TransformerException e)
         throws TransformerException
     {
         Throwable wrapped = e.getException();
         if (wrapped != null) {

@@ -1356,10 +1366,11 @@
      * @param e The warning information encapsulated in a transformer
      * exception.
      * @throws TransformerException if the application chooses to discontinue
      * the transformation (always does in our case).
      */
+    @Override
     public void fatalError(TransformerException e)
         throws TransformerException
     {
         Throwable wrapped = e.getException();
         if (wrapped != null) {

@@ -1384,10 +1395,11 @@
      * @param e The warning information encapsulated in a transformer
      * exception.
      * @throws TransformerException if the application chooses to discontinue
      * the transformation (never does in our case).
      */
+    @Override
     public void warning(TransformerException e)
         throws TransformerException
     {
         Throwable wrapped = e.getException();
         if (wrapped != null) {

@@ -1404,10 +1416,11 @@
      * This method resets  the Transformer to its original configuration
      * Transformer code is reset to the same state it was when it was
      * created
      * @since 1.5
      */
+    @Override
     public void reset() {
 
         _method = null;
         _encoding = null;
         _sourceSystemId = null;