jeremias    2003/02/14 03:18:55

  Modified:    src/org/apache/fop/tools/anttasks RunTest.java
                        SerializeHyphPattern.java Compare.java
               src/org/apache/fop/tools DocumentReader.java
                        TestConverter.java DocumentInputSource.java
               src/org/apache/fop/tools/xslt TraxTransform.java
                        XSLTransform.java
  Log:
  Checkstyle fixing
  
  Revision  Changes    Path
  1.7       +43 -27    xml-fop/src/org/apache/fop/tools/anttasks/RunTest.java
  
  Index: RunTest.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/anttasks/RunTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RunTest.java      8 Jan 2002 09:52:18 -0000       1.6
  +++ RunTest.java      14 Feb 2003 11:18:52 -0000      1.7
  @@ -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 @@
    * 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 @@
               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 @@
        * 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 @@
               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 @@
        * 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 @@
               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) {
  
  
  
  1.4       +18 -17    
xml-fop/src/org/apache/fop/tools/anttasks/SerializeHyphPattern.java
  
  Index: SerializeHyphPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/org/apache/fop/tools/anttasks/SerializeHyphPattern.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SerializeHyphPattern.java 9 Jan 2002 11:35:15 -0000       1.3
  +++ SerializeHyphPattern.java 14 Feb 2003 11:18:53 -0000      1.4
  @@ -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 @@
       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 @@
   
   
       /**
  -     * 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 @@
   
       /**
        * Sets the target directory
  -     *
  +     * @param targetDir target directory
        */
       public void setTargetDir(String targetDir) {
           File dir = new File(targetDir);
  @@ -65,8 +65,8 @@
       }
   
       /**
  -     * 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 @@
       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 @@
           }
           // 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) {
  
  
  
  1.4       +39 -18    xml-fop/src/org/apache/fop/tools/anttasks/Compare.java
  
  Index: Compare.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/anttasks/Compare.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Compare.java      2 Nov 2001 11:06:08 -0000       1.3
  +++ Compare.java      14 Feb 2003 11:18:53 -0000      1.4
  @@ -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 @@
           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 @@
           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 @@
       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 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]);
  
  
  
  1.3       +59 -57    xml-fop/src/org/apache/fop/tools/DocumentReader.java
  
  Index: DocumentReader.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/DocumentReader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DocumentReader.java       30 Jul 2001 20:29:35 -0000      1.2
  +++ DocumentReader.java       14 Feb 2003 11:18:54 -0000      1.3
  @@ -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 @@
       // //////////////////////////////////////////////////////////////////
       // Configuration.
       // //////////////////////////////////////////////////////////////////
  -    private boolean _namespaces = true;
  -    private boolean _namespace_prefixes = true;
  +    private boolean namespaces = true;
  +    private boolean namespacePrefixes = true;
   
   
       /**
  @@ -82,9 +92,9 @@
        *
        * @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 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 @@
        * 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 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 @@
        *
        * @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 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 @@
        * 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 @@
       // //////////////////////////////////////////////////////////////////
       // 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 @@
        * 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 @@
        * @see #setEntityResolver
        */
       public EntityResolver getEntityResolver() {
  -        return _entityResolver;
  +        return entityResolver;
       }
   
   
  @@ -272,12 +280,10 @@
        * 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 @@
        * @see #setDTDHandler
        */
       public DTDHandler getDTDHandler() {
  -        return _dtdHandler;
  +        return dtdHandler;
       }
   
   
  @@ -307,12 +313,10 @@
        * 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 @@
        * @see #setContentHandler
        */
       public ContentHandler getContentHandler() {
  -        return _contentHandler;
  +        return contentHandler;
       }
   
   
  @@ -344,12 +348,10 @@
        * 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 @@
        * @see #setErrorHandler
        */
       public ErrorHandler getErrorHandler() {
  -        return _errorHandler;
  +        return errorHandler;
       }
   
   
  @@ -374,11 +376,11 @@
        *
        *
        *
  -     * @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 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 @@
               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 @@
                           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 @@
                                                    att.getName(), "CDATA",
                                                    att.getValue());
                       }
  -                    _contentHandler.startElement(currentNode.getNamespaceURI(),
  +                    contentHandler.startElement(currentNode.getNamespaceURI(),
                                                    currentNode.getLocalName(),
                                                    currentNode.getNodeName(),
                                                    currentAtts);
  @@ -457,10 +459,10 @@
                   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 @@
        * 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)
  
  
  
  1.22      +65 -31    xml-fop/src/org/apache/fop/tools/TestConverter.java
  
  Index: TestConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/TestConverter.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- TestConverter.java        4 Sep 2002 08:36:36 -0000       1.21
  +++ TestConverter.java        14 Feb 2003 11:18:54 -0000      1.22
  @@ -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 javax.xml.parsers.*;
  -
  -import org.w3c.dom.*;
  +import java.io.File;
  +import java.io.InputStream;
  +import java.util.Map;
  +
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
  +
  +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 @@
    * 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 @@
        * -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 @@
           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 @@
        * 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 @@
        * 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 @@
                   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 @@
        * 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 @@
           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 @@
                   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 @@
               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 @@
   
       /**
        * 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 @@
                       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 @@
           }
       }
   
  -    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);
  
  
  
  1.3       +24 -11    xml-fop/src/org/apache/fop/tools/DocumentInputSource.java
  
  Index: DocumentInputSource.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/DocumentInputSource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DocumentInputSource.java  30 Jul 2001 20:29:35 -0000      1.2
  +++ DocumentInputSource.java  14 Feb 2003 11:18:54 -0000      1.3
  @@ -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;
       }
   
   }
  
  
  
  1.4       +51 -11    xml-fop/src/org/apache/fop/tools/xslt/TraxTransform.java
  
  Index: TraxTransform.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/xslt/TraxTransform.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TraxTransform.java        30 Jul 2001 20:29:35 -0000      1.3
  +++ TraxTransform.java        14 Feb 2003 11:18:54 -0000      1.4
  @@ -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 @@
   
               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 @@
   
       }
   
  +    /**
  +     * 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 @@
                     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 @@
   
       }
   
  +    /**
  +     * 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 @@
                     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 @@
                     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 {
  
  
  
  1.4       +43 -7     xml-fop/src/org/apache/fop/tools/xslt/XSLTransform.java
  
  Index: XSLTransform.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/xslt/XSLTransform.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLTransform.java 30 Jul 2001 20:29:35 -0000      1.3
  +++ XSLTransform.java 14 Feb 2003 11:18:54 -0000      1.4
  @@ -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 @@
           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 @@
   
       }
   
  +    /**
  +     * 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 @@
   
       }
   
  +    /**
  +     * 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 @@
                   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 @@
               transformer =
                   Class.forName("org.apache.fop.tools.xslt.Xalan1Transform");
               return transformer;
  -        } catch (ClassNotFoundException ex) {}
  +        } catch (ClassNotFoundException ex) {
  +            //nop
  +        }
           return null;
   
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to