From 0e1127c22ce00b23a65cbf90b3abf1cee81133ab Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Fri, 12 Apr 2002 14:46:45 +0000 Subject: [PATCH] Fix up style issues git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272409 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/IntrospectionHelper.java | 31 ++++-- .../tools/ant/taskdefs/AbstractCvsTask.java | 98 +++++++++---------- .../org/apache/tools/ant/taskdefs/Ant.java | 42 ++++---- .../tools/ant/taskdefs/AntStructure.java | 15 ++- .../apache/tools/ant/taskdefs/Available.java | 13 +-- .../apache/tools/ant/taskdefs/BUnzip2.java | 6 +- .../apache/tools/ant/taskdefs/CVSPass.java | 52 +++++----- .../apache/tools/ant/taskdefs/CallTarget.java | 2 +- .../apache/tools/ant/taskdefs/Checksum.java | 2 +- .../org/apache/tools/ant/taskdefs/Copy.java | 28 +++--- .../apache/tools/ant/taskdefs/Copydir.java | 4 +- .../apache/tools/ant/taskdefs/Definer.java | 56 +++++------ .../taskdefs/compilers/CompilerAdapter.java | 2 +- .../compilers/CompilerAdapterFactory.java | 30 +++--- .../compilers/DefaultCompilerAdapter.java | 10 +- .../tools/ant/taskdefs/compilers/Gcj.java | 4 +- .../tools/ant/taskdefs/compilers/Javac12.java | 2 +- .../tools/ant/taskdefs/compilers/Jikes.java | 2 +- .../tools/ant/taskdefs/compilers/Jvc.java | 2 +- .../tools/ant/taskdefs/compilers/Kjc.java | 2 +- 20 files changed, 213 insertions(+), 190 deletions(-) diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index 581889a0a..971ff79cb 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -212,14 +212,7 @@ public class IntrospectionHelper implements BuildListener { // not really user settable properties on tasks if (org.apache.tools.ant.Task.class.isAssignableFrom(bean) - && args.length == 1 && - ( - ( - "setLocation".equals(name) && org.apache.tools.ant.Location.class.equals(args[0]) - ) || ( - "setTaskType".equals(name) && java.lang.String.class.equals(args[0]) - ) - )) { + && args.length == 1 && isHiddenSetMethod(name, args[0])) { continue; } @@ -353,6 +346,28 @@ public class IntrospectionHelper implements BuildListener { } } + /** + * Certain set methods are part of the Ant core interface to tasks and + * therefore not to be considered for introspection + * + * @param name the name of the set method + * @param type the type of the set method's parameter + * @return true if the given set method is to be hidden. + */ + private boolean isHiddenSetMethod(String name, Class type) { + if ("setLocation".equals(name) + && org.apache.tools.ant.Location.class.equals(type)) { + return true; + } + + if ("setTaskType".equals(name) + && java.lang.String.class.equals(type)) { + return true; + } + + return false; + } + /** * Returns a helper for the given class, either from the cache * or by creating a new instance. diff --git a/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java b/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java index f660798eb..f6055aa33 100644 --- a/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/AbstractCvsTask.java @@ -186,8 +186,7 @@ public abstract class AbstractCvsTask extends Task { protected ExecuteStreamHandler getExecuteStreamHandler(){ - if(this.executeStreamHandler == null){ - + if (this.executeStreamHandler == null) { setExecuteStreamHandler(new PumpStreamHandler(getOutputStream(), getErrorStream())); } @@ -203,7 +202,7 @@ public abstract class AbstractCvsTask extends Task { protected OutputStream getOutputStream(){ - if(this.outputStream == null){ + if (this.outputStream == null) { if (output != null) { try { @@ -230,7 +229,7 @@ public abstract class AbstractCvsTask extends Task { protected OutputStream getErrorStream(){ - if(this.errorStream == null){ + if (this.errorStream == null) { if (error != null) { @@ -254,7 +253,7 @@ public abstract class AbstractCvsTask extends Task { * Sets up the environment for toExecute and then runs it. * @throws BuildException */ - protected void runCommand( Commandline toExecute ) throws BuildException { + protected void runCommand(Commandline toExecute) throws BuildException { // XXX: we should use JCVS (www.ice.com/JCVS) instead of // command line execution so that we don't rely on having // native CVS stuff around (SM) @@ -264,7 +263,7 @@ public abstract class AbstractCvsTask extends Task { Environment env = new Environment(); - if (port>0) { + if (port > 0) { Environment.Variable var = new Environment.Variable(); var.setKey("CVS_CLIENT_PORT"); var.setValue(String.valueOf(port)); @@ -286,7 +285,7 @@ public abstract class AbstractCvsTask extends Task { } */ - if (passFile!=null) { + if (passFile != null) { Environment.Variable var = new Environment.Variable(); var.setKey("CVS_PASSFILE"); var.setValue(String.valueOf(passFile)); @@ -295,7 +294,7 @@ public abstract class AbstractCvsTask extends Task { Project.MSG_INFO); } - if (cvsRsh!=null) { + if (cvsRsh != null) { Environment.Variable var = new Environment.Variable(); var.setKey("CVS_RSH"); var.setValue(String.valueOf(cvsRsh)); @@ -322,42 +321,42 @@ public abstract class AbstractCvsTask extends Task { log("running cvs command: " + actualCommandLine, Project.MSG_DEBUG); int retCode = exe.execute(); - log( "retCode="+retCode, Project.MSG_DEBUG ); + log("retCode=" + retCode, Project.MSG_DEBUG); /*Throw an exception if cvs exited with error. (Iulian)*/ - if(failOnError && retCode != 0) { + if (failOnError && retCode != 0) { throw new BuildException("cvs exited with error code " + retCode + StringUtils.LINE_SEP + "Command line was [" - + actualCommandLine + "]", location ); + + actualCommandLine + "]", location); } } catch (IOException e) { - if( failOnError ) { + if (failOnError) { throw new BuildException(e, location); } else { - log("Caught exception: "+e.getMessage(), Project.MSG_WARN); + log("Caught exception: " + e.getMessage(), Project.MSG_WARN); } } catch (BuildException e) { - if( failOnError ) { - throw( e ); + if (failOnError) { + throw(e); } else { Throwable t = e.getException(); if (t == null) { t = e; } - log("Caught exception: "+t.getMessage(), Project.MSG_WARN); + log("Caught exception: " + t.getMessage(), Project.MSG_WARN); } } catch (Exception e) { - if( failOnError ) { + if (failOnError) { throw new BuildException(e, location); } else { - log("Caught exception: "+e.getMessage(), Project.MSG_WARN); + log("Caught exception: " + e.getMessage(), Project.MSG_WARN); } } finally { @@ -382,23 +381,22 @@ public abstract class AbstractCvsTask extends Task { String savedCommand = getCommand(); - if( this.getCommand() == null - && vecCommandlines.size() == 0 ) { + if (this.getCommand() == null && vecCommandlines.size() == 0) { // re-implement legacy behaviour: - this.setCommand( AbstractCvsTask.default_command ); + this.setCommand(AbstractCvsTask.default_command); } String c = this.getCommand(); Commandline cloned = null; - if( c != null ) { + if (c != null) { cloned = (Commandline) cmd.clone(); cloned.createArgument(true).setLine(c); this.addConfiguredCommandline(cloned, true); } try { - for( int i = 0; i < vecCommandlines.size(); i++ ) { - this.runCommand( (Commandline)vecCommandlines.elementAt( i ) ); + for (int i = 0; i < vecCommandlines.size(); i++) { + this.runCommand((Commandline) vecCommandlines.elementAt(i)); } } finally { if (cloned != null) { @@ -412,7 +410,7 @@ public abstract class AbstractCvsTask extends Task { StringBuffer stringBuffer = new StringBuffer(250); String[] commandLine = execute.getCommandline(); - for(int i=0; i 0) { + if (p != null && p.trim().length() > 0) { addCommandArgument("-D"); addCommandArgument(p); } @@ -567,16 +565,16 @@ public abstract class AbstractCvsTask extends Task { /** * Configure a commandline element for things like cvsRoot, quiet, etc. */ - protected void configureCommandline( Commandline c ) { - if( c == null ) { + protected void configureCommandline(Commandline c) { + if (c == null) { return; } - c.setExecutable( "cvs" ); + c.setExecutable("cvs"); if (cvsPackage != null) { c.createArgument().setLine(cvsPackage); } - if ( this.compression > 0 && this.compression < 10 ) { - c.createArgument(true).setValue("-z"+this.compression); + if (this.compression > 0 && this.compression < 10) { + c.createArgument(true).setValue("-z" + this.compression); } if (quiet) { c.createArgument(true).setValue("-q"); @@ -585,31 +583,33 @@ public abstract class AbstractCvsTask extends Task { c.createArgument(true).setValue("-n"); } if (cvsRoot != null) { - c.createArgument(true).setLine("-d"+cvsRoot); + c.createArgument(true).setLine("-d" + cvsRoot); } } protected void removeCommandline(Commandline c) { - vecCommandlines.removeElement( c ); + vecCommandlines.removeElement(c); } - public void addConfiguredCommandline( Commandline c ) { - this.addConfiguredCommandline( c, false ); + public void addConfiguredCommandline(Commandline c) { + this.addConfiguredCommandline(c, false); } /** * Configures and adds the given Commandline. * @param insertAtStart If true, c is */ - public void addConfiguredCommandline( Commandline c, - boolean insertAtStart ) { - if( c == null ) { return; } - this.configureCommandline( c ); - if( insertAtStart ) { - vecCommandlines.insertElementAt( c, 0 ); + public void addConfiguredCommandline(Commandline c, + boolean insertAtStart) { + if (c == null) { + return; + } + this.configureCommandline(c); + if (insertAtStart) { + vecCommandlines.insertElementAt(c, 0); } else { - vecCommandlines.addElement( c ); + vecCommandlines.addElement(c); } } @@ -617,7 +617,7 @@ public abstract class AbstractCvsTask extends Task { * If set to a value 1-9 it adds -zN to the cvs command line, else * it disables compression. */ - public void setCompressionLevel( int level ) { + public void setCompressionLevel(int level) { this.compression = level; } @@ -625,9 +625,9 @@ public abstract class AbstractCvsTask extends Task { * @param usecomp If true, turns on compression using default * level, AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL. */ - public void setCompression( boolean usecomp ) { - setCompressionLevel( usecomp ? - AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL : 0 ); + public void setCompression(boolean usecomp) { + setCompressionLevel(usecomp ? + AbstractCvsTask.DEFAULT_COMPRESSION_LEVEL : 0); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index b2ed56f61..b950a0432 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -199,7 +199,7 @@ public class Ant extends Task { Vector listeners = project.getBuildListeners(); final int count = listeners.size(); for (int i = 0; i < count; i++) { - newProject.addBuildListener((BuildListener)listeners.elementAt(i)); + newProject.addBuildListener((BuildListener) listeners.elementAt(i)); } if (output != null) { @@ -217,8 +217,8 @@ public class Ant extends Task { logger.setErrorPrintStream(out); newProject.addBuildListener(logger); } - catch( IOException ex ) { - log( "Ant: Can't set output to " + output ); + catch (IOException ex) { + log("Ant: Can't set output to " + output); } } @@ -309,7 +309,7 @@ public class Ant extends Task { reinit(); } - if ( (dir == null) && (inheritAll) ) { + if ((dir == null) && (inheritAll)) { dir = project.getBaseDir(); } @@ -331,10 +331,10 @@ public class Ant extends Task { File file = FileUtils.newFileUtils().resolveFile(dir, antFile); antFile = file.getAbsolutePath(); - log("calling target "+(target!=null?target:"[default]") - + " in build file "+ antFile.toString(), + log("calling target " + (target != null ? target : "[default]") + + " in build file " + antFile.toString(), Project.MSG_VERBOSE); - newProject.setUserProperty( "ant.file" , antFile ); + newProject.setUserProperty("ant.file" , antFile); ProjectHelper.configureProject(newProject, new File(antFile)); if (target == null) { @@ -393,8 +393,8 @@ public class Ant extends Task { Hashtable newReferences = newProject.getReferences(); Enumeration e; if (references.size() > 0) { - for(e = references.elements(); e.hasMoreElements();) { - Reference ref = (Reference)e.nextElement(); + for (e = references.elements(); e.hasMoreElements();) { + Reference ref = (Reference) e.nextElement(); String refid = ref.getRefId(); if (refid == null) { throw new BuildException("the refid attribute is required" @@ -419,8 +419,8 @@ public class Ant extends Task { // Now add all references that are not defined in the // subproject, if inheritRefs is true if (inheritRefs) { - for(e = thisReferences.keys(); e.hasMoreElements();) { - String key = (String)e.nextElement(); + for (e = thisReferences.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); if (newReferences.containsKey(key)) { continue; } @@ -456,14 +456,14 @@ public class Ant extends Task { } else { try { Method setProjectM = - c.getMethod( "setProject", new Class[] {Project.class}); - if(setProjectM != null) { + c.getMethod("setProject", new Class[] {Project.class}); + if (setProjectM != null) { setProjectM.invoke(copy, new Object[] {newProject}); } } catch (NoSuchMethodException e) { // ignore this if the class being referenced does not have // a set project method. - } catch(Exception e2) { + } catch (Exception e2) { String msg = "Error setting new project instance for " + "reference with id " + oldKey; throw new BuildException(msg, e2, location); @@ -516,7 +516,7 @@ public class Ant extends Task { Property p = new Property(true); p.setProject(newProject); p.setTaskName("property"); - properties.addElement( p ); + properties.addElement(p); return p; } @@ -537,8 +537,14 @@ public class Ant extends Task { public Reference() {super();} - private String targetid=null; - public void setToRefid(String targetid) { this.targetid=targetid; } - public String getToRefid() { return targetid; } + private String targetid = null; + + public void setToRefid(String targetid) { + this.targetid = targetid; + } + + public String getToRefid() { + return targetid; + } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java index 1e36fab0d..1bf8af185 100644 --- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java +++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java @@ -145,8 +145,8 @@ public class AntStructure extends Task { printTail(out); } catch (IOException ioe) { - throw new BuildException("Error writing "+output.getAbsolutePath(), - ioe, location); + throw new BuildException("Error writing " + + output.getAbsolutePath(), ioe, location); } finally { if (out != null) { out.close(); @@ -314,7 +314,7 @@ public class AntStructure extends Task { } else if (org.apache.tools.ant.types.EnumeratedAttribute.class.isAssignableFrom(type)) { try { EnumeratedAttribute ea = - (EnumeratedAttribute)type.newInstance(); + (EnumeratedAttribute) type.newInstance(); String[] values = ea.getValues(); if (values == null || values.length == 0 @@ -322,7 +322,7 @@ public class AntStructure extends Task { sb.append("CDATA "); } else { sb.append("("); - for (int i=0; i < values.length; i++) { + for (int i = 0; i < values.length; i++) { if (i != 0) { sb.append(" | "); } @@ -346,10 +346,9 @@ public class AntStructure extends Task { final int count = v.size(); for (int i = 0; i < count; i++) { String nestedName = (String) v.elementAt(i); - if (!"#PCDATA".equals(nestedName) && - !TASKS.equals(nestedName) && - !TYPES.equals(nestedName) - ) { + if (!"#PCDATA".equals(nestedName) + && !TASKS.equals(nestedName) + && !TYPES.equals(nestedName)) { printElementDecl(out, nestedName, ih.getElementType(nestedName)); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java index 27efcb000..8c042db83 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -264,7 +264,7 @@ public class Available extends Task implements Condition { return checkFile(project.resolveFile(file), file); } else { String[] paths = filepath.list(); - for(int i = 0; i < paths.length; ++i) { + for (int i = 0; i < paths.length; ++i) { log("Searching " + paths[i], Project.MSG_DEBUG); File path = new File(paths[i]); @@ -340,12 +340,12 @@ public class Available extends Task implements Condition { private boolean checkFile(File f, String text) { if (type != null) { if (type.isDir()) { - if( f.isDirectory()) { + if (f.isDirectory()) { log("Found directory: " + text, Project.MSG_VERBOSE); } return f.isDirectory(); } else if (type.isFile()) { - if( f.isFile()) { + if (f.isFile()) { log("Found file: " + text, Project.MSG_VERBOSE); } return f.isFile(); @@ -380,12 +380,13 @@ public class Available extends Task implements Condition { private boolean checkClass(String classname) { try { Class requiredClass = null; - if( ignoreSystemclasses ) { - loader = new AntClassLoader(null,getProject(),classpath,false); + if (ignoreSystemclasses) { + loader = new AntClassLoader(null, getProject(), + classpath, false); if (loader != null) { try { loader.findClass(classname); - } catch( SecurityException se ) { + } catch (SecurityException se) { // class found but restricted name; this is actually // the case we're looking for, so catch the exception // and return diff --git a/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java b/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java index 2eaa47dfb..104bb1970 100644 --- a/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java +++ b/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java @@ -84,7 +84,7 @@ public class BUnzip2 extends Unpack { protected void extract() { if (source.lastModified() > dest.lastModified()) { - log("Expanding "+ source.getAbsolutePath() + " to " + log("Expanding " + source.getAbsolutePath() + " to " + dest.getAbsolutePath()); FileOutputStream out = null; @@ -96,11 +96,11 @@ public class BUnzip2 extends Unpack { fis = new FileInputStream(source); bis = new BufferedInputStream(fis); int b = bis.read(); - if(b != 'B') { + if (b != 'B') { throw new BuildException("Invalid bz2 file.", location); } b = bis.read(); - if(b != 'Z') { + if (b != 'Z') { throw new BuildException("Invalid bz2 file.", location); } zIn = new CBZip2InputStream(bis); diff --git a/src/main/org/apache/tools/ant/taskdefs/CVSPass.java b/src/main/org/apache/tools/ant/taskdefs/CVSPass.java index 3cdd32c67..efba52bd2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/CVSPass.java +++ b/src/main/org/apache/tools/ant/taskdefs/CVSPass.java @@ -88,26 +88,26 @@ public class CVSPass extends Task { /** Array contain char conversion data */ private final char[] shifts = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87, - 111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105, - 41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35, - 125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56, - 36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48, - 58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223, - 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190, - 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193, - 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212, - 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246, - 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176, - 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127, - 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195, - 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 114, 120, 53, 79, 96, 109, 72, 108, 70, 64, 76, 67, 116, 74, 68, 87, + 111, 52, 75, 119, 49, 34, 82, 81, 95, 65, 112, 86, 118, 110, 122, 105, + 41, 57, 83, 43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123, 91, 35, + 125, 55, 54, 66, 124, 126, 59, 47, 92, 71, 115, 78, 88, 107, 106, 56, + 36, 121, 117, 104, 101, 100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48, + 58, 113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85, 223, + 225, 216, 187, 166, 229, 189, 222, 188, 141, 249, 148, 200, 184, 136, 248, 190, + 199, 170, 181, 204, 138, 232, 218, 183, 255, 234, 220, 247, 213, 203, 226, 193, + 174, 172, 228, 252, 217, 201, 131, 230, 197, 211, 145, 238, 161, 179, 160, 212, + 207, 221, 254, 173, 202, 146, 224, 151, 140, 196, 205, 130, 135, 133, 143, 246, + 192, 159, 244, 239, 185, 168, 215, 144, 139, 165, 180, 157, 147, 186, 214, 176, + 227, 231, 219, 169, 175, 156, 206, 198, 129, 164, 150, 210, 154, 177, 134, 127, + 182, 128, 158, 208, 162, 132, 167, 209, 149, 241, 153, 251, 237, 236, 171, 195, + 243, 233, 253, 240, 194, 250, 191, 155, 142, 137, 245, 235, 163, 242, 178, 152 }; public CVSPass(){ - passFile = new File(System.getProperty("user.home")+"/.cvspass"); + passFile = new File(System.getProperty("user.home") + "/.cvspass"); } /** @@ -116,10 +116,10 @@ public class CVSPass extends Task { * @exception BuildException if someting goes wrong with the build */ public final void execute() throws BuildException { - if(cvsRoot==null) { + if (cvsRoot == null) { throw new BuildException("cvsroot is required"); } - if(password==null) { + if (password == null) { throw new BuildException("password is required"); } @@ -129,16 +129,16 @@ public class CVSPass extends Task { BufferedReader reader = null; PrintWriter writer = null; - try{ + try { StringBuffer buf = new StringBuffer(); - if(passFile.exists()){ + if (passFile.exists()) { reader = new BufferedReader(new FileReader(passFile)); String line = null; - while((line=reader.readLine())!=null){ - if(!line.startsWith(cvsRoot)){ + while ((line = reader.readLine()) != null) { + if (!line.startsWith(cvsRoot)) { buf.append(line).append(StringUtils.LINE_SEP); } } @@ -151,8 +151,8 @@ public class CVSPass extends Task { writer = new PrintWriter(new FileWriter(passFile)); - writer.println( pwdfile ); - }catch(IOException e){ + writer.println(pwdfile); + } catch (IOException e) { throw new BuildException(e); } finally { if (reader != null) { @@ -168,7 +168,7 @@ public class CVSPass extends Task { private final String mangle(String password){ StringBuffer buf = new StringBuffer(); - for(int i=0;i 0) { - log("Copying " + fileCopyMap.size() + - " file" + (fileCopyMap.size() == 1 ? "" : "s") + - " to " + destDir.getAbsolutePath() ); + log("Copying " + fileCopyMap.size() + + " file" + (fileCopyMap.size() == 1 ? "" : "s") + + " to " + destDir.getAbsolutePath()); Enumeration e = fileCopyMap.keys(); while (e.hasMoreElements()) { String fromFile = (String) e.nextElement(); String toFile = (String) fileCopyMap.get(fromFile); - if( fromFile.equals( toFile ) ) { + if (fromFile.equals(toFile)) { log("Skipping self-copy of " + fromFile, verbosity); continue; } @@ -516,7 +518,7 @@ public class Copy extends Task { for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) { executionFilters - .addFilterSet((FilterSet)filterEnum.nextElement()); + .addFilterSet((FilterSet) filterEnum.nextElement()); } fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains, forceOverwrite, @@ -534,7 +536,7 @@ public class Copy extends Task { Enumeration e = dirCopyMap.elements(); int count = 0; while (e.hasMoreElements()) { - File d = new File((String)e.nextElement()); + File d = new File((String) e.nextElement()); if (!d.exists()) { if (!d.mkdirs()) { log("Unable to create directory " @@ -548,7 +550,7 @@ public class Copy extends Task { if (count > 0) { log("Copied " + count + " empty director" + - (count==1?"y":"ies") + + (count == 1 ? "y" : "ies") + " to " + destDir.getAbsolutePath()); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Copydir.java b/src/main/org/apache/tools/ant/taskdefs/Copydir.java index 2f920816b..bd1ec4350 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copydir.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copydir.java @@ -110,8 +110,8 @@ public class Copydir extends MatchingTask { } if (!srcDir.exists()) { - throw new BuildException("srcdir "+srcDir.toString() - +" does not exist!", location); + throw new BuildException("srcdir " + srcDir.toString() + + " does not exist!", location); } if (destDir == null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Definer.java b/src/main/org/apache/tools/ant/taskdefs/Definer.java index f1d5f35f3..1b29b011c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Definer.java +++ b/src/main/org/apache/tools/ant/taskdefs/Definer.java @@ -111,22 +111,22 @@ public abstract class Definer extends Task { } public void execute() throws BuildException { - AntClassLoader al=createLoader(); + AntClassLoader al = createLoader(); - if (file==null && resource==null ) { + if (file == null && resource == null) { // simple case - one definition - if ( name==null || value==null ) { + if (name == null || value == null) { String msg = "name or classname attributes of " + getTaskName() + " element " + "are undefined"; throw new BuildException(msg); } - addDefinition( al, name, value ); + addDefinition(al, name, value); } else { - InputStream is=null; + InputStream is = null; try { if (name != null || value != null) { String msg = "You must not specify name or value " @@ -141,20 +141,20 @@ public abstract class Definer extends Task { } - Properties props=new Properties(); - if( file != null ) { + Properties props = new Properties(); + if (file != null) { log("Loading definitions from file " + file, Project.MSG_VERBOSE); - is=new FileInputStream( file ); + is = new FileInputStream(file); if (is == null) { log("Could not load definitions from file " + file + ". It doesn\'t exist.", Project.MSG_WARN); } } - if( resource!=null ) { + if (resource != null) { log("Loading definitions from resource " + resource, Project.MSG_VERBOSE); - is=al.getResourceAsStream( resource ); + is = al.getResourceAsStream(resource); if (is == null) { log("Could not load definitions from resource " + resource + ". It could not be found.", @@ -162,16 +162,16 @@ public abstract class Definer extends Task { } } - if( is!=null ) { - props.load( is ); - Enumeration keys=props.keys(); - while( keys.hasMoreElements() ) { - String n=(String)keys.nextElement(); - String v=props.getProperty( n ); - addDefinition( al, n, v ); + if (is != null) { + props.load(is); + Enumeration keys = props.keys(); + while (keys.hasMoreElements()) { + String n = (String) keys.nextElement(); + String v = props.getProperty(n); + addDefinition(al, n, v); } } - } catch( IOException ex ) { + } catch (IOException ex) { throw new BuildException(ex, location); } finally { if (is != null) { @@ -183,19 +183,19 @@ public abstract class Definer extends Task { } } - private void addDefinition( ClassLoader al, String name, String value ) + private void addDefinition(ClassLoader al, String name, String value) throws BuildException { try { Class c = al.loadClass(value); AntClassLoader.initializeClass(c); addDefinition(name, c); } catch (ClassNotFoundException cnfe) { - String msg = getTaskName()+" class " + value + - " cannot be found"; + String msg = getTaskName() + " class " + value + + " cannot be found"; throw new BuildException(msg, cnfe, location); } catch (NoClassDefFoundError ncdfe) { - String msg = getTaskName()+" class " + value + - " cannot be found"; + String msg = getTaskName() + " class " + value + + " cannot be found"; throw new BuildException(msg, ncdfe, location); } } @@ -216,15 +216,15 @@ public abstract class Definer extends Task { return al; } - public void setFile( File file ) { - this.file=file; + public void setFile(File file) { + this.file = file; } - public void setResource( String res ) { - this.resource=res; + public void setResource(String res) { + this.resource = res; } - public void setName( String name) { + public void setName(String name) { this.name = name; } diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java index 4f1466580..05e0d0944 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java @@ -76,7 +76,7 @@ public interface CompilerAdapter { /** * Sets the compiler attributes, which are stored in the Javac task. */ - void setJavac( Javac attributes ); + void setJavac(Javac attributes); /** * Executes the task. diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java index 560ae25b7..a84a26c97 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java @@ -92,23 +92,23 @@ public class CompilerAdapterFactory { * @throws BuildException if the compiler type could not be resolved into * a compiler adapter. */ - public static CompilerAdapter getCompiler( String compilerType, Task task ) + public static CompilerAdapter getCompiler(String compilerType, Task task) throws BuildException { /* If I've done things right, this should be the extent of the * conditional statements required. */ - if ( compilerType.equalsIgnoreCase("jikes") ) { + if (compilerType.equalsIgnoreCase("jikes")) { return new Jikes(); } - if ( compilerType.equalsIgnoreCase("extJavac") ) { + if (compilerType.equalsIgnoreCase("extJavac")) { return new JavacExternal(); } - if ( compilerType.equalsIgnoreCase("classic") || + if (compilerType.equalsIgnoreCase("classic") || compilerType.equalsIgnoreCase("javac1.1") || compilerType.equalsIgnoreCase("javac1.2")) { return new Javac12(); } - if ( compilerType.equalsIgnoreCase("modern") || + if (compilerType.equalsIgnoreCase("modern") || compilerType.equalsIgnoreCase("javac1.3") || compilerType.equalsIgnoreCase("javac1.4")) { // does the modern compiler exist? @@ -121,21 +121,21 @@ public class CompilerAdapterFactory { } return new Javac13(); } - if ( compilerType.equalsIgnoreCase("jvc") || + if (compilerType.equalsIgnoreCase("jvc") || compilerType.equalsIgnoreCase("microsoft")) { return new Jvc(); } - if ( compilerType.equalsIgnoreCase("kjc") ) { + if (compilerType.equalsIgnoreCase("kjc")) { return new Kjc(); } - if ( compilerType.equalsIgnoreCase("gcj") ) { + if (compilerType.equalsIgnoreCase("gcj")) { return new Gcj(); } if (compilerType.equalsIgnoreCase("sj") || compilerType.equalsIgnoreCase("symantec")) { return new Sj(); } - return resolveClassName( compilerType ); + return resolveClassName(compilerType); } /** @@ -146,18 +146,18 @@ public class CompilerAdapterFactory { * @throws BuildException This is the fit that is thrown if className * isn't an instance of CompilerAdapter. */ - private static CompilerAdapter resolveClassName( String className ) + private static CompilerAdapter resolveClassName(String className) throws BuildException { try { - Class c = Class.forName( className ); + Class c = Class.forName(className); Object o = c.newInstance(); return (CompilerAdapter) o; - } catch ( ClassNotFoundException cnfe ) { - throw new BuildException( className + " can\'t be found.", cnfe ); - } catch ( ClassCastException cce ) { + } catch (ClassNotFoundException cnfe) { + throw new BuildException(className + " can\'t be found.", cnfe); + } catch (ClassCastException cce) { throw new BuildException(className + " isn\'t the classname of " + "a compiler adapter.", cce); - } catch ( Throwable t ) { + } catch (Throwable t) { // for all other possibilities throw new BuildException(className + " caused an interesting " + "exception.", t); diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index 99ece8899..425b28bcd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -113,7 +113,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { private FileUtils fileUtils = FileUtils.newFileUtils(); - public void setJavac( Javac attributes ) { + public void setJavac(Javac attributes) { this.attributes = attributes; src = attributes.getSrcdir(); destDir = attributes.getDestdir(); @@ -159,11 +159,11 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { // order determined by the value of build.classpath if (compileClasspath == null) { - if ( includeAntRuntime ) { + if (includeAntRuntime) { classpath.addExisting(Path.systemClasspath); } } else { - if ( includeAntRuntime ) { + if (includeAntRuntime) { classpath.addExisting(compileClasspath .concatSystemClasspath("last")); } else { @@ -381,7 +381,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { niceSourceList.append(lSep); - for (int i=0; i < compileList.length; i++) { + for (int i = 0; i < compileList.length; i++) { String arg = compileList[i].getAbsolutePath(); cmd.createArgument().setValue(arg); niceSourceList.append(" " + arg + lSep); @@ -418,7 +418,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { out.println(args[i]); } out.flush(); - commandArray = new String[firstFileName+1]; + commandArray = new String[firstFileName + 1]; System.arraycopy(args, 0, commandArray, 0, firstFileName); commandArray[firstFileName] = "@" + tmpFile; } catch (IOException e) { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java index 4a8040cf9..98246c327 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java @@ -98,7 +98,7 @@ public class Gcj extends DefaultCompilerAdapter { // so we'll emulate it for compatibility and convenience. classpath.addExtdirs(extdirs); - if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) { + if (bootclasspath == null || bootclasspath.size() == 0) { // no bootclasspath, therefore, get one from the java runtime includeJavaRuntime = true; } @@ -114,7 +114,7 @@ public class Gcj extends DefaultCompilerAdapter { cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(destDir); - if(destDir.mkdirs()){ + if (destDir.mkdirs()) { throw new BuildException("Can't make output directories. " + "Maybe permission is wrong. "); }; diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java index 218ba6652..285687b03 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java @@ -97,7 +97,7 @@ public class Javac12 extends DefaultCompilerAdapter { Method compile = c.getMethod("compile", new Class [] { String[].class }); Boolean ok = - (Boolean)compile.invoke(compiler, + (Boolean) compile.invoke(compiler, new Object[] {cmd.getArguments()}); return ok.booleanValue(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java index 1786e0847..921324c6e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java @@ -97,7 +97,7 @@ public class Jikes extends DefaultCompilerAdapter { // so we'll emulate it for compatibility and convenience. classpath.addExtdirs(extdirs); - if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) { + if (bootclasspath == null || bootclasspath.size() == 0) { // no bootclasspath, therefore, get one from the java runtime includeJavaRuntime = true; } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java index 6c4824bc6..0c6fa8ca9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java @@ -87,7 +87,7 @@ public class Jvc extends DefaultCompilerAdapter { // so we'll emulate it for compatibility and convenience. classpath.addExtdirs(extdirs); - if ( (bootclasspath == null) || (bootclasspath.size() == 0) ) { + if (bootclasspath == null || bootclasspath.size() == 0) { // no bootclasspath, therefore, get one from the java runtime includeJavaRuntime = true; } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java index c3ef6db11..9e716a718 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java @@ -85,7 +85,7 @@ public class Kjc extends DefaultCompilerAdapter { Method compile = c.getMethod("compile", new Class [] { String [].class }); Boolean ok = - (Boolean)compile.invoke(null, + (Boolean) compile.invoke(null, new Object[] {cmd.getArguments()}); return ok.booleanValue(); }