Project Report: fawkez

Packagesummary org.jcoderz.commons.taskdefs

org.jcoderz.commons.taskdefs.SaxonTask

LineHitsNoteSource
1  /*
2   * $Id: SaxonTask.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.commons.taskdefs;
34  
35  import java.io.File;
36  import java.io.IOException;
37  import org.apache.tools.ant.BuildException;
38  import org.apache.tools.ant.Project;
39  import org.apache.tools.ant.taskdefs.Java;
40  import org.jcoderz.commons.util.IoUtil;
41  
42  
43  /**
44   * Ant task wrapper for Saxon.
45   *
46   * @author Michael Griffel
47   */
48  public class SaxonTask
49        extends Java
50  {
51     private static final String SAXON_TRANSFORMER = "com.icl.saxon.StyleSheet";
52     /** The output file. */
53     private File mOutFile;
54     /** The input file. */
55     private File mInFile;
56     /** The XSL stylesheet file. */
57     private File mXslFile;
58     private File mHtmlStyleSheet;
59     private boolean mHaveRenderX;
60  
61     /**
62      * Constructor.
63      */
64     public SaxonTask ()
65     {
660       super();
670(1)      super.setClassname(SAXON_TRANSFORMER);
68        // defaults
690       setFork(true);
700       setFailonerror(true);
710    }
72  
73     /**
74      * Sets the XML input file that contains the document.
75      * @param f the XML input file (log message info).
76      */
77     public void setIn (File f)
78     {
790       mInFile = f;
80  
810    }
82  
83     /**
84      * Set the destination file into which the result is written.
85      * @param f the name of the destination file.
86      **/
87     public void setOut (File f)
88     {
890        mOutFile = f;
900    }
91  
92     /**
93      * Sets the XSL stylesheet file.
94      * @param f the XSL stylesheet file.
95      */
96     public void setXsl (File f)
97     {
980       mXslFile = f;
990    }
100  
101     /**
102      * Sets the CSS stylesheet file.
103      * @param f the CSS stylesheet file.
104      */
105     public void setCss (File f)
106     {
1070       mHtmlStyleSheet = f;
1080    }
109  
110     /** {@inheritDoc} */
111     public void setClassname (String arg0)
112           throws BuildException
113     {
1140(2)      throw new BuildException("classname attribute is not allowed!");
115     }
116  
117 (3)   public void setHaveRenderX (boolean b)
118     {
1190       mHaveRenderX = b;
1200    }
121  
122  
123     /** {@inheritDoc} */
124     public void execute ()
125           throws BuildException
126     {
1270       createArg().setValue("-x");
1280       createArg().setValue("org.apache.xml.resolver.tools.ResolvingXMLReader");
129  
1300       createArg().setValue("-y");
1310       createArg().setValue("org.apache.xml.resolver.tools.ResolvingXMLReader");
132  
1330       createArg().setValue("-r");
1340       createArg().setValue("org.apache.xml.resolver.tools.CatalogResolver");
135  
1360       createArg().setValue("-u");
137  
1380       createArg().setValue("-o");
1390       createArg().setFile(mOutFile);
1400       createArg().setValue(mInFile.toURI().toString());
1410       createArg().setValue(mXslFile.toURI().toString());
142  
1430       createJvmarg().setValue("-Djava.awt.headless=true");
144  
1450       if (mHtmlStyleSheet != null)
146        {
1470          log("Using CSS stylesheet " + mHtmlStyleSheet, Project.MSG_VERBOSE);
1480          final File out = new File(
149                 mOutFile.getParent(), mHtmlStyleSheet.getName());
150           try
151           {
1520             IoUtil.copy(mHtmlStyleSheet, out);
153           }
1540          catch (IOException e)
155           {
1560             throw new BuildException("Failed to copy CSS stylesheet "
157                    + mHtmlStyleSheet + " to " + out, e);
1580          }
1590          createArg().setValue(
160                 "html.stylesheet=" + out.getName());
161        }
162  
1630       if (mHaveRenderX)
164        {
1650          createArg().setValue(
166                 "xep.extensions=1");
167        }
168  
1690       super.execute();
1700    }
171  }

Findings in this File

i (1) 67 : 0 constructor new org.jcoderz.commons.taskdefs.SaxonTask() makes call to non-final method
i (2) 114 : 0 method org.jcoderz.commons.taskdefs.SaxonTask.setClassname(String) throws exception with static message string
c (3) 117 : 4 Missing a Javadoc comment.