git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274850 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -156,10 +156,8 @@ public class ANTLR extends Task { | |||
| public void setGlib(String superGrammar) { | |||
| String sg = null; | |||
| if (Os.isFamily("dos")) { | |||
| sg = superGrammar.replace('\\','/'); | |||
| } | |||
| else | |||
| { | |||
| sg = superGrammar.replace('\\', '/'); | |||
| } else { | |||
| sg = superGrammar; | |||
| } | |||
| setGlib(fileUtils.resolveFile(getProject().getBaseDir(), sg)); | |||
| @@ -304,8 +302,8 @@ public class ANTLR extends Task { | |||
| File generatedFile = getGeneratedFile(); | |||
| boolean targetIsOutOfDate = | |||
| target.lastModified() > generatedFile.lastModified(); | |||
| boolean superGrammarIsOutOfDate = superGrammar != null && | |||
| (superGrammar.lastModified() > generatedFile.lastModified()); | |||
| boolean superGrammarIsOutOfDate = superGrammar != null | |||
| && (superGrammar.lastModified() > generatedFile.lastModified()); | |||
| if (targetIsOutOfDate || superGrammarIsOutOfDate) { | |||
| if (targetIsOutOfDate) { | |||
| log("Compiling " + target + " as it is newer than " | |||
| @@ -431,6 +429,7 @@ public class ANTLR extends Task { | |||
| try { | |||
| bos.close(); | |||
| } catch (IOException e) { | |||
| // ignore | |||
| } | |||
| } | |||
| } | |||
| @@ -144,7 +144,7 @@ public class Cab extends MatchingTask { | |||
| protected void checkConfiguration() throws BuildException { | |||
| if (baseDir == null && filesets.size() == 0) { | |||
| throw new BuildException("basedir attribute or at least one " | |||
| + "nested filest is required!", | |||
| + "nested filest is required!", | |||
| getLocation()); | |||
| } | |||
| if (baseDir != null && !baseDir.exists()) { | |||
| @@ -266,7 +266,7 @@ public class Cab extends MatchingTask { | |||
| try { | |||
| Process p = Execute.launch(getProject(), | |||
| new String[] {"listcab"}, null, | |||
| baseDir != null ? baseDir | |||
| baseDir != null ? baseDir | |||
| : getProject().getBaseDir(), | |||
| true); | |||
| OutputStream out = p.getOutputStream(); | |||
| @@ -164,7 +164,7 @@ public class EchoProperties extends Task { | |||
| * | |||
| * @param file the input file | |||
| */ | |||
| public void setSrcfile( File file ) { | |||
| public void setSrcfile(File file) { | |||
| inFile = file; | |||
| } | |||
| @@ -260,16 +260,16 @@ public class EchoProperties extends Task { | |||
| if (inFile.exists() && !inFile.canRead()) { | |||
| String message = "Can not read from the specified srcfile!"; | |||
| if (failonerror) { | |||
| throw new BuildException( message, getLocation() ); | |||
| throw new BuildException(message, getLocation()); | |||
| } else { | |||
| log( message, Project.MSG_ERR ); | |||
| log(message, Project.MSG_ERR); | |||
| } | |||
| return; | |||
| } | |||
| FileInputStream in = null; | |||
| try { | |||
| in = new FileInputStream( inFile ); | |||
| in = new FileInputStream(inFile); | |||
| Properties props = new Properties(); | |||
| props.load(in); | |||
| CollectionUtils.putAll(allProps, props); | |||
| @@ -279,21 +279,21 @@ public class EchoProperties extends Task { | |||
| if (failonerror) { | |||
| throw new BuildException(message, fnfe, getLocation()); | |||
| } else { | |||
| log( message, Project.MSG_WARN ); | |||
| log(message, Project.MSG_WARN); | |||
| } | |||
| return; | |||
| } catch( IOException ioe ) { | |||
| } catch(IOException ioe) { | |||
| String message = | |||
| "Could not read file " + inFile.getAbsolutePath(); | |||
| if (failonerror) { | |||
| throw new BuildException(message, ioe, getLocation()); | |||
| } else { | |||
| log( message, Project.MSG_WARN ); | |||
| log(message, Project.MSG_WARN); | |||
| } | |||
| return; | |||
| } finally { | |||
| try { | |||
| if( null != in ) { | |||
| if(null != in) { | |||
| in.close(); | |||
| } | |||
| } catch(IOException ioe) {} | |||
| @@ -305,7 +305,7 @@ public class EchoProperties extends Task { | |||
| PropertySet ps = (PropertySet) enum.nextElement(); | |||
| CollectionUtils.putAll(allProps, ps.getProperties()); | |||
| } | |||
| OutputStream os = null; | |||
| try { | |||
| if (destfile == null) { | |||
| @@ -376,7 +376,7 @@ public class EchoProperties extends Task { | |||
| if ("text".equals(format)) { | |||
| jdkSaveProperties(props, os, "Ant properties"); | |||
| } else if ("xml".equals(format)) { | |||
| xmlSaveProperties(props, os ); | |||
| xmlSaveProperties(props, os); | |||
| } | |||
| } | |||
| @@ -384,29 +384,29 @@ public class EchoProperties extends Task { | |||
| OutputStream os) throws IOException { | |||
| // create XML document | |||
| Document doc = getDocumentBuilder().newDocument(); | |||
| Element rootElement = doc.createElement( PROPERTIES ); | |||
| Element rootElement = doc.createElement(PROPERTIES); | |||
| // output properties | |||
| String name; | |||
| Enumeration e = props.propertyNames(); | |||
| while( e.hasMoreElements() ) { | |||
| while(e.hasMoreElements()) { | |||
| name = (String)e.nextElement(); | |||
| Element propElement = doc.createElement( PROPERTY ); | |||
| propElement.setAttribute( ATTR_NAME, name ); | |||
| propElement.setAttribute( ATTR_VALUE, props.getProperty( name ) ); | |||
| rootElement.appendChild( propElement ); | |||
| Element propElement = doc.createElement(PROPERTY); | |||
| propElement.setAttribute(ATTR_NAME, name); | |||
| propElement.setAttribute(ATTR_VALUE, props.getProperty(name)); | |||
| rootElement.appendChild(propElement); | |||
| } | |||
| Writer wri = null; | |||
| try { | |||
| wri = new OutputStreamWriter( os, "UTF8" ); | |||
| wri.write( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ); | |||
| ( new DOMElementWriter() ).write( rootElement, wri, 0, "\t" ); | |||
| wri = new OutputStreamWriter(os, "UTF8"); | |||
| wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | |||
| (new DOMElementWriter()).write(rootElement, wri, 0, "\t"); | |||
| wri.flush(); | |||
| } catch( IOException ioe ) { | |||
| throw new BuildException( "Unable to write XML file", ioe ); | |||
| } catch(IOException ioe) { | |||
| throw new BuildException("Unable to write XML file", ioe); | |||
| } finally { | |||
| if( wri != null ) { | |||
| if(wri != null) { | |||
| wri.close(); | |||
| } | |||
| } | |||
| @@ -414,11 +414,11 @@ public class EchoProperties extends Task { | |||
| /** | |||
| * JDK 1.2 allows for the safer method | |||
| * <tt>Properties.store( OutputStream, String )</tt>, which throws an | |||
| * <tt>Properties.store(OutputStream, String)</tt>, which throws an | |||
| * <tt>IOException</tt> on an output error. This method attempts to | |||
| * use the JDK 1.2 method first, and if that does not exist, then the | |||
| * JDK 1.0 compatible method | |||
| * <tt>Properties.save( OutputStream, String )</tt> is used instead. | |||
| * <tt>Properties.save(OutputStream, String)</tt> is used instead. | |||
| * | |||
| *@param props the properties to record | |||
| *@param os record the properties to this output stream | |||
| @@ -476,8 +476,8 @@ public class EchoProperties extends Task { | |||
| private static DocumentBuilder getDocumentBuilder() { | |||
| try { | |||
| return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||
| } catch( Exception e ) { | |||
| throw new ExceptionInInitializerError( e ); | |||
| } catch(Exception e) { | |||
| throw new ExceptionInInitializerError(e); | |||
| } | |||
| } | |||
| } | |||
| @@ -78,10 +78,13 @@ import org.apache.tools.ant.types.Reference; | |||
| /** | |||
| * Instruments Java classes with iContract DBC preprocessor. | |||
| * <br/> | |||
| * The task can generate a properties file for <a href="http://hjem.sol.no/hellesoy/icontrol.html">iControl</a>, | |||
| * a graphical user interface that lets you turn on/off assertions. iControl generates a control file that you can refer to | |||
| * The task can generate a properties file for | |||
| * <a href="http://hjem.sol.no/hellesoy/icontrol.html">iControl</a>, | |||
| * a graphical user interface that lets you turn on/off assertions. | |||
| * iControl generates a control file that you can refer to | |||
| * from this task using the controlfile attribute. | |||
| * iContract is at <a href="http://www.reliable-systems.com/tools/">http://www.reliable-systems.com/tools/</a> | |||
| * iContract is at | |||
| * <a href="http://www.reliable-systems.com/tools/">http://www.reliable-systems.com/tools/</a> | |||
| * <p/> | |||
| * Thanks to Rainer Schmitz for enhancements and comments. | |||
| * | |||
| @@ -154,22 +157,25 @@ import org.apache.tools.ant.types.Reference; | |||
| * </tr> | |||
| * <tr> | |||
| * <td valign="top">verbosity</td> | |||
| * <td valign="top">Indicates the verbosity level of iContract. Any combination | |||
| * of <code>error*,warning*,note*,info*,progress*,debug*</code> (comma separated) can be | |||
| * used. Defaults to <code>error*</code></td> | |||
| * <td valign="top">Indicates the verbosity level of iContract. | |||
| * Any combination of | |||
| * <code>error*,warning*,note*,info*,progress*,debug*</code> | |||
| * (comma separated) can be used. Defaults to <code>error*</code></td> | |||
| * <td valign="top" align="center">No</td> | |||
| * </tr> | |||
| * <tr> | |||
| * <td valign="top">quiet</td> | |||
| * <td valign="top">Indicates if iContract should be quiet. Turn it off if many your classes extend uninstrumented classes | |||
| * and you don't want warnings about this. Defaults to <code>false</code></td> | |||
| * <td valign="top">Indicates if iContract should be quiet. Turn it off | |||
| * if many your classes extend uninstrumented classes and you don't | |||
| * want warnings about this. Defaults to <code>false</code></td> | |||
| * <td valign="top" align="center">No</td> | |||
| * </tr> | |||
| * <tr> | |||
| * <td valign="top">updateicontrol</td> | |||
| * <td valign="top">If set to true, it indicates that the properties file for | |||
| * iControl in the current directory should be updated (or created if it doesn't exist). | |||
| * Defaults to <code>false</code>.</td> | |||
| * <td valign="top">If set to true, it indicates that the properties | |||
| * file for iControl in the current directory should be updated | |||
| * (or created if it doesn't exist). Defaults to <code>false</code>. | |||
| * </td> | |||
| * <td valign="top" align="center">No</td> | |||
| * </tr> | |||
| * <tr> | |||
| @@ -614,7 +620,8 @@ public class IContract extends MatchingTask { | |||
| if (updateIcontrol) { | |||
| Properties iControlProps = new Properties(); | |||
| try {// to read existing propertiesfile | |||
| try { | |||
| // to read existing propertiesfile | |||
| iControlProps.load(new FileInputStream("icontrol.properties")); | |||
| } catch (IOException e) { | |||
| log("File icontrol.properties not found. That's ok. Writing a default one."); | |||
| @@ -625,7 +632,8 @@ public class IContract extends MatchingTask { | |||
| iControlProps.setProperty("controlFile", controlFile.getAbsolutePath()); | |||
| iControlProps.setProperty("targetsFile", targets.getAbsolutePath()); | |||
| try {// to read existing propertiesfile | |||
| try { | |||
| // to read existing propertiesfile | |||
| iControlProps.store(new FileOutputStream("icontrol.properties"), ICONTROL_PROPERTIES_HEADER); | |||
| log("Updated icontrol.properties"); | |||
| } catch (IOException e) { | |||
| @@ -644,7 +652,8 @@ public class IContract extends MatchingTask { | |||
| } | |||
| throw new BuildException("iContract instrumentation failed. Code=" + result); | |||
| } | |||
| } else {// not dirty | |||
| } else { | |||
| // not dirty | |||
| //log( "Nothing to do. Everything up to date." ); | |||
| } | |||
| } | |||
| @@ -664,10 +673,10 @@ public class IContract extends MatchingTask { | |||
| if (repositoryDir == null) { | |||
| throw new BuildException("repositorydir attribute must be set!", getLocation()); | |||
| } | |||
| if (updateIcontrol == true && classDir == null) { | |||
| if (updateIcontrol && classDir == null) { | |||
| throw new BuildException("classdir attribute must be specified when updateicontrol=true!", getLocation()); | |||
| } | |||
| if (updateIcontrol == true && controlFile == null) { | |||
| if (updateIcontrol && controlFile == null) { | |||
| throw new BuildException("controlfile attribute must be specified when updateicontrol=true!", getLocation()); | |||
| } | |||
| } | |||
| @@ -719,8 +728,8 @@ public class IContract extends MatchingTask { | |||
| File classFile = new File(buildDir, files[i].substring(0, files[i].indexOf(".java")) + ".class"); | |||
| if (srcFile.lastModified() > now) { | |||
| log("Warning: file modified in the future: " + | |||
| files[i], Project.MSG_WARN); | |||
| log("Warning: file modified in the future: " | |||
| + files[i], Project.MSG_WARN); | |||
| } | |||
| if (!classFile.exists() || srcFile.lastModified() > classFile.lastModified()) { | |||
| @@ -337,8 +337,8 @@ public class Javah extends Task { | |||
| throw new BuildException("Compile failed"); | |||
| } | |||
| */ | |||
| try { | |||
| Class javahMainClass = null; | |||
| try { | |||
| @@ -348,17 +348,17 @@ public class Javah extends Task { | |||
| // assume older than 1.4.2 tools.jar | |||
| javahMainClass = Class.forName("com.sun.tools.javah.Main"); | |||
| } | |||
| // now search for the constructor that takes in String[] arguments. | |||
| Class[] strings = new Class[] {String[].class}; | |||
| Constructor constructor = javahMainClass.getConstructor(strings); | |||
| // construct the javah Main instance | |||
| Object javahMain = constructor.newInstance(new Object[] {cmd.getArguments()}); | |||
| // find the run method | |||
| Method runMethod = javahMainClass.getMethod("run",new Class[0]); | |||
| runMethod.invoke(javahMain,new Object[0]); | |||
| } catch (Exception ex) { | |||
| if (ex instanceof BuildException) { | |||
| @@ -368,7 +368,7 @@ public class Javah extends Task { | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Does the command line argument processing common to classic and | |||
| * modern. | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -85,11 +85,11 @@ public class Native2Ascii extends MatchingTask { | |||
| /** | |||
| * Flag the conversion to run in the reverse sense, | |||
| * that is Ascii to Native encoding. | |||
| * | |||
| * | |||
| * @param reverse True if the conversion is to be reversed, | |||
| * otherwise false; | |||
| */ | |||
| public void setReverse(boolean reverse){ | |||
| public void setReverse(boolean reverse) { | |||
| this.reverse = reverse; | |||
| } | |||
| @@ -97,10 +97,10 @@ public class Native2Ascii extends MatchingTask { | |||
| * Set the encoding to translate to/from. | |||
| * If unset, the default encoding for the JVM is used. | |||
| * | |||
| * @param encoding String containing the name of the Native | |||
| * @param encoding String containing the name of the Native | |||
| * encoding to convert from or to. | |||
| */ | |||
| public void setEncoding(String encoding){ | |||
| public void setEncoding(String encoding) { | |||
| this.encoding = encoding; | |||
| } | |||
| @@ -109,7 +109,7 @@ public class Native2Ascii extends MatchingTask { | |||
| * | |||
| * @param srcDir directory to find input file in. | |||
| */ | |||
| public void setSrc(File srcDir){ | |||
| public void setSrc(File srcDir) { | |||
| this.srcDir = srcDir; | |||
| } | |||
| @@ -119,7 +119,7 @@ public class Native2Ascii extends MatchingTask { | |||
| * | |||
| * @param destDir directory to place output file into. | |||
| */ | |||
| public void setDest(File destDir){ | |||
| public void setDest(File destDir) { | |||
| this.destDir = destDir; | |||
| } | |||
| @@ -129,7 +129,7 @@ public class Native2Ascii extends MatchingTask { | |||
| * | |||
| * @param ext File extension to use for converted files. | |||
| */ | |||
| public void setExt(String ext){ | |||
| public void setExt(String ext) { | |||
| this.extension = ext; | |||
| } | |||
| @@ -151,19 +151,19 @@ public class Native2Ascii extends MatchingTask { | |||
| String[] files; // list of files to process | |||
| // default srcDir to basedir | |||
| if (srcDir == null){ | |||
| if (srcDir == null) { | |||
| srcDir = getProject().resolveFile("."); | |||
| } | |||
| // Require destDir | |||
| if (destDir == null){ | |||
| if (destDir == null) { | |||
| throw new BuildException("The dest attribute must be set."); | |||
| } | |||
| // if src and dest dirs are the same, require the extension | |||
| // to be set, so we don't stomp every file. One could still | |||
| // include a file with the same extension, but .... | |||
| if (srcDir.equals(destDir) && extension == null && mapper == null){ | |||
| if (srcDir.equals(destDir) && extension == null && mapper == null) { | |||
| throw new BuildException("The ext attribute or a mapper must be set if" | |||
| + " src and dest dirs are the same."); | |||
| } | |||
| @@ -178,7 +178,7 @@ public class Native2Ascii extends MatchingTask { | |||
| } else { | |||
| m = mapper.getImplementation(); | |||
| } | |||
| scanner = getDirectoryScanner(srcDir); | |||
| files = scanner.getIncludedFiles(); | |||
| SourceFileScanner sfs = new SourceFileScanner(this); | |||
| @@ -190,7 +190,7 @@ public class Native2Ascii extends MatchingTask { | |||
| String message = "Converting " + count + " file" | |||
| + (count != 1 ? "s" : "") + " from "; | |||
| log(message + srcDir + " to " + destDir); | |||
| for (int i = 0; i < files.length; i++){ | |||
| for (int i = 0; i < files.length; i++) { | |||
| convert(files[i], m.mapFileName(files[i])[0]); | |||
| } | |||
| } | |||
| @@ -209,11 +209,11 @@ public class Native2Ascii extends MatchingTask { | |||
| // Set up the basic args (this could be done once, but | |||
| // it's cleaner here) | |||
| if (reverse){ | |||
| if (reverse) { | |||
| cmd.createArgument().setValue("-reverse"); | |||
| } | |||
| if (encoding != null){ | |||
| if (encoding != null) { | |||
| cmd.createArgument().setValue("-encoding"); | |||
| cmd.createArgument().setValue(encoding); | |||
| } | |||
| @@ -225,27 +225,27 @@ public class Native2Ascii extends MatchingTask { | |||
| cmd.createArgument().setFile(srcFile); | |||
| cmd.createArgument().setFile(destFile); | |||
| // Make sure we're not about to clobber something | |||
| if (srcFile.equals(destFile)){ | |||
| throw new BuildException("file " + srcFile | |||
| if (srcFile.equals(destFile)) { | |||
| throw new BuildException("file " + srcFile | |||
| + " would overwrite its self"); | |||
| } | |||
| // Make intermediate directories if needed | |||
| // XXX JDK 1.1 dosen't have File.getParentFile, | |||
| String parentName = destFile.getParent(); | |||
| if (parentName != null){ | |||
| if (parentName != null) { | |||
| File parentFile = new File(parentName); | |||
| if ((!parentFile.exists()) && (!parentFile.mkdirs())){ | |||
| if ((!parentFile.exists()) && (!parentFile.mkdirs())) { | |||
| throw new BuildException("cannot create parent directory " | |||
| + parentName); | |||
| } | |||
| } | |||
| log("converting " + srcName, Project.MSG_VERBOSE); | |||
| sun.tools.native2ascii.Main n2a | |||
| = new sun.tools.native2ascii.Main(); | |||
| if (!n2a.convert(cmd.getArguments())){ | |||
| if (!n2a.convert(cmd.getArguments())) { | |||
| throw new BuildException("conversion failed"); | |||
| } | |||
| } | |||
| @@ -258,7 +258,7 @@ public class Native2Ascii extends MatchingTask { | |||
| public String[] mapFileName(String fileName) { | |||
| int lastDot = fileName.lastIndexOf('.'); | |||
| if (lastDot >= 0) { | |||
| return new String[] {fileName.substring(0, lastDot) | |||
| return new String[] {fileName.substring(0, lastDot) | |||
| + extension}; | |||
| } else { | |||
| return new String[] {fileName + extension}; | |||
| @@ -60,9 +60,6 @@ import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.OutputStream; | |||
| import java.lang.reflect.InvocationTargetException; | |||
| import java.lang.reflect.Method; | |||
| import java.text.DateFormat; | |||
| import java.text.DecimalFormat; | |||
| import java.text.ParseException; | |||
| @@ -195,7 +192,7 @@ public class PropertyFile extends Task { | |||
| properties = new Properties(); | |||
| try { | |||
| if (propertyfile.exists()) { | |||
| log("Updating property file: " | |||
| log("Updating property file: " | |||
| + propertyfile.getAbsolutePath()); | |||
| FileInputStream fis = null; | |||
| try { | |||
| @@ -208,7 +205,7 @@ public class PropertyFile extends Task { | |||
| } | |||
| } | |||
| } else { | |||
| log("Creating new property file: " | |||
| log("Creating new property file: " | |||
| + propertyfile.getAbsolutePath()); | |||
| FileOutputStream out = null; | |||
| try { | |||
| @@ -289,40 +286,40 @@ public class PropertyFile extends Task { | |||
| public void setKey(String value) { | |||
| this.key = value; | |||
| } | |||
| /** | |||
| /** | |||
| * Value to set (=), to add (+) or subtract (-) | |||
| */ | |||
| public void setValue(String value) { | |||
| this.value = value; | |||
| } | |||
| /** | |||
| * operation to apply. | |||
| * "+" or "=" | |||
| * operation to apply. | |||
| * "+" or "=" | |||
| *(default) for all datatypes; "-" for date and int only)\. | |||
| */ | |||
| public void setOperation(Operation value) { | |||
| this.operation = Operation.toOperation(value.getValue()); | |||
| } | |||
| /** | |||
| * Regard the value as : int, date or string (default) | |||
| */ | |||
| public void setType(Type value) { | |||
| this.type = Type.toType(value.getValue()); | |||
| } | |||
| /** | |||
| * Initial value to set for a property if it is not | |||
| * already defined in the property file. | |||
| * For type date, an additional keyword is allowed: "now" | |||
| */ | |||
| public void setDefault(String value) { | |||
| this.defaultValue = value; | |||
| } | |||
| /** | |||
| * For int and date type only. If present, Values will | |||
| * be parsed and formatted accordingly. | |||
| @@ -330,7 +327,7 @@ public class PropertyFile extends Task { | |||
| public void setPattern(String value) { | |||
| this.pattern = value; | |||
| } | |||
| /** | |||
| * The unit of the value to be applied to date +/- operations. | |||
| * Valid Values are: | |||
| @@ -344,7 +341,7 @@ public class PropertyFile extends Task { | |||
| * <li>month</li> | |||
| * <li>year</li> | |||
| * </ul> | |||
| * This only applies to date types using a +/- operation. | |||
| * This only applies to date types using a +/- operation. | |||
| * @since Ant 1.5 | |||
| */ | |||
| public void setUnit(PropertyFile.Unit unit) { | |||
| @@ -372,11 +369,11 @@ public class PropertyFile extends Task { | |||
| // which means do nothing | |||
| npe.printStackTrace(); | |||
| } | |||
| if (newValue == null) { | |||
| newValue = ""; | |||
| } | |||
| // Insert as a string by default | |||
| props.put(key, newValue); | |||
| } | |||
| @@ -400,17 +397,17 @@ public class PropertyFile extends Task { | |||
| if (currentStringValue == null) { | |||
| currentStringValue = DEFAULT_DATE_VALUE; | |||
| } | |||
| if ("now".equals(currentStringValue)) { | |||
| currentValue.setTime(new Date()); | |||
| } else { | |||
| try { | |||
| currentValue.setTime(fmt.parse(currentStringValue)); | |||
| } catch (ParseException pe) { | |||
| // swallow | |||
| } catch (ParseException pe) { | |||
| // swallow | |||
| } | |||
| } | |||
| if (operation != Operation.EQUALS_OPER) { | |||
| int offset = 0; | |||
| try { | |||
| @@ -454,7 +451,7 @@ public class PropertyFile extends Task { | |||
| } catch (ParseException pe) { | |||
| // swallow | |||
| } | |||
| if (operation == Operation.EQUALS_OPER) { | |||
| newValue = currentValue; | |||
| } else { | |||
| @@ -478,7 +475,7 @@ public class PropertyFile extends Task { | |||
| this.newValue = fmt.format(newValue); | |||
| } | |||
| /** | |||
| * Handle operations for type <code>string</code>. | |||
| * | |||
| @@ -490,11 +487,11 @@ public class PropertyFile extends Task { | |||
| String newValue = DEFAULT_STRING_VALUE; | |||
| String currentValue = getCurrentValue(oldValue); | |||
| if (currentValue == null) { | |||
| currentValue = DEFAULT_STRING_VALUE; | |||
| } | |||
| if (operation == Operation.EQUALS_OPER) { | |||
| newValue = currentValue; | |||
| } else if (operation == Operation.INCREMENT_OPER) { | |||
| @@ -502,7 +499,7 @@ public class PropertyFile extends Task { | |||
| } | |||
| this.newValue = newValue; | |||
| } | |||
| /** | |||
| * Check if parameter combinations can be supported | |||
| * @todo make sure the 'unit' attribute is only specified on date | |||
| @@ -511,11 +508,11 @@ public class PropertyFile extends Task { | |||
| private void checkParameters() throws BuildException { | |||
| if (type == Type.STRING_TYPE && | |||
| operation == Operation.DECREMENT_OPER) { | |||
| throw new BuildException("- is not suported for string " | |||
| throw new BuildException("- is not suported for string " | |||
| + "properties (key:" + key + ")"); | |||
| } | |||
| if (value == null && defaultValue == null) { | |||
| throw new BuildException("\"value\" and/or \"default\" " | |||
| throw new BuildException("\"value\" and/or \"default\" " | |||
| + "attribute must be specified (key:" + key + ")"); | |||
| } | |||
| if (key == null) { | |||
| @@ -523,7 +520,7 @@ public class PropertyFile extends Task { | |||
| } | |||
| if (type == Type.STRING_TYPE && | |||
| pattern != null) { | |||
| throw new BuildException("pattern is not suported for string " | |||
| throw new BuildException("pattern is not suported for string " | |||
| + "properties (key:" + key + ")"); | |||
| } | |||
| } | |||
| @@ -532,13 +529,13 @@ public class PropertyFile extends Task { | |||
| String ret = null; | |||
| if (operation == Operation.EQUALS_OPER) { | |||
| // If only value is specified, the property is set to it | |||
| // regardless of its previous value. | |||
| // regardless of its previous value. | |||
| if (value != null && defaultValue == null) { | |||
| ret = value; | |||
| } | |||
| // If only default is specified and the property previously | |||
| // existed in the property file, it is unchanged. | |||
| // existed in the property file, it is unchanged. | |||
| if (value == null && defaultValue != null && oldValue != null) { | |||
| ret = oldValue; | |||
| } | |||
| @@ -548,7 +545,7 @@ public class PropertyFile extends Task { | |||
| if (value == null && defaultValue != null && oldValue == null) { | |||
| ret = defaultValue; | |||
| } | |||
| // If value and default are both specified and the property | |||
| // previously existed in the property file, the property | |||
| // is set to value. | |||
| @@ -558,17 +555,17 @@ public class PropertyFile extends Task { | |||
| // If value and default are both specified and the property | |||
| // did not exist in the property file, the property is set | |||
| // to default. | |||
| // to default. | |||
| if (value != null && defaultValue != null && oldValue == null) { | |||
| ret = defaultValue; | |||
| } | |||
| } else { | |||
| ret = (oldValue == null) ? defaultValue : oldValue; | |||
| } | |||
| return ret; | |||
| } | |||
| /** | |||
| * Enumerated attribute with the values "+", "-", "=" | |||
| */ | |||
| @@ -617,7 +614,7 @@ public class PropertyFile extends Task { | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Borrowed from Tstamp | |||
| * @todo share all this time stuff across many tasks as a datetime datatype | |||
| @@ -103,7 +103,7 @@ public class RenameExtensions extends MatchingTask { | |||
| fromExtension = from; | |||
| } | |||
| /** | |||
| /** | |||
| * The string that renamed files will end with on | |||
| * completion | |||
| */ | |||
| @@ -133,7 +133,7 @@ public class RenameExtensions extends MatchingTask { | |||
| // first off, make sure that we've got a from and to extension | |||
| if (fromExtension == null || toExtension == null || srcDir == null) { | |||
| throw new BuildException("srcDir, fromExtension and toExtension " | |||
| throw new BuildException("srcDir, fromExtension and toExtension " | |||
| + "attributes must be set!"); | |||
| } | |||
| @@ -147,7 +147,7 @@ public class RenameExtensions extends MatchingTask { | |||
| log(" from=\"*" + fromExtension + "\"", Project.MSG_INFO); | |||
| log(" to=\"*" + toExtension + "\" />", Project.MSG_INFO); | |||
| log("</move>", Project.MSG_INFO); | |||
| log("using the same patterns on <fileset> as you\'ve used here", | |||
| log("using the same patterns on <fileset> as you\'ve used here", | |||
| Project.MSG_INFO); | |||
| Move move = (Move) getProject().createTask("move"); | |||
| @@ -102,8 +102,8 @@ import org.apache.tools.ant.util.regexp.Regexp; | |||
| * Call Syntax: | |||
| * | |||
| * <replaceregexp file="file" | |||
| * match="pattern" | |||
| * replace="pattern" | |||
| * match="pattern" | |||
| * replace="pattern" | |||
| * flags="options"? | |||
| * byline="true|false"? > | |||
| * regexp? | |||
| @@ -120,9 +120,9 @@ import org.apache.tools.ant.util.regexp.Regexp; | |||
| * Attributes: | |||
| * | |||
| * file --> A single file to operation on (mutually exclusive with the fileset subelements) | |||
| * match --> The Regular expression to match | |||
| * replace --> The Expression replacement string | |||
| * flags --> The options to give to the replacement | |||
| * match --> The Regular expression to match | |||
| * replace --> The Expression replacement string | |||
| * flags --> The options to give to the replacement | |||
| * g = Substitute all occurrences. default is to replace only the first one | |||
| * i = Case insensitive match | |||
| * | |||
| @@ -202,7 +202,7 @@ public class ReplaceRegExp extends Task { | |||
| * of the regular expression. | |||
| * Required if no nested <substitution> is used | |||
| */ | |||
| public void setReplace(String replace) { | |||
| if (subs != null) { | |||
| throw new BuildException("Only one substitution expression is " | |||
| @@ -219,12 +219,12 @@ public class ReplaceRegExp extends Task { | |||
| * <ul> | |||
| * <li>g : Global replacement. Replace all occurences found | |||
| * <li>i : Case Insensitive. Do not consider case in the match | |||
| * <li>m : Multiline. Treat the string as multiple lines of input, | |||
| * <li>m : Multiline. Treat the string as multiple lines of input, | |||
| * using "^" and "$" as the start or end of any line, respectively, rather than start or end of string. | |||
| * <li> s : Singleline. Treat the string as a single line of input, using | |||
| * "." to match any character, including a newline, which normally, it would not match. | |||
| *</ul> | |||
| */ | |||
| */ | |||
| public void setFlags(String flags) { | |||
| this.flags = flags; | |||
| } | |||
| @@ -303,7 +303,7 @@ public class ReplaceRegExp extends Task { | |||
| Regexp regexp = r.getRegexp(getProject()); | |||
| if (regexp.matches(input, options)) { | |||
| res = regexp.substitute(input, s.getExpression(getProject()), | |||
| res = regexp.substitute(input, s.getExpression(getProject()), | |||
| options); | |||
| } | |||
| @@ -441,7 +441,7 @@ public class ReplaceRegExp extends Task { | |||
| fileUtils.rename(temp, f); | |||
| temp = null; | |||
| } catch (IOException e) { | |||
| throw new BuildException("Couldn't rename temporary file " | |||
| throw new BuildException("Couldn't rename temporary file " | |||
| + temp, getLocation()); | |||
| } | |||
| } | |||
| @@ -502,12 +502,12 @@ public class ReplaceRegExp extends Task { | |||
| try { | |||
| doReplace(file, options); | |||
| } catch (IOException e) { | |||
| log("An error occurred processing file: '" | |||
| log("An error occurred processing file: '" | |||
| + file.getAbsolutePath() + "': " + e.toString(), | |||
| Project.MSG_ERR); | |||
| } | |||
| } else if (file != null) { | |||
| log("The following file is missing: '" | |||
| log("The following file is missing: '" | |||
| + file.getAbsolutePath() + "'", Project.MSG_ERR); | |||
| } | |||
| @@ -526,12 +526,12 @@ public class ReplaceRegExp extends Task { | |||
| try { | |||
| doReplace(f, options); | |||
| } catch (Exception e) { | |||
| log("An error occurred processing file: '" | |||
| log("An error occurred processing file: '" | |||
| + f.getAbsolutePath() + "': " + e.toString(), | |||
| Project.MSG_ERR); | |||
| } | |||
| } else { | |||
| log("The following file is missing: '" | |||
| log("The following file is missing: '" | |||
| + f.getAbsolutePath() + "'", Project.MSG_ERR); | |||
| } | |||
| } | |||
| @@ -79,7 +79,7 @@ import org.apache.tools.ant.types.Path; | |||
| * @author lucas@collab.net | |||
| */ | |||
| public class Rpm extends Task { | |||
| /** | |||
| * the spec file | |||
| */ | |||
| @@ -127,10 +127,10 @@ public class Rpm extends Task { | |||
| private File error; | |||
| public void execute() throws BuildException { | |||
| Commandline toExecute = new Commandline(); | |||
| toExecute.setExecutable(rpmBuildCommand == null | |||
| toExecute.setExecutable(rpmBuildCommand == null | |||
| ? guessRpmBuildCommand() | |||
| : rpmBuildCommand); | |||
| if (topDir != null) { | |||
| @@ -210,7 +210,7 @@ public class Rpm extends Task { | |||
| /** | |||
| * The directory which will have the expected | |||
| * subdirectories, SPECS, SOURCES, BUILD, SRPMS ; optional. | |||
| * subdirectories, SPECS, SOURCES, BUILD, SRPMS ; optional. | |||
| * If this isn't specified, | |||
| * the <tt>baseDir</tt> value is used | |||
| */ | |||
| @@ -237,7 +237,7 @@ public class Rpm extends Task { | |||
| } | |||
| /** | |||
| * Flag (optional, default=false) to remove | |||
| * Flag (optional, default=false) to remove | |||
| * the generated files in the BUILD directory | |||
| */ | |||
| public void setCleanBuildDir(boolean cbd) { | |||
| @@ -252,7 +252,7 @@ public class Rpm extends Task { | |||
| } | |||
| /** | |||
| * Flag (optional, default=false) | |||
| * Flag (optional, default=false) | |||
| * to remove the sources after the build. | |||
| * See the the <tt>--rmsource</tt> option of rpmbuild. | |||
| */ | |||
| @@ -307,8 +307,8 @@ public class Rpm extends Task { | |||
| Path p = new Path(getProject(), path); | |||
| String[] pElements = p.list(); | |||
| for (int i = 0; i < pElements.length; i++) { | |||
| File f = new File(pElements[i], | |||
| "rpmbuild" | |||
| File f = new File(pElements[i], | |||
| "rpmbuild" | |||
| + (Os.isFamily("dos") ? ".exe" : "")); | |||
| if (f.canRead()) { | |||
| return f.getAbsolutePath(); | |||
| @@ -1,7 +1,7 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| @@ -150,7 +150,7 @@ public class Script extends Task { | |||
| */ | |||
| public void setSrc(String fileName) { | |||
| File file = new File(fileName); | |||
| if (!file.exists()) { | |||
| if (!file.exists()) { | |||
| throw new BuildException("file " + fileName + " not found."); | |||
| } | |||
| @@ -164,7 +164,7 @@ public class Script extends Task { | |||
| } catch (IOException e) { | |||
| throw new BuildException(e); | |||
| } | |||
| script += new String(data); | |||
| } | |||
| @@ -85,10 +85,10 @@ public class StyleBook | |||
| } | |||
| /** | |||
| * The book xml file that the documentation generation starts from; | |||
| * The book xml file that the documentation generation starts from; | |||
| * required. | |||
| */ | |||
| public void setBook(final File book) { | |||
| m_book = book; | |||
| } | |||
| @@ -60,7 +60,7 @@ import org.apache.tools.ant.taskdefs.Java; | |||
| /** | |||
| * This is a primitive task to execute a unit test in the | |||
| * org.apache.testlet framework. | |||
| * | |||
| * | |||
| * @deprecated testlet has been abandoned in favor of JUnit by the | |||
| * Avalon community | |||
| * | |||
| @@ -109,17 +109,17 @@ public class Test extends Java { | |||
| /** | |||
| * a boolean value indicating whether tests should display a | |||
| * a boolean value indicating whether tests should display a | |||
| * message on success; optional | |||
| */ | |||
| public void setShowSuccess(final boolean showSuccess) { | |||
| createArg().setValue("-s=" + showSuccess); | |||
| } | |||
| /** | |||
| * a boolean value indicating whether a banner should be displayed | |||
| * a boolean value indicating whether a banner should be displayed | |||
| * when starting testlet engine; optional. | |||
| */ | |||
| public void setShowBanner(final String showBanner) { | |||
| @@ -128,7 +128,7 @@ public class Test extends Java { | |||
| /** | |||
| * a boolean indicating that a stack trace is displayed on | |||
| * a boolean indicating that a stack trace is displayed on | |||
| * error (but not normal failure); optional. | |||
| */ | |||
| public void setShowTrace(final boolean showTrace) { | |||
| @@ -118,12 +118,12 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| /** The In memory version of the stylesheet */ | |||
| private Templates templates; | |||
| /** | |||
| * The modification time of the stylesheet from which the templates | |||
| * are read | |||
| /** | |||
| * The modification time of the stylesheet from which the templates | |||
| * are read | |||
| */ | |||
| private long templatesModTime; | |||
| /** possible resolver for URIs */ | |||
| private URIResolver uriResolver; | |||
| @@ -143,10 +143,10 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| if (this.stylesheet != null) { | |||
| // resetting the stylesheet - reset transformer | |||
| transformer = null; | |||
| // do we need to reset templates as well | |||
| if (!this.stylesheet.equals(stylesheet) | |||
| || (stylesheet.lastModified() != templatesModTime)) { | |||
| || (stylesheet.lastModified() != templatesModTime)) { | |||
| templates = null; | |||
| } | |||
| } | |||
| @@ -222,7 +222,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| /** | |||
| * Read in templates from the stylsheet | |||
| */ | |||
| private void readTemplates() | |||
| private void readTemplates() | |||
| throws IOException, TransformerConfigurationException { | |||
| // WARN: Don't use the StreamSource(File) ctor. It won't work with | |||
| // xalan prior to 2.2 because of systemid bugs. | |||
| @@ -233,7 +233,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| // the file quickly on windows. | |||
| InputStream xslStream = null; | |||
| try { | |||
| xslStream | |||
| xslStream | |||
| = new BufferedInputStream(new FileInputStream(stylesheet)); | |||
| templatesModTime = stylesheet.lastModified(); | |||
| StreamSource src = new StreamSource(xslStream); | |||
| @@ -247,7 +247,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Create a new transformer based on the liaison settings | |||
| * @return the newly created and configured transformer. | |||
| @@ -333,7 +333,7 @@ public class TraXLiaison implements XSLTLiaison, ErrorListener, XSLTLoggerAware | |||
| * string or object. | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void setAttribute(String name, Object value){ | |||
| public void setAttribute(String name, Object value) { | |||
| final Object[] pair = new Object[]{name, value}; | |||
| attributes.addElement(pair); | |||
| } | |||
| @@ -105,24 +105,24 @@ public class XalanLiaison implements XSLTLiaison { | |||
| // collector will close them...whenever possible and | |||
| // Windows may complain about not being able to delete files. | |||
| try { | |||
| if (xslStream != null){ | |||
| if (xslStream != null) { | |||
| xslStream.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| } catch (IOException ignored) {} | |||
| try { | |||
| if (fis != null){ | |||
| if (fis != null) { | |||
| fis.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| } catch (IOException ignored) {} | |||
| try { | |||
| if (fos != null){ | |||
| if (fos != null) { | |||
| fos.close(); | |||
| } | |||
| } catch (IOException ignored){} | |||
| } catch (IOException ignored) {} | |||
| } | |||
| } | |||
| public void addParam(String name, String value){ | |||
| public void addParam(String name, String value) { | |||
| processor.setStylesheetParam(name, value); | |||
| } | |||
| @@ -89,7 +89,7 @@ public class XslpLiaison implements XSLTLiaison { | |||
| // it is really the pathname | |||
| xslSheet = xslReader.read(fileName.getAbsolutePath()); | |||
| } | |||
| public void transform(File infile, File outfile) throws Exception { | |||
| FileOutputStream fos = new FileOutputStream(outfile); | |||
| // XSLP does not support encoding...we're in hot water. | |||
| @@ -97,7 +97,7 @@ public class XslpLiaison implements XSLTLiaison { | |||
| processor.process(infile.getAbsolutePath(), xslSheet, out); | |||
| } | |||
| public void addParam(String name, String expression){ | |||
| public void addParam(String name, String expression) { | |||
| processor.setProperty(name, expression); | |||
| } | |||
| @@ -59,7 +59,7 @@ import java.io.FilenameFilter; | |||
| public class InnerClassFilenameFilter implements FilenameFilter { | |||
| private String baseClassName; | |||
| InnerClassFilenameFilter(String baseclass){ | |||
| InnerClassFilenameFilter(String baseclass) { | |||
| int extidx = baseclass.lastIndexOf(".class"); | |||
| if (extidx == -1) { | |||
| extidx = baseclass.length() - 1; | |||
| @@ -67,7 +67,7 @@ public class InnerClassFilenameFilter implements FilenameFilter { | |||
| baseClassName = baseclass.substring(0, extidx); | |||
| } | |||
| public boolean accept (File Dir, String filename){ | |||
| public boolean accept (File Dir, String filename) { | |||
| if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) | |||
| || (filename.indexOf(baseClassName + "$") != 0)) { | |||
| return false; | |||
| @@ -112,8 +112,8 @@ public class JavaCC extends Task { | |||
| protected static final int TASKDEF_TYPE_JJTREE = 2; | |||
| protected static final int TASKDEF_TYPE_JJDOC = 3; | |||
| protected static final String[] ARCHIVE_LOCATIONS = | |||
| new String[] {"JavaCC.zip", "bin/lib/JavaCC.zip", | |||
| protected static final String[] ARCHIVE_LOCATIONS = | |||
| new String[] {"JavaCC.zip", "bin/lib/JavaCC.zip", | |||
| "bin/lib/javacc.jar", | |||
| "javacc.jar", // used by jpackage for JavaCC 3.x | |||
| }; | |||
| @@ -353,7 +353,7 @@ public class JavaCC extends Task { | |||
| * @return the file object pointing to the JavaCC archive. | |||
| */ | |||
| protected static File getArchiveFile(File home) throws BuildException { | |||
| return new File(home, | |||
| return new File(home, | |||
| ARCHIVE_LOCATIONS[getMajorVersionNumber(home) - 1]); | |||
| } | |||
| @@ -365,7 +365,7 @@ public class JavaCC extends Task { | |||
| * or if the archive could not be found despite attempts to do so. | |||
| * @return the main class for the taskdef. | |||
| */ | |||
| protected static String getMainClass(File home, int type) | |||
| protected static String getMainClass(File home, int type) | |||
| throws BuildException { | |||
| int majorVersion = getMajorVersionNumber(home); | |||
| @@ -398,7 +398,7 @@ public class JavaCC extends Task { | |||
| case 3: | |||
| case 4: | |||
| /* | |||
| /* | |||
| * This is where the fun starts, JavaCC 3.0 uses | |||
| * org.netbeans.javacc, 3.1 uses org.javacc - I wonder | |||
| * which version is going to use net.java.javacc. | |||
| @@ -466,7 +466,7 @@ public class JavaCC extends Task { | |||
| * or if the archive could not be found despite attempts to do so. | |||
| * @return a number that is useless outside the scope of this class | |||
| */ | |||
| protected static int getMajorVersionNumber(File home) | |||
| protected static int getMajorVersionNumber(File home) | |||
| throws BuildException { | |||
| if (home == null || !home.isDirectory()) { | |||
| @@ -476,7 +476,7 @@ public class JavaCC extends Task { | |||
| for (int i = 0; i < ARCHIVE_LOCATIONS.length; i++) { | |||
| File f = new File(home, ARCHIVE_LOCATIONS[i]); | |||
| if (f.exists()){ | |||
| if (f.exists()) { | |||
| return (i + 1); | |||
| } | |||
| } | |||
| @@ -110,11 +110,11 @@ public class JDependTask extends Task { | |||
| static { | |||
| try { | |||
| Class packageFilter = | |||
| Class packageFilter = | |||
| Class.forName("jdepend.framework.PackageFilter"); | |||
| packageFilterC = | |||
| packageFilterC = | |||
| packageFilter.getConstructor(new Class[] {java.util.Collection.class}); | |||
| setFilter = | |||
| setFilter = | |||
| jdepend.textui.JDepend.class.getDeclaredMethod("setFilter", | |||
| new Class[] {packageFilter}); | |||
| } catch (Throwable t) { | |||
| @@ -199,9 +199,9 @@ public class JDependTask extends Task { | |||
| /** | |||
| * Gets the sourcepath. | |||
| * | |||
| * | |||
| * @deprecated | |||
| * | |||
| * | |||
| */ | |||
| public Path getSourcespath() { | |||
| return _sourcesPath; | |||
| @@ -219,7 +219,7 @@ public class JDependTask extends Task { | |||
| /** | |||
| * Gets the classespath. | |||
| * | |||
| * | |||
| */ | |||
| public Path getClassespath() { | |||
| return _classesPath; | |||
| @@ -355,7 +355,7 @@ public class JDependTask extends Task { | |||
| } | |||
| } | |||
| // if there is an error/failure and that it should halt, stop | |||
| // if there is an error/failure and that it should halt, stop | |||
| // everything otherwise just log a statement | |||
| boolean errorOccurred = exitValue == JDependTask.ERRORS; | |||
| @@ -391,7 +391,7 @@ public class JDependTask extends Task { | |||
| try { | |||
| fw = new FileWriter(getOutputFile().getPath()); | |||
| } catch (IOException e) { | |||
| String msg = "JDepend Failed when creating the output file: " | |||
| String msg = "JDepend Failed when creating the output file: " | |||
| + e.getMessage(); | |||
| log(msg); | |||
| throw new BuildException(msg); | |||
| @@ -507,8 +507,8 @@ public class JDependTask extends Task { | |||
| } | |||
| if (getOutputFile() != null) { | |||
| // having a space between the file and its path causes commandline | |||
| // to add quotes around the argument thus making JDepend not taking | |||
| // having a space between the file and its path causes commandline | |||
| // to add quotes around the argument thus making JDepend not taking | |||
| // it into account. Thus we split it in two | |||
| commandline.createArgument().setValue("-file"); | |||
| commandline.createArgument().setValue(_outputFile.getPath()); | |||
| @@ -522,7 +522,7 @@ public class JDependTask extends Task { | |||
| // not necessary as JDepend would fail, but why loose some time? | |||
| if (!f.exists() || !f.isDirectory()) { | |||
| throw new BuildException("\"" + f.getPath() + "\" does not " | |||
| throw new BuildException("\"" + f.getPath() + "\" does not " | |||
| + "represent a valid directory. JDepend would fail."); | |||
| } | |||
| commandline.createArgument().setValue(f.getPath()); | |||
| @@ -566,7 +566,7 @@ public class JDependTask extends Task { | |||
| return null; | |||
| /* | |||
| if (getTimeout() == null){ | |||
| if (getTimeout() == null) { | |||
| return null; | |||
| } | |||
| return new ExecuteWatchdog(getTimeout().intValue()); | |||
| @@ -61,7 +61,7 @@ import org.apache.tools.ant.types.Path; | |||
| /** | |||
| * This class defines objects that can link together various jar and | |||
| * zip files. | |||
| * zip files. | |||
| * | |||
| * <p>It is basically a wrapper for the jlink code written originally | |||
| * by <a href="mailto:beard@netscape.com">Patrick Beard</a>. The | |||
| @@ -154,11 +154,11 @@ public class JlinkTask extends MatchingTask { | |||
| public void execute() throws BuildException { | |||
| //Be sure everything has been set. | |||
| if (outfile == null) { | |||
| throw new BuildException("outfile attribute is required! " | |||
| throw new BuildException("outfile attribute is required! " | |||
| + "Please set."); | |||
| } | |||
| if (!haveAddFiles() && !haveMergeFiles()) { | |||
| throw new BuildException("addfiles or mergefiles required! " | |||
| throw new BuildException("addfiles or mergefiles required! " | |||
| + "Please set."); | |||
| } | |||
| log("linking: " + outfile.getPath()); | |||
| @@ -181,19 +181,19 @@ public class JlinkTask extends MatchingTask { | |||
| } | |||
| } | |||
| private boolean haveAddFiles(){ | |||
| private boolean haveAddFiles() { | |||
| return haveEntries(addfiles); | |||
| } | |||
| private boolean haveMergeFiles(){ | |||
| private boolean haveMergeFiles() { | |||
| return haveEntries(mergefiles); | |||
| } | |||
| private boolean haveEntries(Path p){ | |||
| if (p == null){ | |||
| private boolean haveEntries(Path p) { | |||
| if (p == null) { | |||
| return false; | |||
| } | |||
| if (p.size() > 0){ | |||
| if (p.size() > 0) { | |||
| return true; | |||
| } | |||
| return false; | |||
| @@ -164,7 +164,7 @@ public class JspC extends MatchingTask { | |||
| src.append(srcDir); | |||
| } | |||
| } | |||
| public Path getSrcDir(){ | |||
| public Path getSrcDir() { | |||
| return src; | |||
| } | |||
| @@ -175,28 +175,28 @@ public class JspC extends MatchingTask { | |||
| public void setDestdir(File destDir) { | |||
| this.destDir = destDir; | |||
| } | |||
| public File getDestdir(){ | |||
| public File getDestdir() { | |||
| return destDir; | |||
| } | |||
| /** | |||
| * Set the name of the package the compiled jsp files should be in. | |||
| */ | |||
| public void setPackage(String pkg){ | |||
| public void setPackage(String pkg) { | |||
| this.packageName = pkg; | |||
| } | |||
| public String getPackage(){ | |||
| public String getPackage() { | |||
| return packageName; | |||
| } | |||
| /** | |||
| * Set the verbose level of the compiler | |||
| */ | |||
| public void setVerbose(int i){ | |||
| public void setVerbose(int i) { | |||
| verbose = i; | |||
| } | |||
| public int getVerbose(){ | |||
| public int getVerbose() { | |||
| return verbose; | |||
| } | |||
| @@ -298,7 +298,7 @@ public class JspC extends MatchingTask { | |||
| public void setClasspathRef(Reference r) { | |||
| createClasspath().setRefid(r); | |||
| } | |||
| public Path getClasspath(){ | |||
| public Path getClasspath() { | |||
| return classpath; | |||
| } | |||
| @@ -316,7 +316,7 @@ public class JspC extends MatchingTask { | |||
| /** | |||
| * get the classpath used to find the compiler adapter | |||
| */ | |||
| public Path getCompilerclasspath(){ | |||
| public Path getCompilerclasspath() { | |||
| return compilerClasspath; | |||
| } | |||
| @@ -389,7 +389,7 @@ public class JspC extends MatchingTask { | |||
| /** | |||
| * get the list of files to compile | |||
| */ | |||
| public Vector getCompileList(){ | |||
| public Vector getCompileList() { | |||
| return compileList; | |||
| } | |||
| @@ -430,7 +430,7 @@ public class JspC extends MatchingTask { | |||
| if (src == null) { | |||
| throw new BuildException("srcdir attribute must be set!", | |||
| getLocation()); | |||
| } | |||
| } | |||
| String [] list = src.list(); | |||
| if (list.length == 0) { | |||
| throw new BuildException("srcdir attribute must be set!", | |||
| @@ -132,9 +132,9 @@ public class JasperC extends DefaultJspCompilerAdapter { | |||
| getJspc().deleteEmptyJavaFiles(); | |||
| } | |||
| } | |||
| /** | |||
| * build up a command line | |||
| * @return a command line for jasper | |||
| @@ -149,12 +149,12 @@ public class JasperC extends DefaultJspCompilerAdapter { | |||
| addArg(cmd, "-uribase", jspc.getUribase()); | |||
| addArg(cmd, "-ieplugin", jspc.getIeplugin()); | |||
| addArg(cmd, "-webinc", jspc.getWebinc()); | |||
| addArg(cmd, "-webxml", jspc.getWebxml()); | |||
| addArg(cmd, "-webxml", jspc.getWebxml()); | |||
| addArg(cmd, "-die9"); | |||
| if (jspc.isMapped()){ | |||
| if (jspc.isMapped()) { | |||
| addArg(cmd, "-mapped"); | |||
| } | |||
| } | |||
| if (jspc.getWebApp() != null) { | |||
| File dir = jspc.getWebApp().getDirectory(); | |||
| addArg(cmd, "-webapp", dir); | |||
| @@ -84,7 +84,7 @@ public class AggregateTransformer { | |||
| public static final String NOFRAMES = "noframes"; | |||
| public static class Format extends EnumeratedAttribute { | |||
| public String[] getValues(){ | |||
| public String[] getValues() { | |||
| return new String[]{FRAMES, NOFRAMES}; | |||
| } | |||
| } | |||
| @@ -106,16 +106,16 @@ public class AggregateTransformer { | |||
| /** XML Parser factory */ | |||
| private static DocumentBuilderFactory privateDBFactory; | |||
| /** XML Parser factory accessible to subclasses */ | |||
| protected static DocumentBuilderFactory dbfactory; | |||
| static { | |||
| privateDBFactory = DocumentBuilderFactory.newInstance(); | |||
| dbfactory = privateDBFactory; | |||
| } | |||
| public AggregateTransformer(Task task){ | |||
| public AggregateTransformer(Task task) { | |||
| this.task = task; | |||
| } | |||
| @@ -127,12 +127,12 @@ public class AggregateTransformer { | |||
| protected static DocumentBuilderFactory getDocumentBuilderFactory() { | |||
| return privateDBFactory; | |||
| } | |||
| public void setFormat(Format format){ | |||
| public void setFormat(Format format) { | |||
| this.format = format.getValue(); | |||
| } | |||
| public void setXmlDocument(Document doc){ | |||
| public void setXmlDocument(Document doc) { | |||
| this.document = doc; | |||
| } | |||
| @@ -151,7 +151,7 @@ public class AggregateTransformer { | |||
| } finally { | |||
| in.close(); | |||
| } | |||
| } catch (Exception e){ | |||
| } catch (Exception e) { | |||
| throw new BuildException("Error while parsing document: " + xmlfile, e); | |||
| } | |||
| } | |||
| @@ -162,17 +162,17 @@ public class AggregateTransformer { | |||
| * @param styledir the directory containing the xsl files if the user | |||
| * would like to override with its own style. | |||
| */ | |||
| public void setStyledir(File styledir){ | |||
| public void setStyledir(File styledir) { | |||
| this.styleDir = styledir; | |||
| } | |||
| /** set the destination directory */ | |||
| public void setTodir(File todir){ | |||
| public void setTodir(File todir) { | |||
| this.toDir = todir; | |||
| } | |||
| /** set the extension of the output files */ | |||
| public void setExtension(String ext){ | |||
| public void setExtension(String ext) { | |||
| task.log("extension is not used anymore", Project.MSG_WARN); | |||
| } | |||
| @@ -182,7 +182,7 @@ public class AggregateTransformer { | |||
| XalanExecutor executor = XalanExecutor.newInstance(this); | |||
| try { | |||
| executor.execute(); | |||
| } catch (Exception e){ | |||
| } catch (Exception e) { | |||
| throw new BuildException("Errors while applying transformations: " | |||
| + e.getMessage(), e); | |||
| } | |||
| @@ -210,18 +210,18 @@ public class AggregateTransformer { | |||
| */ | |||
| protected String getStylesheetSystemId() throws IOException { | |||
| String xslname = "junit-frames.xsl"; | |||
| if (NOFRAMES.equals(format)){ | |||
| if (NOFRAMES.equals(format)) { | |||
| xslname = "junit-noframes.xsl"; | |||
| } | |||
| if (styleDir == null){ | |||
| if (styleDir == null) { | |||
| URL url = getClass().getResource("xsl/" + xslname); | |||
| if (url == null){ | |||
| if (url == null) { | |||
| throw new FileNotFoundException("Could not find jar resource " + xslname); | |||
| } | |||
| return url.toExternalForm(); | |||
| } | |||
| File file = new File(styleDir, xslname); | |||
| if (!file.exists()){ | |||
| if (!file.exists()) { | |||
| throw new FileNotFoundException("Could not find file '" + file + "'"); | |||
| } | |||
| return JAXPUtils.getSystemId(file); | |||
| @@ -60,7 +60,7 @@ import java.util.Vector; | |||
| /** | |||
| * Baseclass for BatchTest and JUnitTest. | |||
| * | |||
| * @author Stefan Bodewig | |||
| * @author Stefan Bodewig | |||
| * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| public abstract class BaseTest { | |||
| @@ -84,7 +84,7 @@ public abstract class BaseTest { | |||
| public boolean getFiltertrace() { | |||
| return filtertrace; | |||
| } | |||
| public void setFork(boolean value) { | |||
| fork = value; | |||
| } | |||
| @@ -125,15 +125,15 @@ public abstract class BaseTest { | |||
| * Sets the destination directory. | |||
| */ | |||
| public void setTodir(File destDir) { | |||
| this.destDir = destDir; | |||
| this.destDir = destDir; | |||
| } | |||
| /** | |||
| * @return the destination directory as an absolute path if it exists | |||
| * otherwise return <tt>null</tt> | |||
| */ | |||
| public String getTodir(){ | |||
| if (destDir != null){ | |||
| public String getTodir() { | |||
| if (destDir != null) { | |||
| return destDir.getAbsolutePath(); | |||
| } | |||
| return null; | |||
| @@ -142,15 +142,15 @@ public abstract class BaseTest { | |||
| public java.lang.String getFailureProperty() { | |||
| return failureProperty; | |||
| } | |||
| public void setFailureProperty(String failureProperty) { | |||
| this.failureProperty = failureProperty; | |||
| } | |||
| public java.lang.String getErrorProperty() { | |||
| return errorProperty; | |||
| } | |||
| public void setErrorProperty(String errorProperty) { | |||
| this.errorProperty = errorProperty; | |||
| } | |||
| @@ -65,8 +65,8 @@ import org.apache.tools.ant.types.FileSet; | |||
| /** | |||
| * <p> Create then run <code>JUnitTest</code>'s based on the list of files given by the fileset attribute. | |||
| * | |||
| * <p> Every <code>.java</code> or <code>.class</code> file in the fileset is | |||
| * assumed to be a testcase. | |||
| * <p> Every <code>.java</code> or <code>.class</code> file in the fileset is | |||
| * assumed to be a testcase. | |||
| * A <code>JUnitTest</code> is created for each of these named classes with basic setup | |||
| * inherited from the parent <code>BatchTest</code>. | |||
| * | |||
| @@ -88,7 +88,7 @@ public final class BatchTest extends BaseTest { | |||
| * create a new batchtest instance | |||
| * @param project the project it depends on. | |||
| */ | |||
| public BatchTest(Project project){ | |||
| public BatchTest(Project project) { | |||
| this.project = project; | |||
| } | |||
| @@ -107,7 +107,7 @@ public final class BatchTest extends BaseTest { | |||
| * @return an enumeration of all elements of this batchtest that are | |||
| * a <tt>JUnitTest</tt> instance. | |||
| */ | |||
| public final Enumeration elements(){ | |||
| public final Enumeration elements() { | |||
| JUnitTest[] tests = createAllJUnitTest(); | |||
| return Enumerations.fromArray(tests); | |||
| } | |||
| @@ -118,7 +118,7 @@ public final class BatchTest extends BaseTest { | |||
| * @param v the vector to which should be added all individual tests of this | |||
| * batch test. | |||
| */ | |||
| final void addTestsTo(Vector v){ | |||
| final void addTestsTo(Vector v) { | |||
| JUnitTest[] tests = createAllJUnitTest(); | |||
| v.ensureCapacity(v.size() + tests.length); | |||
| for (int i = 0; i < tests.length; i++) { | |||
| @@ -131,7 +131,7 @@ public final class BatchTest extends BaseTest { | |||
| * is configured to match this instance properties. | |||
| * @return the array of all <tt>JUnitTest</tt>s that belongs to this batch. | |||
| */ | |||
| private JUnitTest[] createAllJUnitTest(){ | |||
| private JUnitTest[] createAllJUnitTest() { | |||
| String[] filenames = getFilenames(); | |||
| JUnitTest[] tests = new JUnitTest[filenames.length]; | |||
| for (int i = 0; i < tests.length; i++) { | |||
| @@ -151,7 +151,7 @@ public final class BatchTest extends BaseTest { | |||
| * qualified class name (If it is not the case it will fail when running the test). | |||
| * For the class <tt>org/apache/Whatever.class</tt> it will return <tt>org/apache/Whatever</tt>. | |||
| */ | |||
| private String[] getFilenames(){ | |||
| private String[] getFilenames() { | |||
| Vector v = new Vector(); | |||
| final int size = this.filesets.size(); | |||
| for (int j = 0; j < size; j++) { | |||
| @@ -181,7 +181,7 @@ public final class BatchTest extends BaseTest { | |||
| * @param filename the filename to "convert" to a classname. | |||
| * @return the classname matching the filename. | |||
| */ | |||
| public static final String javaToClass(String filename){ | |||
| public static final String javaToClass(String filename) { | |||
| return filename.replace(File.separatorChar, '.'); | |||
| } | |||
| @@ -192,7 +192,7 @@ public final class BatchTest extends BaseTest { | |||
| * <tt>JUnitTest</tt>. It must be a fully qualified name. | |||
| * @return the <tt>JUnitTest</tt> over the given classname. | |||
| */ | |||
| private JUnitTest createJUnitTest(String classname){ | |||
| private JUnitTest createJUnitTest(String classname) { | |||
| JUnitTest test = new JUnitTest(); | |||
| test.setName(classname); | |||
| test.setHaltonerror(this.haltOnError); | |||
| @@ -74,7 +74,7 @@ import org.w3c.dom.Text; | |||
| public final class DOMUtil { | |||
| /** unused constructor */ | |||
| private DOMUtil(){ | |||
| private DOMUtil() { | |||
| } | |||
| /** | |||
| @@ -98,7 +98,7 @@ public final class DOMUtil { | |||
| * @param recurse <tt>true</tt> if you want the list to be made recursively | |||
| * otherwise <tt>false</tt>. | |||
| */ | |||
| public static NodeList listChildNodes(Node parent, NodeFilter filter, boolean recurse){ | |||
| public static NodeList listChildNodes(Node parent, NodeFilter filter, boolean recurse) { | |||
| NodeListImpl matches = new NodeListImpl(); | |||
| NodeList children = parent.getChildNodes(); | |||
| if (children != null) { | |||
| @@ -122,13 +122,13 @@ public final class DOMUtil { | |||
| /** custom implementation of a nodelist */ | |||
| public static class NodeListImpl extends Vector implements NodeList { | |||
| public int getLength(){ | |||
| public int getLength() { | |||
| return size(); | |||
| } | |||
| public Node item(int i){ | |||
| public Node item(int i) { | |||
| try { | |||
| return (Node) elementAt(i); | |||
| } catch (ArrayIndexOutOfBoundsException e){ | |||
| } catch (ArrayIndexOutOfBoundsException e) { | |||
| return null; // conforming to NodeList interface | |||
| } | |||
| } | |||
| @@ -160,7 +160,7 @@ public final class DOMUtil { | |||
| * given name. | |||
| */ | |||
| public static Element getChildByTagName (Node parent, String tagname) { | |||
| if (parent == null){ | |||
| if (parent == null) { | |||
| return null; | |||
| } | |||
| NodeList childList = parent.getChildNodes(); | |||
| @@ -187,7 +187,7 @@ public final class DOMUtil { | |||
| * appended to <tt>parent</tt>. | |||
| * @return the cloned node that is appended to <tt>parent</tt> | |||
| */ | |||
| public static final Node importNode(Node parent, Node child){ | |||
| public static final Node importNode(Node parent, Node child) { | |||
| Node copy = null; | |||
| final Document doc = parent.getOwnerDocument(); | |||
| @@ -64,8 +64,8 @@ import java.util.NoSuchElementException; | |||
| * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| public final class Enumerations { | |||
| private Enumerations(){ | |||
| private Enumerations() { | |||
| } | |||
| /** | |||
| @@ -73,7 +73,7 @@ public final class Enumerations { | |||
| * @param array the array of object to enumerate. | |||
| * @return the enumeration over the array of objects. | |||
| */ | |||
| public static Enumeration fromArray(Object[] array){ | |||
| public static Enumeration fromArray(Object[] array) { | |||
| return new ArrayEnumeration(array); | |||
| } | |||
| @@ -84,7 +84,7 @@ public final class Enumerations { | |||
| * @param enums the array of enumerations. | |||
| * @return the enumeration over the array of enumerations. | |||
| */ | |||
| public static Enumeration fromCompound(Enumeration[] enums){ | |||
| public static Enumeration fromCompound(Enumeration[] enums) { | |||
| return new CompoundEnumeration(enums); | |||
| } | |||
| @@ -96,18 +96,18 @@ public final class Enumerations { | |||
| * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| class ArrayEnumeration implements Enumeration { | |||
| /** object array */ | |||
| private Object[] array; | |||
| /** current index */ | |||
| private int pos; | |||
| /** | |||
| * Initialize a new enumeration that wraps an array. | |||
| * @param array the array of object to enumerate. | |||
| */ | |||
| public ArrayEnumeration(Object[] array){ | |||
| public ArrayEnumeration(Object[] array) { | |||
| this.array = array; | |||
| this.pos = 0; | |||
| } | |||
| @@ -142,11 +142,11 @@ class ArrayEnumeration implements Enumeration { | |||
| * Convenient enumeration over an array of enumeration. For example: | |||
| * <pre> | |||
| * Enumeration e1 = v1.elements(); | |||
| * while (e1.hasMoreElements()){ | |||
| * while (e1.hasMoreElements()) { | |||
| * // do something | |||
| * } | |||
| * Enumeration e2 = v2.elements(); | |||
| * while (e2.hasMoreElements()){ | |||
| * while (e2.hasMoreElements()) { | |||
| * // do the same thing | |||
| * } | |||
| * </pre> | |||
| @@ -154,7 +154,7 @@ class ArrayEnumeration implements Enumeration { | |||
| * <pre> | |||
| * Enumeration[] enums = { v1.elements(), v2.elements() }; | |||
| * Enumeration e = Enumerations.fromCompound(enums); | |||
| * while (e.hasMoreElements()){ | |||
| * while (e.hasMoreElements()) { | |||
| * // do something | |||
| * } | |||
| * </pre> | |||
| @@ -163,17 +163,17 @@ class ArrayEnumeration implements Enumeration { | |||
| * <pre> | |||
| * Enumeration[] enums = { v1.elements(), null, v2.elements() }; // a null enumeration in the array | |||
| * Enumeration e = Enumerations.fromCompound(enums); | |||
| * while (e.hasMoreElements()){ | |||
| * while (e.hasMoreElements()) { | |||
| * // do something | |||
| * } | |||
| * </pre> | |||
| * @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a> | |||
| */ | |||
| class CompoundEnumeration implements Enumeration { | |||
| /** enumeration array */ | |||
| private Enumeration[] enumArray; | |||
| /** index in the enums array */ | |||
| private int index = 0; | |||
| @@ -911,7 +911,7 @@ public class JUnitTask extends Task { | |||
| * @since Ant 1.2 | |||
| */ | |||
| protected ExecuteWatchdog createWatchdog() throws BuildException { | |||
| if (timeout == null){ | |||
| if (timeout == null) { | |||
| return null; | |||
| } | |||
| return new ExecuteWatchdog(timeout.intValue()); | |||
| @@ -922,7 +922,7 @@ public class JUnitTask extends Task { | |||
| * | |||
| * @since Ant 1.3 | |||
| */ | |||
| protected OutputStream getDefaultOutput(){ | |||
| protected OutputStream getDefaultOutput() { | |||
| return new LogOutputStream(this, Project.MSG_INFO); | |||
| } | |||
| @@ -932,7 +932,7 @@ public class JUnitTask extends Task { | |||
| * | |||
| * @since Ant 1.3 | |||
| */ | |||
| protected Enumeration getIndividualTests(){ | |||
| protected Enumeration getIndividualTests() { | |||
| final int count = batchTests.size(); | |||
| final Enumeration[] enums = new Enumeration[ count + 1]; | |||
| for (int i = 0; i < count; i++) { | |||
| @@ -954,7 +954,7 @@ public class JUnitTask extends Task { | |||
| /** | |||
| * @since Ant 1.3 | |||
| */ | |||
| private FormatterElement[] mergeFormatters(JUnitTest test){ | |||
| private FormatterElement[] mergeFormatters(JUnitTest test) { | |||
| Vector feVector = (Vector) formatters.clone(); | |||
| test.addFormattersTo(feVector); | |||
| FormatterElement[] feArray = new FormatterElement[feVector.size()]; | |||
| @@ -968,7 +968,7 @@ public class JUnitTask extends Task { | |||
| * | |||
| * @since Ant 1.3 | |||
| */ | |||
| protected File getOutput(FormatterElement fe, JUnitTest test){ | |||
| protected File getOutput(FormatterElement fe, JUnitTest test) { | |||
| if (fe.getUseFile()) { | |||
| String filename = test.getOutfile() + fe.getExtension(); | |||
| File destFile = new File(test.getTodir(), filename); | |||
| @@ -76,10 +76,10 @@ import org.apache.tools.ant.Project; | |||
| * @see JUnitTestRunner | |||
| */ | |||
| public class JUnitTest extends BaseTest implements Cloneable { | |||
| /** the name of the test case */ | |||
| private String name = null; | |||
| /** the name of the result file */ | |||
| private String outfile = null; | |||
| @@ -99,7 +99,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| this.name = name; | |||
| } | |||
| public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, | |||
| public JUnitTest(String name, boolean haltOnError, boolean haltOnFailure, | |||
| boolean filtertrace) { | |||
| this.name = name; | |||
| this.haltOnError = haltOnError; | |||
| @@ -107,7 +107,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| this.filtertrace = filtertrace; | |||
| } | |||
| /** | |||
| /** | |||
| * Set the name of the test class. | |||
| */ | |||
| public void setName(String value) { | |||
| @@ -121,7 +121,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| outfile = value; | |||
| } | |||
| /** | |||
| /** | |||
| * Get the name of the test class. | |||
| */ | |||
| public String getName() { | |||
| @@ -130,7 +130,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| /** | |||
| * Get the name of the output file | |||
| * | |||
| * | |||
| * @return the name of the output file. | |||
| */ | |||
| public String getOutfile() { | |||
| @@ -150,15 +150,15 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| public long runCount() { | |||
| return runs; | |||
| } | |||
| public long failureCount() { | |||
| return failures; | |||
| } | |||
| public long errorCount() { | |||
| return errors; | |||
| } | |||
| public long getRunTime() { | |||
| return runTime; | |||
| } | |||
| @@ -166,9 +166,9 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| public Properties getProperties() { | |||
| return props; | |||
| } | |||
| public void setProperties(Hashtable p) { | |||
| props = new Properties(); | |||
| public void setProperties(Hashtable p) { | |||
| props = new Properties(); | |||
| for (Enumeration enum = p.keys(); enum.hasMoreElements();) { | |||
| Object key = enum.nextElement(); | |||
| props.put(key, p.get(key)); | |||
| @@ -178,7 +178,7 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| public boolean shouldRun(Project p) { | |||
| if (ifProperty != null && p.getProperty(ifProperty) == null) { | |||
| return false; | |||
| } else if (unlessProperty != null && | |||
| } else if (unlessProperty != null && | |||
| p.getProperty(unlessProperty) != null) { | |||
| return false; | |||
| } | |||
| @@ -195,9 +195,9 @@ public class JUnitTest extends BaseTest implements Cloneable { | |||
| /** | |||
| * Convenient method to add formatters to a vector | |||
| */ | |||
| void addFormattersTo(Vector v){ | |||
| void addFormattersTo(Vector v) { | |||
| final int count = formatters.size(); | |||
| for (int i = 0; i < count; i++){ | |||
| for (int i = 0; i < count; i++) { | |||
| v.addElement(formatters.elementAt(i)); | |||
| } | |||
| } | |||
| @@ -247,7 +247,7 @@ public class JUnitTestRunner implements TestListener { | |||
| // know exactly what is the cause, but we're doing exactly | |||
| // the same as JUnit TestRunner do. We swallow the exceptions. | |||
| } | |||
| if (suiteMethod != null){ | |||
| if (suiteMethod != null) { | |||
| // if there is a suite method available, then try | |||
| // to extract the suite from it. If there is an error | |||
| // here it will be caught below and reported. | |||
| @@ -114,7 +114,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| /** | |||
| * Generate a report based on the document created by the merge. | |||
| */ | |||
| public AggregateTransformer createReport(){ | |||
| public AggregateTransformer createReport() { | |||
| AggregateTransformer transformer = new AggregateTransformer(this); | |||
| transformers.addElement(transformer); | |||
| return transformer; | |||
| @@ -126,7 +126,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| * @param value the name of the file. | |||
| * @see #setTodir(File) | |||
| */ | |||
| public void setTofile(String value){ | |||
| public void setTofile(String value) { | |||
| toFile = value; | |||
| } | |||
| @@ -137,7 +137,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| * @param value the directory where to write the results, absolute or | |||
| * relative. | |||
| */ | |||
| public void setTodir(File value){ | |||
| public void setTodir(File value) { | |||
| toDir = value; | |||
| } | |||
| @@ -161,7 +161,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| // write the document | |||
| try { | |||
| writeDOMTree(rootElement.getOwnerDocument(), destFile); | |||
| } catch (IOException e){ | |||
| } catch (IOException e) { | |||
| throw new BuildException("Unable to write test aggregate to '" + destFile + "'", e); | |||
| } | |||
| // apply transformation | |||
| @@ -179,11 +179,11 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| * the <tt>todir</tt> and <tt>tofile</tt> attributes. | |||
| * @return the destination file where should be written the result file. | |||
| */ | |||
| protected File getDestinationFile(){ | |||
| if (toFile == null){ | |||
| protected File getDestinationFile() { | |||
| if (toFile == null) { | |||
| toFile = DEFAULT_FILENAME; | |||
| } | |||
| if (toDir == null){ | |||
| if (toDir == null) { | |||
| toDir = getProject().resolveFile(DEFAULT_DIR); | |||
| } | |||
| return new File(toDir, toFile); | |||
| @@ -235,7 +235,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); | |||
| wri.flush(); | |||
| // writers do not throw exceptions, so check for them. | |||
| if (wri.checkError()){ | |||
| if (wri.checkError()) { | |||
| throw new IOException("Error while writing DOM content"); | |||
| } | |||
| } finally { | |||
| @@ -270,7 +270,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| //XXX there seems to be a bug in xerces 1.3.0 that doesn't like file object | |||
| // will investigate later. It does not use the given directory but | |||
| // the vm dir instead ? Works fine with crimson. | |||
| Document testsuiteDoc | |||
| Document testsuiteDoc | |||
| = builder.parse("file:///" + files[i].getAbsolutePath()); | |||
| Element elem = testsuiteDoc.getDocumentElement(); | |||
| // make sure that this is REALLY a testsuite. | |||
| @@ -280,12 +280,12 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| // issue a warning. | |||
| log("the file " + files[i] + " is not a valid testsuite XML document", Project.MSG_WARN); | |||
| } | |||
| } catch (SAXException e){ | |||
| } catch (SAXException e) { | |||
| // a testcase might have failed and write a zero-length document, | |||
| // It has already failed, but hey.... mm. just put a warning | |||
| log("The file " + files[i] + " is not a valid XML document. It is possibly corrupted.", Project.MSG_WARN); | |||
| log(StringUtils.getStackTrace(e), Project.MSG_DEBUG); | |||
| } catch (IOException e){ | |||
| } catch (IOException e) { | |||
| log("Error while accessing file " + files[i] + ": " + e.getMessage(), Project.MSG_ERR); | |||
| } | |||
| } | |||
| @@ -304,7 +304,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||
| * modify the original node to change the name attribute and add | |||
| * a package one. | |||
| */ | |||
| protected void addTestSuite(Element root, Element testsuite){ | |||
| protected void addTestSuite(Element root, Element testsuite) { | |||
| String fullclassname = testsuite.getAttribute(ATTR_NAME); | |||
| int pos = fullclassname.lastIndexOf('.'); | |||
| @@ -76,13 +76,13 @@ abstract class XalanExecutor { | |||
| protected AggregateTransformer caller; | |||
| /** set the caller for this object. */ | |||
| private final void setCaller(AggregateTransformer caller){ | |||
| private final void setCaller(AggregateTransformer caller) { | |||
| this.caller = caller; | |||
| } | |||
| /** get the appropriate stream based on the format (frames/noframes) */ | |||
| protected OutputStream getOutputStream() throws IOException { | |||
| if (AggregateTransformer.FRAMES.equals(caller.format)){ | |||
| if (AggregateTransformer.FRAMES.equals(caller.format)) { | |||
| // dummy output for the framed report | |||
| // it's all done by extension... | |||
| return new ByteArrayOutputStream(); | |||
| @@ -109,7 +109,7 @@ abstract class XalanExecutor { | |||
| procVersion = Class.forName("org.apache.xalan.processor.XSLProcessorVersion"); | |||
| executor = (XalanExecutor) Class.forName( | |||
| "org.apache.tools.ant.taskdefs.optional.junit.Xalan2Executor").newInstance(); | |||
| } catch (Exception xalan2missing){ | |||
| } catch (Exception xalan2missing) { | |||
| StringWriter swr = new StringWriter(); | |||
| xalan2missing.printStackTrace(new PrintWriter(swr)); | |||
| caller.task.log("Didn't find Xalan2.", Project.MSG_DEBUG); | |||
| @@ -118,7 +118,7 @@ abstract class XalanExecutor { | |||
| procVersion = Class.forName("org.apache.xalan.xslt.XSLProcessorVersion"); | |||
| executor = (XalanExecutor) Class.forName( | |||
| "org.apache.tools.ant.taskdefs.optional.junit.Xalan1Executor").newInstance(); | |||
| } catch (Exception xalan1missing){ | |||
| } catch (Exception xalan1missing) { | |||
| swr = new StringWriter(); | |||
| xalan1missing.printStackTrace(new PrintWriter(swr)); | |||
| caller.task.log("Didn't find Xalan1.", Project.MSG_DEBUG); | |||
| @@ -137,7 +137,7 @@ abstract class XalanExecutor { | |||
| try { | |||
| Field f = procVersion.getField("S_VERSION"); | |||
| return f.get(null).toString(); | |||
| } catch (Exception e){ | |||
| } catch (Exception e) { | |||
| return "?"; | |||
| } | |||
| } | |||
| @@ -70,7 +70,7 @@ import org.apache.tools.ant.types.Path; | |||
| * <p> | |||
| * <i>maudit</i> performs static analysis of the Java source code and byte code files to find and report | |||
| * errors of style and potential problems related to performance, maintenance and robustness. | |||
| * As a convenience, a stylesheet is given in <tt>etc</tt> directory, so that an HTML report | |||
| * As a convenience, a stylesheet is given in <tt>etc</tt> directory, so that an HTML report | |||
| * can be generated from the XML file. | |||
| * | |||
| * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a> | |||
| @@ -135,16 +135,16 @@ public class MAudit extends AbstractMetamataTask { | |||
| super("com.metamata.gui.rc.MAudit"); | |||
| } | |||
| /** | |||
| /** | |||
| * The XML file to which the Audit result should be written to; required | |||
| */ | |||
| public void setTofile(File outFile) { | |||
| this.outFile = outFile; | |||
| } | |||
| /** | |||
| * Automatically fix certain errors | |||
| * Automatically fix certain errors | |||
| * (those marked as fixable in the manual); | |||
| * optional, default=false | |||
| */ | |||
| @@ -153,7 +153,7 @@ public class MAudit extends AbstractMetamataTask { | |||
| } | |||
| /** | |||
| * Creates listing file for each audited file; optional, default false. | |||
| * Creates listing file for each audited file; optional, default false. | |||
| * When set, a .maudit file will be generated in the | |||
| * same location as the source file. | |||
| */ | |||
| @@ -162,9 +162,9 @@ public class MAudit extends AbstractMetamataTask { | |||
| } | |||
| /** | |||
| * Finds declarations unused in search paths; optional, default false. | |||
| * Finds declarations unused in search paths; optional, default false. | |||
| * It will look for unused global declarations | |||
| * in the source code within a use domain specified by the | |||
| * in the source code within a use domain specified by the | |||
| * <tt>searchpath</tt> element. | |||
| */ | |||
| public void setUnused(boolean flag) { | |||
| @@ -181,7 +181,7 @@ public class MAudit extends AbstractMetamataTask { | |||
| } | |||
| /** | |||
| * flag to tell the task to exit after the first error. | |||
| * flag to tell the task to exit after the first error. | |||
| * internal/testing only | |||
| * @ant.attribute ignore="true" | |||
| */ | |||
| @@ -214,9 +214,9 @@ public class MAudit extends AbstractMetamataTask { | |||
| this.fullsemanticize = flag; | |||
| } | |||
| /** | |||
| /** | |||
| * classpath for additional audit rules | |||
| * these must be placed before metamata.jar !! | |||
| * these must be placed before metamata.jar !! | |||
| */ | |||
| public Path createRulespath() { | |||
| if (rulesPath == null) { | |||
| @@ -225,9 +225,9 @@ public class MAudit extends AbstractMetamataTask { | |||
| return rulesPath; | |||
| } | |||
| /** | |||
| * search path to use for unused global declarations; | |||
| * required when <tt>unused</tt> is set. | |||
| /** | |||
| * search path to use for unused global declarations; | |||
| * required when <tt>unused</tt> is set. | |||
| */ | |||
| public Path createSearchpath() { | |||
| if (searchPath == null) { | |||
| @@ -333,10 +333,10 @@ public class MAudit extends AbstractMetamataTask { | |||
| } catch (IOException e) { | |||
| throw new BuildException(e); | |||
| } finally { | |||
| if (out == null){ | |||
| if (out == null) { | |||
| try { | |||
| out.close(); | |||
| } catch (IOException e){ | |||
| } catch (IOException e) { | |||
| } | |||
| } | |||
| } | |||
| @@ -350,7 +350,7 @@ public class MAudit extends AbstractMetamataTask { | |||
| // the .maudit files match the .java files | |||
| // we'll use includedFiles to get the .maudit files. | |||
| /*if (out != null){ | |||
| /*if (out != null) { | |||
| // close it if not closed by the handler... | |||
| }*/ | |||
| } | |||
| @@ -82,7 +82,7 @@ final class MAuditParser { | |||
| /** matcher that will be used to extract the info from the line */ | |||
| private final RegexpMatcher matcher; | |||
| MAuditParser(){ | |||
| MAuditParser() { | |||
| /** the matcher should be the Oro one. I don't know about the other one */ | |||
| matcher = (new RegexpMatcherFactory()).newRegexpMatcher(); | |||
| matcher.setPattern(AUDIT_PATTERN); | |||
| @@ -95,9 +95,9 @@ final class MAuditParser { | |||
| * or <tt>null</tt> if it could not parse it. (might be a | |||
| * message info or copyright or summary). | |||
| */ | |||
| Violation parseLine(String line){ | |||
| Violation parseLine(String line) { | |||
| Vector matches = matcher.getGroups(line); | |||
| if (matches == null){ | |||
| if (matches == null) { | |||
| return null; | |||
| } | |||
| final String file = (String) matches.elementAt(1); | |||
| @@ -205,7 +205,7 @@ class MAuditStreamHandler implements ExecuteStreamHandler { | |||
| DOMElementWriter domWriter = new DOMElementWriter(); | |||
| try { | |||
| domWriter.write(rootElement, xmlOut); | |||
| } catch (IOException e){ | |||
| } catch (IOException e) { | |||
| throw new BuildException(e); | |||
| } | |||
| } | |||
| @@ -413,7 +413,7 @@ class MetricsElement { | |||
| while ((pos = line.indexOf('\t')) != -1) { | |||
| String token = line.substring(0, pos); | |||
| // only parse what coudl be a valid number. ie not constructs nor no value | |||
| /*if (metrics.size() != 0 || token.length() != 0){ | |||
| /*if (metrics.size() != 0 || token.length() != 0) { | |||
| Number num = METAMATA_NF.parse(token); // parse with Metamata NF | |||
| token = NEUTRAL_NF.format(num.doubleValue()); // and format with a neutral NF | |||
| }*/ | |||
| @@ -93,17 +93,17 @@ public class MParse extends AbstractMetamataTask { | |||
| } | |||
| /** set verbose mode */ | |||
| public void setVerbose(boolean flag){ | |||
| public void setVerbose(boolean flag) { | |||
| verbose = flag; | |||
| } | |||
| /** set scanner debug mode; optional, default false */ | |||
| public void setDebugscanner(boolean flag){ | |||
| public void setDebugscanner(boolean flag) { | |||
| debugscanner = flag; | |||
| } | |||
| /** set parser debug mode; optional, default false */ | |||
| public void setDebugparser(boolean flag){ | |||
| public void setDebugparser(boolean flag) { | |||
| debugparser = flag; | |||
| } | |||
| @@ -132,7 +132,7 @@ public class MParse extends AbstractMetamataTask { | |||
| } | |||
| /** return the default stream handler for this task */ | |||
| protected ExecuteStreamHandler createStreamHandler(){ | |||
| protected ExecuteStreamHandler createStreamHandler() { | |||
| return new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_INFO); | |||
| } | |||
| @@ -145,7 +145,7 @@ public class MParse extends AbstractMetamataTask { | |||
| // set the classpath as the jar files | |||
| File[] jars = getMetamataLibs(); | |||
| final Path classPath = cmdl.createClasspath(getProject()); | |||
| for (int i = 0; i < jars.length; i++){ | |||
| for (int i = 0; i < jars.length; i++) { | |||
| classPath.createPathElement().setLocation(jars[i]); | |||
| } | |||
| @@ -186,14 +186,14 @@ public class MParse extends AbstractMetamataTask { | |||
| if (process.execute() != 0) { | |||
| throw new BuildException("Metamata task failed."); | |||
| } | |||
| } catch (IOException e){ | |||
| } catch (IOException e) { | |||
| throw new BuildException("Failed to launch Metamata task: ", e); | |||
| } | |||
| } | |||
| /** clean up all the mess that we did with temporary objects */ | |||
| protected void cleanUp(){ | |||
| if (optionsFile != null){ | |||
| protected void cleanUp() { | |||
| if (optionsFile != null) { | |||
| optionsFile.delete(); | |||
| optionsFile = null; | |||
| } | |||
| @@ -216,7 +216,7 @@ public class MParse extends AbstractMetamataTask { | |||
| * forked process do it for you. | |||
| * @return array of jars/zips needed to run metamata. | |||
| */ | |||
| protected File[] getMetamataLibs(){ | |||
| protected File[] getMetamataLibs() { | |||
| Vector files = new Vector(); | |||
| files.addElement(new File(metamataHome, "lib/metamata.jar")); | |||
| files.addElement(new File(metamataHome, "bin/lib/JavaCC.zip")); | |||
| @@ -233,15 +233,15 @@ public class MParse extends AbstractMetamataTask { | |||
| */ | |||
| protected void checkOptions() throws BuildException { | |||
| // check that the home is ok. | |||
| if (metamataHome == null || !metamataHome.exists()){ | |||
| if (metamataHome == null || !metamataHome.exists()) { | |||
| throw new BuildException("'metamatahome' must point to Metamata home directory."); | |||
| } | |||
| metamataHome = getProject().resolveFile(metamataHome.getPath()); | |||
| // check that the needed jar exists. | |||
| File[] jars = getMetamataLibs(); | |||
| for (int i = 0; i < jars.length; i++){ | |||
| if (!jars[i].exists()){ | |||
| for (int i = 0; i < jars.length; i++) { | |||
| if (!jars[i].exists()) { | |||
| throw new BuildException(jars[i] | |||
| + " does not exist. Check your metamata installation."); | |||
| } | |||
| @@ -261,20 +261,20 @@ public class MParse extends AbstractMetamataTask { | |||
| */ | |||
| protected Vector getOptions() { | |||
| Vector options = new Vector(); | |||
| if (verbose){ | |||
| if (verbose) { | |||
| options.addElement("-verbose"); | |||
| } | |||
| if (debugscanner){ | |||
| if (debugscanner) { | |||
| options.addElement("-ds"); | |||
| } | |||
| if (debugparser){ | |||
| if (debugparser) { | |||
| options.addElement("-dp"); | |||
| } | |||
| if (classPath != null){ | |||
| if (classPath != null) { | |||
| options.addElement("-classpath"); | |||
| options.addElement(classPath.toString()); | |||
| } | |||
| if (sourcePath != null){ | |||
| if (sourcePath != null) { | |||
| options.addElement("-sourcepath"); | |||
| options.addElement(sourcePath.toString()); | |||
| } | |||
| @@ -294,17 +294,17 @@ public class MParse extends AbstractMetamataTask { | |||
| try { | |||
| fw = new FileWriter(tofile); | |||
| PrintWriter pw = new PrintWriter(fw); | |||
| for (int i = 0; i < options.length; i++){ | |||
| for (int i = 0; i < options.length; i++) { | |||
| pw.println(options[i]); | |||
| } | |||
| pw.flush(); | |||
| } catch (IOException e){ | |||
| } catch (IOException e) { | |||
| throw new BuildException("Error while writing options file " + tofile, e); | |||
| } finally { | |||
| if (fw != null){ | |||
| if (fw != null) { | |||
| try { | |||
| fw.close(); | |||
| } catch (IOException ignored){} | |||
| } catch (IOException ignored) {} | |||
| } | |||
| } | |||
| } | |||
| @@ -135,7 +135,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| try { | |||
| audioInputStream = AudioSystem.getAudioInputStream(file); | |||
| } catch (UnsupportedAudioFileException uafe) { | |||
| project.log("Audio format is not yet supported: " | |||
| project.log("Audio format is not yet supported: " | |||
| + uafe.getMessage()); | |||
| } catch (IOException ioe) { | |||
| ioe.printStackTrace(); | |||
| @@ -205,7 +205,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| /** | |||
| * Fired before any targets are started. | |||
| */ | |||
| public void buildStarted(BuildEvent event){ | |||
| public void buildStarted(BuildEvent event) { | |||
| } | |||
| /** | |||
| @@ -214,7 +214,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| * | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void buildFinished(BuildEvent event){ | |||
| public void buildFinished(BuildEvent event) { | |||
| if (event.getException() == null && fileSuccess != null) { | |||
| // build successfull! | |||
| play(event.getProject(), fileSuccess, loopsSuccess, durationSuccess); | |||
| @@ -228,7 +228,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| * | |||
| * @see BuildEvent#getTarget() | |||
| */ | |||
| public void targetStarted(BuildEvent event){ | |||
| public void targetStarted(BuildEvent event) { | |||
| } | |||
| /** | |||
| @@ -237,7 +237,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| * | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void targetFinished(BuildEvent event){ | |||
| public void targetFinished(BuildEvent event) { | |||
| } | |||
| /** | |||
| @@ -245,7 +245,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| * | |||
| * @see BuildEvent#getTask() | |||
| */ | |||
| public void taskStarted(BuildEvent event){ | |||
| public void taskStarted(BuildEvent event) { | |||
| } | |||
| /** | |||
| @@ -254,7 +254,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| * | |||
| * @see BuildEvent#getException() | |||
| */ | |||
| public void taskFinished(BuildEvent event){ | |||
| public void taskFinished(BuildEvent event) { | |||
| } | |||
| /** | |||
| @@ -263,7 +263,7 @@ public class AntSoundPlayer implements LineListener, BuildListener { | |||
| * @see BuildEvent#getMessage() | |||
| * @see BuildEvent#getPriority() | |||
| */ | |||
| public void messageLogged(BuildEvent event){ | |||
| public void messageLogged(BuildEvent event) { | |||
| } | |||
| } | |||
| @@ -105,7 +105,7 @@ public class SoundTask extends Task { | |||
| public SoundTask() { | |||
| } | |||
| public void init(){ | |||
| public void init() { | |||
| } | |||
| public void execute() { | |||
| @@ -82,13 +82,13 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| init(null); | |||
| setText(msg); | |||
| } | |||
| public SplashScreen(ImageIcon img) { | |||
| init(img); | |||
| } | |||
| protected void init(ImageIcon img) { | |||
| JPanel pan = (JPanel) getContentPane(); | |||
| JLabel piccy; | |||
| if (img == null) { | |||
| @@ -96,7 +96,7 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| } else { | |||
| piccy = new JLabel(img); | |||
| } | |||
| piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1)); | |||
| text = new JLabel("Building....", JLabel.CENTER); | |||
| text.setFont(new Font("Sans-Serif", Font.BOLD, 12)); | |||
| @@ -138,16 +138,16 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||
| pb.setValue(total); | |||
| } | |||
| public void buildStarted(BuildEvent event){ actionPerformed(null);} | |||
| public void buildFinished(BuildEvent event){ | |||
| public void buildStarted(BuildEvent event) { actionPerformed(null);} | |||
| public void buildFinished(BuildEvent event) { | |||
| pb.setValue(max); | |||
| setVisible(false); | |||
| dispose(); | |||
| } | |||
| public void targetStarted(BuildEvent event){actionPerformed(null);} | |||
| public void targetFinished(BuildEvent event){actionPerformed(null);} | |||
| public void taskStarted(BuildEvent event){actionPerformed(null);} | |||
| public void taskFinished(BuildEvent event){actionPerformed(null);} | |||
| public void messageLogged(BuildEvent event){actionPerformed(null);} | |||
| public void targetStarted(BuildEvent event) {actionPerformed(null);} | |||
| public void targetFinished(BuildEvent event) {actionPerformed(null);} | |||
| public void taskStarted(BuildEvent event) {actionPerformed(null);} | |||
| public void taskFinished(BuildEvent event) {actionPerformed(null);} | |||
| public void messageLogged(BuildEvent event) {actionPerformed(null);} | |||
| } | |||
| @@ -64,13 +64,13 @@ import javax.swing.ImageIcon; | |||
| import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| /** | |||
| * Creates a splash screen. The splash screen is displayed | |||
| * for the duration of the build and includes a handy progress bar as | |||
| * well. Use in conjunction with the sound task to provide interest | |||
| * whilst waiting for your builds to complete... | |||
| * @since Ant1.5 | |||
| * @since Ant1.5 | |||
| * @author Les Hughes (leslie.hughes@rubus.com) | |||
| */ | |||
| public class SplashTask extends Task { | |||
| @@ -92,10 +92,10 @@ public class SplashTask extends Task { | |||
| public void setImageURL(String imgurl) { | |||
| this.imgurl = imgurl; | |||
| } | |||
| /** | |||
| * flag to enable proxy settings; optional, deprecated : consider | |||
| * using <setproxy> instead | |||
| * using <setproxy> instead | |||
| * @deprecated use org.apache.tools.ant.taskdefs.optional.SetProxy | |||
| */ | |||
| public void setUseproxy(boolean useProxy) { | |||
| @@ -105,31 +105,31 @@ public class SplashTask extends Task { | |||
| /** | |||
| * name of proxy; optional. | |||
| */ | |||
| public void setProxy(String proxy){ | |||
| public void setProxy(String proxy) { | |||
| this.proxy = proxy; | |||
| } | |||
| /** | |||
| * Proxy port; optional, default 80. | |||
| * Proxy port; optional, default 80. | |||
| */ | |||
| public void setPort(String port){ | |||
| public void setPort(String port) { | |||
| this.port = port; | |||
| } | |||
| /** | |||
| * Proxy user; optional, default =none. | |||
| * Proxy user; optional, default =none. | |||
| */ | |||
| public void setUser(String user){ | |||
| public void setUser(String user) { | |||
| this.user = user; | |||
| } | |||
| /** | |||
| * Proxy password; required if <tt>user</tt> is set. | |||
| */ | |||
| public void setPassword(String password){ | |||
| public void setPassword(String password) { | |||
| this.password = password; | |||
| } | |||
| /** | |||
| * how long to show the splash screen in milliseconds, | |||
| * optional; default 5000 ms. | |||
| @@ -137,7 +137,7 @@ public class SplashTask extends Task { | |||
| public void setShowduration(int duration) { | |||
| this.showDuration = duration; | |||
| } | |||
| public void execute() throws BuildException { | |||
| if (splash != null) { | |||
| @@ -146,33 +146,33 @@ public class SplashTask extends Task { | |||
| splash.dispose(); | |||
| splash = null; | |||
| } | |||
| log("Creating new SplashScreen", Project.MSG_VERBOSE); | |||
| InputStream in = null; | |||
| if (imgurl != null) { | |||
| try { | |||
| URLConnection conn = null; | |||
| if (useProxy && | |||
| (proxy != null && proxy.length() > 0) && | |||
| (port != null && port.length() > 0)) { | |||
| log("Using proxied Connection", Project.MSG_DEBUG); | |||
| System.getProperties().put("http.proxySet", "true"); | |||
| System.getProperties().put("http.proxyHost", proxy); | |||
| System.getProperties().put("http.proxyPort", port); | |||
| URL url = new URL(imgurl); | |||
| conn = url.openConnection(); | |||
| if (user != null && user.length() > 0) { | |||
| String encodedcreds = | |||
| String encodedcreds = | |||
| new sun.misc.BASE64Encoder().encode((new String(user + ":" + password)).getBytes()); | |||
| conn.setRequestProperty("Proxy-Authorization", | |||
| conn.setRequestProperty("Proxy-Authorization", | |||
| encodedcreds); | |||
| } | |||
| } else { | |||
| System.getProperties().put("http.proxySet", "false"); | |||
| System.getProperties().put("http.proxyHost", ""); | |||
| @@ -183,16 +183,16 @@ public class SplashTask extends Task { | |||
| } | |||
| conn.setDoInput(true); | |||
| conn.setDoOutput(false); | |||
| in = conn.getInputStream(); | |||
| // Catch everything - some of the above return nulls, throw exceptions or generally misbehave | |||
| // in the event of a problem etc | |||
| } catch (Throwable ioe) { | |||
| log("Unable to download image, trying default Ant Logo", | |||
| log("Unable to download image, trying default Ant Logo", | |||
| Project.MSG_DEBUG); | |||
| log("(Exception was \"" + ioe.getMessage() + "\"", | |||
| log("(Exception was \"" + ioe.getMessage() + "\"", | |||
| Project.MSG_DEBUG); | |||
| } | |||
| } | |||
| @@ -210,10 +210,10 @@ public class SplashTask extends Task { | |||
| while ((data = din.read()) != -1) { | |||
| bout.write((byte) data); | |||
| } | |||
| log("Got ByteArray, creating splash", Project.MSG_DEBUG); | |||
| ImageIcon img = new ImageIcon(bout.toByteArray()); | |||
| splash = new SplashScreen(img); | |||
| success = true; | |||
| } catch (Exception e) { | |||
| @@ -240,6 +240,6 @@ public class SplashTask extends Task { | |||
| Thread.currentThread().sleep(showDuration); | |||
| } catch (InterruptedException e) { | |||
| } | |||
| } | |||
| } | |||
| @@ -256,7 +256,7 @@ public class Symlink extends Task { | |||
| linksToStore.put(alink.getName(), | |||
| alink.getCanonicalPath()); | |||
| } catch (IOException ioe) { | |||
| handleError("Couldn't get canonical " | |||
| handleError("Couldn't get canonical " | |||
| + "name of a parent link"); | |||
| } | |||
| } | |||
| @@ -541,7 +541,7 @@ public class Symlink extends Task { | |||
| return; | |||
| } | |||
| if (link == null) { | |||
| handleError("Must define the link " | |||
| handleError("Must define the link " | |||
| + "name for symlink!"); | |||
| return; | |||
| } | |||
| @@ -573,7 +573,7 @@ public class Symlink extends Task { | |||
| * Simultaneously get included directories and included files. | |||
| * | |||
| * @param ds The scanner with which to get the files and directories. | |||
| * @return A vector of <code>String</code> objects containing the | |||
| * @return A vector of <code>String</code> objects containing the | |||
| * included file names and directory names. | |||
| */ | |||
| @@ -772,7 +772,7 @@ public class Symlink extends Task { | |||
| // loop through the files identified by each file set | |||
| // and load their contents. | |||
| for (int j = 0; j < includedFiles.length; j++){ | |||
| for (int j = 0; j < includedFiles.length; j++) { | |||
| File inc = new File(workingDir + File.separator | |||
| + includedFiles[j]); | |||
| String inDir; | |||
| @@ -73,10 +73,7 @@ import org.apache.tools.ant.BuildException; | |||
| * The script is meant to use get self.token and | |||
| * set self.token in the reply. | |||
| */ | |||
| public class ScriptFilter | |||
| extends TokenFilter.ChainableReaderFilter | |||
| { | |||
| public class ScriptFilter extends TokenFilter.ChainableReaderFilter { | |||
| /** The language - attribute of element */ | |||
| private String language; | |||
| /** The script - inline text or external file */ | |||
| @@ -132,12 +129,14 @@ public class ScriptFilter | |||
| * @exception BuildException if someting goes wrong | |||
| */ | |||
| private void init() throws BuildException { | |||
| if (initialized) | |||
| if (initialized) { | |||
| return; | |||
| } | |||
| initialized = true; | |||
| if (language == null) | |||
| if (language == null) { | |||
| throw new BuildException( | |||
| "scriptfilter: language is not defined"); | |||
| } | |||
| try { | |||
| addBeans(getProject().getProperties()); | |||
| @@ -151,14 +150,13 @@ public class ScriptFilter | |||
| manager = new BSFManager (); | |||
| for (Enumeration e = beans.keys() ; e.hasMoreElements() ;) { | |||
| for (Enumeration e = beans.keys(); e.hasMoreElements();) { | |||
| String key = (String) e.nextElement(); | |||
| Object value = beans.get(key); | |||
| manager.declareBean(key, value, value.getClass()); | |||
| } | |||
| } | |||
| catch (BSFException e) { | |||
| } catch (BSFException e) { | |||
| Throwable t = e; | |||
| Throwable te = e.getTargetException(); | |||
| if (te != null) { | |||