]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Checkstyle fixing
authorJeremias Maerki <jeremias@apache.org>
Fri, 14 Feb 2003 11:18:54 +0000 (11:18 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 14 Feb 2003 11:18:54 +0000 (11:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195953 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/tools/DocumentInputSource.java
src/org/apache/fop/tools/DocumentReader.java
src/org/apache/fop/tools/TestConverter.java
src/org/apache/fop/tools/anttasks/Compare.java
src/org/apache/fop/tools/anttasks/RunTest.java
src/org/apache/fop/tools/anttasks/SerializeHyphPattern.java
src/org/apache/fop/tools/xslt/TraxTransform.java
src/org/apache/fop/tools/xslt/XSLTransform.java

index 2a382dbef5911085ba4c4416a499e3094a6f1669..7754a93b61825835e1fc681b7466e5030cfb4241 100644 (file)
@@ -1,41 +1,54 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
 
 package org.apache.fop.tools;
 
-import java.util.*;
-import org.w3c.dom.*;
-import org.xml.sax.*;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
 
 /**
  * This is an InputSource to be used with DocumentReader.
  *
  * @author Kelly A Campbell
- *
  */
-
 public class DocumentInputSource extends InputSource {
-    private Document _document;
+    
+    private Document document;
 
+    /**
+     * Default constructor.
+     */
     public DocumentInputSource() {
         super();
     }
 
+    /**
+     * Main constructor
+     * @param document the DOM document to use as input
+     */
     public DocumentInputSource(Document document) {
         this();
-        _document = document;
+        setDocument(document);
     }
 
+    /**
+     * Returns the input document.
+     * @return the input DOM document.
+     */
     public Document getDocument() {
-        return _document;
+        return this.document;
     }
 
+    /**
+     * Sets the input document.
+     * @param document the DOM document to use as input
+     */
     public void setDocument(Document document) {
-        _document = document;
+        this.document = document;
     }
 
 }
index 27421e490316e2b14f03a9f7e69661d23abd249f..6081a01c9f8ed8bb10c29f942eff603f254ed91b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
@@ -8,13 +8,23 @@
 package org.apache.fop.tools;
 
 import java.io.IOException;
-// import java.util.*;
 
 // DOM
-import org.w3c.dom.*;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
 
 // SAX
-import org.xml.sax.*;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+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.AttributesImpl;
 
 /**
@@ -30,8 +40,8 @@ public class DocumentReader implements XMLReader {
     // //////////////////////////////////////////////////////////////////
     // Configuration.
     // //////////////////////////////////////////////////////////////////
-    private boolean _namespaces = true;
-    private boolean _namespace_prefixes = true;
+    private boolean namespaces = true;
+    private boolean namespacePrefixes = true;
 
 
     /**
@@ -82,9 +92,9 @@ public class DocumentReader implements XMLReader {
      *
      * @param name The feature name, which is a fully-qualified URI.
      * @return The current state of the feature (true or false).
-     * @exception org.xml.sax.SAXNotRecognizedException When the
+     * @exception SAXNotRecognizedException When the
      * XMLReader does not recognize the feature name.
-     * @exception org.xml.sax.SAXNotSupportedException When the
+     * @exception SAXNotSupportedException When the
      * XMLReader recognizes the feature name but
      * cannot determine its value at this time.
      * @see #setFeature
@@ -92,12 +102,12 @@ public class DocumentReader implements XMLReader {
     public boolean getFeature(String name)
             throws SAXNotRecognizedException, SAXNotSupportedException {
         if ("http://xml.org/sax/features/namespaces".equals(name)) {
-            return _namespaces;
+            return namespaces;
         } else if ("http://xml.org/sax/features/namespace-prefixes".equals(name)) {
-            return _namespace_prefixes;
+            return namespacePrefixes;
         } else {
             throw new SAXNotRecognizedException("Feature '" + name
-                                                + "' not recognized or supported by Document2SAXAdapter");
+                    + "' not recognized or supported by Document2SAXAdapter");
         }
 
     }
@@ -123,10 +133,10 @@ public class DocumentReader implements XMLReader {
      * a parse.</p>
      *
      * @param name The feature name, which is a fully-qualified URI.
-     * @param state The requested state of the feature (true or false).
-     * @exception org.xml.sax.SAXNotRecognizedException When the
+     * @param value The requested state of the feature (true or false).
+     * @exception SAXNotRecognizedException When the
      * XMLReader does not recognize the feature name.
-     * @exception org.xml.sax.SAXNotSupportedException When the
+     * @exception SAXNotSupportedException When the
      * XMLReader recognizes the feature name but
      * cannot set the requested value.
      * @see #getFeature
@@ -134,12 +144,12 @@ public class DocumentReader implements XMLReader {
     public void setFeature(String name, boolean value)
             throws SAXNotRecognizedException, SAXNotSupportedException {
         if ("http://xml.org/sax/features/namespaces".equals(name)) {
-            _namespaces = value;
+            namespaces = value;
         } else if ("http://xml.org/sax/features/namespace-prefixes".equals(name)) {
-            _namespace_prefixes = value;
+            namespacePrefixes = value;
         } else {
             throw new SAXNotRecognizedException("Feature '" + name
-                                                + "' not recognized or supported by Document2SAXAdapter");
+                    + "' not recognized or supported by Document2SAXAdapter");
         }
 
     }
@@ -167,9 +177,9 @@ public class DocumentReader implements XMLReader {
      *
      * @param name The property name, which is a fully-qualified URI.
      * @return The current value of the property.
-     * @exception org.xml.sax.SAXNotRecognizedException When the
+     * @exception SAXNotRecognizedException When the
      * XMLReader does not recognize the property name.
-     * @exception org.xml.sax.SAXNotSupportedException When the
+     * @exception SAXNotSupportedException When the
      * XMLReader recognizes the property name but
      * cannot determine its value at this time.
      * @see #setProperty
@@ -177,7 +187,7 @@ public class DocumentReader implements XMLReader {
     public Object getProperty(String name)
             throws SAXNotRecognizedException, SAXNotSupportedException {
         throw new SAXNotRecognizedException("Property '" + name
-                                            + "' not recognized or supported by Document2SAXAdapter");
+                + "' not recognized or supported by Document2SAXAdapter");
     }
 
 
@@ -203,17 +213,17 @@ public class DocumentReader implements XMLReader {
      * extended handlers.</p>
      *
      * @param name The property name, which is a fully-qualified URI.
-     * @param state The requested value for the property.
-     * @exception org.xml.sax.SAXNotRecognizedException When the
+     * @param value The requested value for the property.
+     * @exception SAXNotRecognizedException When the
      * XMLReader does not recognize the property name.
-     * @exception org.xml.sax.SAXNotSupportedException When the
+     * @exception SAXNotSupportedException When the
      * XMLReader recognizes the property name but
      * cannot set the requested value.
      */
     public void setProperty(String name, Object value)
             throws SAXNotRecognizedException, SAXNotSupportedException {
         throw new SAXNotRecognizedException("Property '" + name
-                                            + "' not recognized or supported by Document2SAXAdapter");
+                + "' not recognized or supported by Document2SAXAdapter");
     }
 
 
@@ -221,10 +231,10 @@ public class DocumentReader implements XMLReader {
     // //////////////////////////////////////////////////////////////////
     // Event handlers.
     // //////////////////////////////////////////////////////////////////
-    private EntityResolver _entityResolver = null;
-    private DTDHandler _dtdHandler = null;
-    private ContentHandler _contentHandler = null;
-    private ErrorHandler _errorHandler = null;
+    private EntityResolver entityResolver = null;
+    private DTDHandler dtdHandler = null;
+    private ContentHandler contentHandler = null;
+    private ErrorHandler errorHandler = null;
 
 
     /**
@@ -238,12 +248,10 @@ public class DocumentReader implements XMLReader {
      * resolver immediately.</p>
      *
      * @param resolver The entity resolver.
-     * @exception java.lang.NullPointerException If the resolver
-     * argument is null.
      * @see #getEntityResolver
      */
     public void setEntityResolver(EntityResolver resolver) {
-        _entityResolver = resolver;
+        entityResolver = resolver;
     }
 
 
@@ -256,7 +264,7 @@ public class DocumentReader implements XMLReader {
      * @see #setEntityResolver
      */
     public EntityResolver getEntityResolver() {
-        return _entityResolver;
+        return entityResolver;
     }
 
 
@@ -272,12 +280,10 @@ public class DocumentReader implements XMLReader {
      * handler immediately.</p>
      *
      * @param handler The DTD handler.
-     * @exception java.lang.NullPointerException If the handler
-     * argument is null.
      * @see #getDTDHandler
      */
     public void setDTDHandler(DTDHandler handler) {
-        _dtdHandler = handler;
+        dtdHandler = handler;
     }
 
 
@@ -290,7 +296,7 @@ public class DocumentReader implements XMLReader {
      * @see #setDTDHandler
      */
     public DTDHandler getDTDHandler() {
-        return _dtdHandler;
+        return dtdHandler;
     }
 
 
@@ -307,12 +313,10 @@ public class DocumentReader implements XMLReader {
      * handler immediately.</p>
      *
      * @param handler The content handler.
-     * @exception java.lang.NullPointerException If the handler
-     * argument is null.
      * @see #getContentHandler
      */
     public void setContentHandler(ContentHandler handler) {
-        _contentHandler = handler;
+        contentHandler = handler;
     }
 
 
@@ -325,7 +329,7 @@ public class DocumentReader implements XMLReader {
      * @see #setContentHandler
      */
     public ContentHandler getContentHandler() {
-        return _contentHandler;
+        return contentHandler;
     }
 
 
@@ -344,12 +348,10 @@ public class DocumentReader implements XMLReader {
      * handler immediately.</p>
      *
      * @param handler The error handler.
-     * @exception java.lang.NullPointerException If the handler
-     * argument is null.
      * @see #getErrorHandler
      */
     public void setErrorHandler(ErrorHandler handler) {
-        _errorHandler = handler;
+        errorHandler = handler;
     }
 
     /**
@@ -360,7 +362,7 @@ public class DocumentReader implements XMLReader {
      * @see #setErrorHandler
      */
     public ErrorHandler getErrorHandler() {
-        return _errorHandler;
+        return errorHandler;
     }
 
 
@@ -374,11 +376,11 @@ public class DocumentReader implements XMLReader {
      *
      *
      *
-     * @param source The input source for the top-level of the
+     * @param input The input source for the top-level of the
      * XML document.
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
+     * @exception SAXException Any SAX exception, possibly
      * wrapping another exception.
-     * @exception java.io.IOException An IO exception from the parser,
+     * @exception IOException An IO exception from the parser,
      * possibly from a byte stream or character stream
      * supplied by the application.
      * @see org.xml.sax.InputSource
@@ -391,7 +393,7 @@ public class DocumentReader implements XMLReader {
     public void parse(InputSource input) throws IOException, SAXException {
         if (input instanceof DocumentInputSource) {
             Document document = ((DocumentInputSource)input).getDocument();
-            if (_contentHandler == null) {
+            if (contentHandler == null) {
                 throw new SAXException("ContentHandler is null. Please use setContentHandler()");
             }
 
@@ -411,7 +413,7 @@ public class DocumentReader implements XMLReader {
             while (currentNode != null) {
                 switch (currentNode.getNodeType()) {
                 case Node.DOCUMENT_NODE:
-                    _contentHandler.startDocument();
+                    contentHandler.startDocument();
                     break;
                 case Node.CDATA_SECTION_NODE:
                 case Node.TEXT_NODE:
@@ -425,10 +427,10 @@ public class DocumentReader implements XMLReader {
                         array = new char[datalen];
                     }
                     data.getChars(0, datalen, array, 0);
-                    _contentHandler.characters(array, 0, datalen);
+                    contentHandler.characters(array, 0, datalen);
                     break;
                 case Node.PROCESSING_INSTRUCTION_NODE:
-                    _contentHandler.processingInstruction(currentNode.getNodeName(),
+                    contentHandler.processingInstruction(currentNode.getNodeName(),
                                                           currentNode.getNodeValue());
                     break;
                 case Node.ELEMENT_NODE:
@@ -441,7 +443,7 @@ public class DocumentReader implements XMLReader {
                                                  att.getName(), "CDATA",
                                                  att.getValue());
                     }
-                    _contentHandler.startElement(currentNode.getNamespaceURI(),
+                    contentHandler.startElement(currentNode.getNamespaceURI(),
                                                  currentNode.getLocalName(),
                                                  currentNode.getNodeName(),
                                                  currentAtts);
@@ -457,10 +459,10 @@ public class DocumentReader implements XMLReader {
                 while (currentNode != null) {
                     switch (currentNode.getNodeType()) {
                     case Node.DOCUMENT_NODE:
-                        _contentHandler.endDocument();
+                        contentHandler.endDocument();
                         break;
                     case Node.ELEMENT_NODE:
-                        _contentHandler.endElement(currentNode.getNamespaceURI(),
+                        contentHandler.endElement(currentNode.getNamespaceURI(),
                                                    currentNode.getLocalName(),
                                                    currentNode.getNodeName());
                         break;
@@ -490,9 +492,9 @@ public class DocumentReader implements XMLReader {
      * instead
      *
      * @param systemId The system identifier (URI).
-     * @exception org.xml.sax.SAXException Any SAX exception, possibly
+     * @exception SAXException Any SAX exception, possibly
      * wrapping another exception.
-     * @exception java.io.IOException An IO exception from the parser,
+     * @exception IOException An IO exception from the parser,
      * possibly from a byte stream or character stream
      * supplied by the application.
      * @see #parse(org.xml.sax.InputSource)
index fac914a3fe02f2b7b117ed35cd463b5227a060c0..ff4126db36f6bcacb578e7e467f6c9e276579e7e 100644 (file)
@@ -1,28 +1,34 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
 
 package org.apache.fop.tools;
 
-import org.apache.fop.apps.*;
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.FOInputHandler;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.InputHandler;
+import org.apache.fop.apps.XSLTInputHandler;
 import org.apache.fop.fo.FOUserAgent;
 
 import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.InputStream;
+import java.util.Map;
 
-import javax.xml.parsers.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.w3c.dom.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 
 /**
  * TestConverter is used to process a set of tests specified in
@@ -38,12 +44,13 @@ import org.xml.sax.SAXParseException;
  * interface.
  */
 public class TestConverter extends AbstractLogEnabled {
-    boolean failOnly = false;
-    boolean outputPDF = false;
-    File destdir;
-    File compare = null;
-    String baseDir = "./";
-    HashMap differ = new HashMap();
+    
+    private boolean failOnly = false;
+    private boolean outputPDF = false;
+    private File destdir;
+    private File compare = null;
+    private String baseDir = "./";
+    private Map differ = new java.util.HashMap();
 
     /**
      * This main method can be used to run the test converter from
@@ -54,6 +61,7 @@ public class TestConverter extends AbstractLogEnabled {
      * -b to set the base directory for where the testsuite and associated files are
      * -failOnly to process only the tests which are specified as fail in the test results
      * -pdf to output the result as pdf
+     * @param args command-line arguments
      */
     public static void main(String[] args) {
         if (args == null || args.length == 0) {
@@ -81,14 +89,27 @@ public class TestConverter extends AbstractLogEnabled {
         tc.runTests(testFile, "results", null);
     }
 
+    /**
+     * Controls whether to generate PDF or XML.
+     * @param pdf If True, PDF is generated, Area Tree XML otherwise.
+     */
     public void setOutputPDF(boolean pdf) {
         outputPDF = pdf;
     }
 
+    /**
+     * Controls whether to process only the tests which are specified as fail 
+     * in the test results.
+     * @param fail True if only fail tests should be processed
+     */
     public void setFailOnly(boolean fail) {
         failOnly = fail;
     }
 
+    /**
+     * Sets the base directory.
+     * @param str base directory
+     */
     public void setBaseDir(String str) {
         baseDir = str;
     }
@@ -97,8 +118,12 @@ public class TestConverter extends AbstractLogEnabled {
      * Run the Tests.
      * This runs the tests specified in the xml file fname.
      * The document is read as a dom and each testcase is covered.
+     * @param fname filename of the input file
+     * @param dest destination directory
+     * @param compDir comparison directory
+     * @return Map a Map containing differences
      */
-    public HashMap runTests(String fname, String dest, String compDir) {
+    public Map runTests(String fname, String dest, String compDir) {
         getLogger().debug("running tests in file:" + fname);
         try {
             if (compDir != null) {
@@ -144,6 +169,7 @@ public class TestConverter extends AbstractLogEnabled {
      * This goes through a test case in the document.
      * A testcase can contain a test, a result or more test cases.
      * A test case is handled recursively otherwise the test is run.
+     * @param tcase Test case node to run
      */
     protected void runTestCase(Node tcase) {
         if (tcase.hasAttributes()) {
@@ -160,7 +186,9 @@ public class TestConverter extends AbstractLogEnabled {
                 runTestCase(node);
             } else if (nodename.equals("test")) {
                 runTest(tcase, node);
-            } else if (nodename.equals("result")) {}
+            } else if (nodename.equals("result")) {
+                //nop
+            }
 
         }
 
@@ -172,6 +200,8 @@ public class TestConverter extends AbstractLogEnabled {
      * If the test has a result specified it is checked.
      * This creates an XSLTInputHandler to provide the input
      * for FOP and writes the data out to an XML are tree.
+     * @param testcase Test case to run
+     * @param test Test
      */
     protected void runTest(Node testcase, Node test) {
         String id = test.getAttributes().getNamedItem("id").getNodeValue();
@@ -193,8 +223,8 @@ public class TestConverter extends AbstractLogEnabled {
         if (xslNode != null) {
             xsl = xslNode.getNodeValue();
         }
-        getLogger().debug("converting xml:" + xml + " and xsl:" +
-                  xsl + " to area tree");
+        getLogger().debug("converting xml:" + xml + " and xsl:" 
+                  xsl + " to area tree");
 
         try {
             File xmlFile = new File(baseDir + "/" + xml);
@@ -229,7 +259,7 @@ public class TestConverter extends AbstractLogEnabled {
                 driver.setRenderer(Driver.RENDER_XML);
             }
 
-            HashMap rendererOptions = new HashMap();
+            Map rendererOptions = new java.util.HashMap();
             rendererOptions.put("fineDetail", new Boolean(false));
             rendererOptions.put("consistentOutput", new Boolean(true));
             driver.getRenderer().setOptions(rendererOptions);
@@ -239,8 +269,8 @@ public class TestConverter extends AbstractLogEnabled {
             if (outname.endsWith(".xml")) {
                 outname = outname.substring(0, outname.length() - 4);
             }
-            driver.setOutputStream(new BufferedOutputStream(
-                                       new FileOutputStream(new File(destdir,
+            driver.setOutputStream(new java.io.BufferedOutputStream(
+                                       new java.io.FileOutputStream(new File(destdir,
                                        outname + (outputPDF ? ".pdf" : ".at.xml")))));
             getLogger().debug("ddir:" + destdir + " on:" + outname + ".pdf");
             driver.render(parser, inputHandler.getInputSource());
@@ -260,15 +290,17 @@ public class TestConverter extends AbstractLogEnabled {
 
     /**
      * Compare files.
-     * Returns true if equal.
+     * @param f1 first file
+     * @param f2 second file
+     * @return true if equal
      */
     protected boolean compareFiles(File f1, File f2) {
-        if(f1.length() != f2.length()) {
+        if (f1.length() != f2.length()) {
             return false;
         }
         try {
-            InputStream is1 = new BufferedInputStream(new FileInputStream(f1));
-            InputStream is2 = new BufferedInputStream(new FileInputStream(f2));
+            InputStream is1 = new java.io.BufferedInputStream(new java.io.FileInputStream(f1));
+            InputStream is2 = new java.io.BufferedInputStream(new java.io.FileInputStream(f2));
             while (true) {
                 int ch1 = is1.read();
                 int ch2 = is2.read();
@@ -280,12 +312,14 @@ public class TestConverter extends AbstractLogEnabled {
                     return false;
                 }
             }
-        } catch (Exception e) {}
+        } catch (Exception e) {
+            getLogger().error("Error while comparing files", e);
+        }
 
         return false;
     }
 
-    public void setParserFeatures(XMLReader parser) throws FOPException {
+    private void setParserFeatures(XMLReader parser) throws FOPException {
         try {
             parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
                               true);
@@ -295,7 +329,7 @@ public class TestConverter extends AbstractLogEnabled {
         }
     }
 
-    protected Node locateResult(Node testcase, String id) {
+    private Node locateResult(Node testcase, String id) {
         NodeList cases = testcase.getChildNodes();
         for (int count = 0; count < cases.getLength(); count++) {
             Node node = cases.item(count);
index 78908b04fd591fec1d898f3878fafdb6717d1e1b..f4feaa3f30469a0faa9e4a0f5c7fd0df0dabeb7d 100644 (file)
@@ -1,35 +1,44 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
 
 package org.apache.fop.tools.anttasks;
 
+import java.util.Date;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
 
-import java.util.*;
-import java.io.*;
-import org.apache.tools.ant.Task;
 import org.apache.tools.ant.BuildException;
 import java.text.DateFormat;
 
 /**
  * This class is an extension of Ant, a script utility from
- * jakarta.apache.org.
- * It provides methods to compare two files
+ * http://ant.apache.org.
+ * It provides methods to compare two files.
  */
 
 public class Compare {
+    
+    private static final boolean IDENTICAL_FILES = true;
+    private static final boolean NOTIDENTICAL_FILES = false;
+
     private String referenceDirectory, testDirectory;
     private String[] filenameList;
     private String filenames;
-    private static boolean IDENTICAL_FILES = true;
-    private static boolean NOTIDENTICAL_FILES = false;
     private BufferedInputStream oldfileInput;
     private BufferedInputStream newfileInput;
 
-    // sets directory for test files
+    /**
+     * Sets directory for test files.
+     * @param testDirectory the test directory
+     */
     public void setTestDirectory(String testDirectory) {
         if (!(testDirectory.endsWith("/") | testDirectory.endsWith("\\"))) {
             testDirectory += File.separator;
@@ -37,7 +46,10 @@ public class Compare {
         this.testDirectory = testDirectory;
     }
 
-    // sets directory for reference files
+    /**
+     * Sets directory for reference files.
+     * @param referenceDirectory the reference directory
+     */
     public void setReferenceDirectory(String referenceDirectory) {
         if (!(referenceDirectory.endsWith("/")
                 | referenceDirectory.endsWith("\\"))) {
@@ -46,9 +58,13 @@ public class Compare {
         this.referenceDirectory = referenceDirectory;
     }
 
+    /**
+     * Sets the comma-separated list of files to process.
+     * @param filenames list of files, comma-separated
+     */
     public void setFilenames(String filenames) {
         StringTokenizer tokens = new StringTokenizer(filenames, ",");
-        ArrayList filenameListTmp = new ArrayList(20);
+        List filenameListTmp = new java.util.ArrayList(20);
         while (tokens.hasMoreTokens()) {
             filenameListTmp.add(tokens.nextToken());
         }
@@ -59,9 +75,9 @@ public class Compare {
     private boolean compareBytes(File oldFile, File newFile) {
         try {
             oldfileInput =
-                new BufferedInputStream(new FileInputStream(oldFile));
+                new BufferedInputStream(new java.io.FileInputStream(oldFile));
             newfileInput =
-                new BufferedInputStream(new FileInputStream(newFile));
+                new BufferedInputStream(new java.io.FileInputStream(newFile));
             int charactO = 0;
             int charactN = 0;
             boolean identical = true;
@@ -104,27 +120,32 @@ public class Compare {
         }
     }
 
-    public void writeHeader(PrintWriter results) {
+    private void writeHeader(PrintWriter results) {
         String dateTime = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
                 DateFormat.MEDIUM).format(new Date());
         results.println("<html><head><title>Test Results</title></head><body>\n");
         results.println("<h2>Compare Results<br>");
         results.println("<font size='1'>created " + dateTime
                         + "</font></h2>");
-        results.println("<table cellpadding='10' border='2'><thead><th align='center'>reference file</th><th align='center'>test file</th>"
+        results.println("<table cellpadding='10' border='2'><thead>"
+                        + "<th align='center'>reference file</th>"
+                        + "<th align='center'>test file</th>"
                         + "<th align='center'>identical?</th></thead>");
 
 
     }
 
-    // main method of task compare
+    /**
+     * Main method of task compare
+     * @throws BuildException If the execution fails.
+     */
     public void execute() throws BuildException {
         boolean identical = false;
         File oldFile;
         File newFile;
         try {
             PrintWriter results =
-                new PrintWriter(new FileWriter("results.html"), true);
+                new PrintWriter(new java.io.FileWriter("results.html"), true);
             this.writeHeader(results);
             for (int i = 0; i < filenameList.length; i++) {
                 oldFile = new File(referenceDirectory + filenameList[i]);
index 78d19ca07db4b020f368da2c545e6c58fc5bec5a..272bb645cc4fa220652f887702eb5d9546626700 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
@@ -8,22 +8,19 @@
 package org.apache.fop.tools.anttasks;
 
 // Ant
-import org.apache.tools.ant.*;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
 
-import java.io.*;
-import java.lang.reflect.*;
+// Java
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.net.URLClassLoader;
 import java.net.URL;
 import java.net.MalformedURLException;
-import java.util.*;
+import java.util.Iterator;
+import java.util.Map;
 
-import javax.xml.parsers.*;
-
-import org.w3c.dom.*;
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 
 /**
  * Testing ant task.
@@ -32,33 +29,48 @@ import org.xml.sax.SAXParseException;
  * and check the results.
  */
 public class RunTest extends Task {
-    String basedir;
-    String testsuite = "";
-    String referenceJar = "";
-    String refVersion = "";
-
-    public RunTest() {}
+    
+    private String basedir;
+    private String testsuite = "";
+    private String referenceJar = "";
+    private String refVersion = "";
 
+    /**
+     * Sets the test suite name.
+     * @param str name of the test suite
+     */
     public void setTestSuite(String str) {
         testsuite = str;
     }
 
+    /**
+     * Sets the base directory.
+     * @param str base directory
+     */
     public void setBasedir(String str) {
         basedir = str;
     }
 
+    /**
+     * Sets the reference directory.
+     * @param str reference directory
+     */
     public void setReference(String str) {
         referenceJar = str;
     }
 
+    /**
+     * Sets the reference version.
+     * @param str reference version
+     */
     public void setRefVersion(String str) {
         refVersion = str;
     }
 
     /**
-     * Execute this ant task.
      * This creates the reference output, if required, then tests
      * the current build.
+     * @see org.apache.tools.ant.Task#execute()
      */
     public void execute() throws BuildException {
         runReference();
@@ -76,14 +88,14 @@ public class RunTest extends Task {
             ClassLoader loader = new URLClassLoader(new URL[] {
                 new URL("file:build/fop.jar")
             });
-            HashMap diff = runConverter(loader, "areatree",
+            Map diff = runConverter(loader, "areatree",
                                           "reference/output/");
-            if (diff != null &&!diff.isEmpty()) {
+            if (diff != null && !diff.isEmpty()) {
                 System.out.println("====================================");
                 System.out.println("The following files differ:");
                 boolean broke = false;
                 for (Iterator keys = diff.keySet().iterator();
-                        keys.hasNext(); ) {
+                        keys.hasNext();) {
                     Object fname = keys.next();
                     Boolean pass = (Boolean)diff.get(fname);
                     System.out.println("file: " + fname
@@ -107,6 +119,7 @@ public class RunTest extends Task {
      * run and then checks the version of the reference jar against
      * the version required.
      * The reference output is then created.
+     * @throws BuildException if an error occurs
      */
     protected void runReference() throws BuildException {
         // check not already done
@@ -124,7 +137,7 @@ public class RunTest extends Task {
             try {
                 Class cla = Class.forName("org.apache.fop.apps.Options",
                                           true, loader);
-                Object opts = cla.newInstance();
+                /*Object opts =*/ cla.newInstance();
                 cla = Class.forName("org.apache.fop.apps.Version", true,
                                     loader);
                 Method get = cla.getMethod("getVersion", new Class[]{});
@@ -164,12 +177,15 @@ public class RunTest extends Task {
      * then runs the test suite for the current test suite
      * file in the base directory.
      * @param loader the class loader to use to run the tests with
+     * @param dest destination directory
+     * @param compDir comparison directory
+     * @return A Map with differences
      */
-    protected HashMap runConverter(ClassLoader loader, String dest,
+    protected Map runConverter(ClassLoader loader, String dest,
                                      String compDir) {
         String converter = "org.apache.fop.tools.TestConverter";
 
-        HashMap diff = null;
+        Map diff = null;
         try {
             Class cla = Class.forName(converter, true, loader);
             Object tc = cla.newInstance();
@@ -185,7 +201,7 @@ public class RunTest extends Task {
             meth = cla.getMethod("runTests", new Class[] {
                 String.class, String.class, String.class
             });
-            diff = (HashMap)meth.invoke(tc, new Object[] {
+            diff = (Map)meth.invoke(tc, new Object[] {
                 testsuite, dest, compDir
             });
         } catch (Exception e) {
index b8f3a8808f11721a3ee04daced76e784fe854d65..4a95fc40ed8370ce7abfdaf50c307bc39cf78665 100644 (file)
@@ -1,22 +1,22 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
 
 package org.apache.fop.tools.anttasks;
 
-// package org.apache.tools.ant.taskdefs;
+// Java
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
 
+// Ant
 import org.apache.tools.ant.taskdefs.MatchingTask;
 import org.apache.tools.ant.DirectoryScanner;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import org.xml.sax.SAXException;
 
-// fop
+// FOP
 import org.apache.fop.layout.hyphenation.HyphenationTree;
 import org.apache.fop.layout.hyphenation.HyphenationException;
 
@@ -30,7 +30,7 @@ public class SerializeHyphPattern extends MatchingTask {
     private boolean errorDump = false;
 
     /**
-     * Main method, which is called by ant.
+     * @see org.apache.tools.ant.Task#execute()
      */
     public void execute() throws org.apache.tools.ant.BuildException {
         DirectoryScanner ds = this.getDirectoryScanner(sourceDir);
@@ -42,8 +42,8 @@ public class SerializeHyphPattern extends MatchingTask {
 
 
     /**
-     * Sets the source directory
-     *
+     * Sets the source directory.
+     * @param sourceDir source directory
      */
     public void setSourceDir(String sourceDir) {
         File dir = new File(sourceDir);
@@ -57,7 +57,7 @@ public class SerializeHyphPattern extends MatchingTask {
 
     /**
      * Sets the target directory
-     *
+     * @param targetDir target directory
      */
     public void setTargetDir(String targetDir) {
         File dir = new File(targetDir);
@@ -65,8 +65,8 @@ public class SerializeHyphPattern extends MatchingTask {
     }
 
     /**
-     * more error information
-     *
+     * Controls the amount of error information dumped.
+     * @param errorDump True if more error info should be provided
      */
     public void setErrorDump(boolean errorDump) {
         this.errorDump = errorDump;
@@ -80,7 +80,7 @@ public class SerializeHyphPattern extends MatchingTask {
     private void processFile(String filename) {
         File infile = new File(sourceDir, filename + ".xml");
         File outfile = new File(targetDir, filename + ".hyp");
-        long outfileLastModified = outfile.lastModified();
+        //long outfileLastModified = outfile.lastModified();
         boolean startProcess = true;
 
         startProcess = rebuild(infile, outfile);
@@ -110,8 +110,9 @@ public class SerializeHyphPattern extends MatchingTask {
         }
         // serialize class
         try {
-            ObjectOutputStream out =
-                new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(outfile)));
+            ObjectOutputStream out = new ObjectOutputStream(
+                    new java.io.BufferedOutputStream(
+                    new java.io.FileOutputStream(outfile)));
             out.writeObject(hTree);
             out.close();
         } catch (IOException ioe) {
index d997c1a2791bf9d9ece634c574894468e70c40af..1d9f84dccb2c2ca230d3b7c7bdef4e16db5d7ece 100644 (file)
@@ -1,38 +1,48 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
 
 package org.apache.fop.tools.xslt;
 
-import javax.xml.transform.*;
-
-import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.Writer;
+import java.util.Map;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
 
-import java.util.Hashtable;
 import org.w3c.dom.Document;
 
 /**
  * Handles xslt tranformations via Trax (xalan2)
  */
-
 public class TraxTransform {
 
     /**
      * Cache of compiled stylesheets (filename, StylesheetRoot)
      */
-    private static Hashtable _stylesheetCache = new Hashtable();
+    private static Map stylesheetCache = new java.util.Hashtable();
 
+    /**
+     * Gets a Trax transformer
+     * @param xsltFilename Filename of the XSLT file
+     * @param cache True, if caching of the stylesheet is allowed
+     * @return Transformer the Trax transformer
+     */
     public static Transformer getTransformer(String xsltFilename,
                                              boolean cache) {
         try {
-            if (cache && _stylesheetCache.containsKey(xsltFilename)) {
+            if (cache && stylesheetCache.containsKey(xsltFilename)) {
                 Templates cachedStylesheet =
-                    (Templates)_stylesheetCache.get(xsltFilename);
+                    (Templates)stylesheetCache.get(xsltFilename);
                 return cachedStylesheet.newTransformer();
             }
 
@@ -49,7 +59,7 @@ public class TraxTransform {
 
             Templates compiledSheet = factory.newTemplates(xslSheet);
             if (cache) {
-                _stylesheetCache.put(xsltFilename, compiledSheet);
+                stylesheetCache.put(xsltFilename, compiledSheet);
             }
             return compiledSheet.newTransformer();
         } catch (TransformerConfigurationException ex) {
@@ -59,6 +69,12 @@ public class TraxTransform {
 
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Filename of the source XML file
+     * @param xslURL Filename of the XSLT filename
+     * @param outputFile Target filename
+     */
     public static void transform(String xmlSource, String xslURL,
                                  String outputFile) {
         transform(new javax.xml.transform.stream.StreamSource(xmlSource),
@@ -66,6 +82,12 @@ public class TraxTransform {
                   new javax.xml.transform.stream.StreamResult(outputFile));
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Source DOM Document
+     * @param xslURL Filename of the XSLT filename
+     * @param outputFile Target filename
+     */
     public static void transform(Document xmlSource, String xslURL,
                                  String outputFile) {
 
@@ -75,6 +97,12 @@ public class TraxTransform {
 
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Filename of the source XML file
+     * @param xslURL Filename of the XSLT filename
+     * @param output Target Writer instance
+     */
     public static void transform(String xmlSource, String xslURL,
                                  Writer output) {
         transform(new javax.xml.transform.stream.StreamSource(xmlSource),
@@ -82,6 +110,12 @@ public class TraxTransform {
                   new javax.xml.transform.stream.StreamResult(output));
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Source DOM Document
+     * @param xsl Filename of the XSLT filename
+     * @param outputDoc Target DOM document
+     */
     public static void transform(Document xmlSource, InputStream xsl,
                                  Document outputDoc) {
         transform(new javax.xml.transform.dom.DOMSource(xmlSource),
@@ -89,6 +123,12 @@ public class TraxTransform {
                   new javax.xml.transform.dom.DOMResult(outputDoc));
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource XML Source
+     * @param xslSource XSLT Source
+     * @param result Target Result
+     */
     public static void transform(Source xmlSource, Source xslSource,
                                  Result result) {
         try {
index c764af22ef30349d473c3dd2dbcf5d4dbc3a423c..a7e9a1d57bca3eb847ca4c0d7d14573278f3f087 100644 (file)
@@ -1,18 +1,29 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
 
 package org.apache.fop.tools.xslt;
 
-import java.io.*;
-import java.lang.reflect.*;
-
+import java.io.InputStream;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
+/**
+ * Class for transforming XML using XSLT. Wraps either Trax (JAXP) or Xalan 1.x.
+ */
 public class XSLTransform {
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Filename of the source XML file
+     * @param xslURL Filename of the XSLT filename
+     * @param outputFile Target filename
+     * @throws Exception If the conversion fails
+     */
     public static void transform(String xmlSource, String xslURL,
                                  String outputFile) throws Exception {
         Class[] argTypes = {
@@ -24,6 +35,13 @@ public class XSLTransform {
         transform(params, argTypes);
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Source DOM Document
+     * @param xslURL Filename of the XSLT filename
+     * @param outputFile Target filename
+     * @throws Exception If the conversion fails
+     */
     public static void transform(org.w3c.dom.Document xmlSource,
                                  String xslURL,
                                  String outputFile) throws Exception {
@@ -38,6 +56,13 @@ public class XSLTransform {
 
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Filename of the source XML file
+     * @param xslURL Filename of the XSLT filename
+     * @param outputWriter Target Writer instance
+     * @throws Exception If the conversion fails
+     */
     public static void transform(String xmlSource, String xslURL,
                                  Writer outputWriter) throws Exception {
         Class[] argTypes = {
@@ -50,6 +75,13 @@ public class XSLTransform {
 
     }
 
+    /**
+     * Transforms an XML file using XSLT.
+     * @param xmlSource Source DOM Document
+     * @param xsl Filename of the XSLT filename
+     * @param outputDoc Target DOM document
+     * @throws Exception If the conversion fails
+     */
     public static void transform(org.w3c.dom.Document xmlSource,
                                  InputStream xsl,
                                  org.w3c.dom.Document outputDoc) throws Exception {
@@ -97,7 +129,9 @@ public class XSLTransform {
                 Class.forName("org.apache.fop.tools.xslt.TraxTransform");
             return transformer;
 
-        } catch (ClassNotFoundException ex) {}
+        } catch (ClassNotFoundException ex) {
+            //nop
+        }
         // otherwise, try regular xalan1
         try {
             Class transformer =
@@ -106,7 +140,9 @@ public class XSLTransform {
             transformer =
                 Class.forName("org.apache.fop.tools.xslt.Xalan1Transform");
             return transformer;
-        } catch (ClassNotFoundException ex) {}
+        } catch (ClassNotFoundException ex) {
+            //nop
+        }
         return null;
 
     }