diff --git a/src/etc/checkstyle/checkstyle-config b/src/etc/checkstyle/checkstyle-config index f443646f6..7bed0d4b5 100644 --- a/src/etc/checkstyle/checkstyle-config +++ b/src/etc/checkstyle/checkstyle-config @@ -35,7 +35,7 @@ - + diff --git a/src/etc/checkstyle/checkstyle-frames.xsl b/src/etc/checkstyle/checkstyle-frames.xsl index 4d6822e65..527490381 100644 --- a/src/etc/checkstyle/checkstyle-frames.xsl +++ b/src/etc/checkstyle/checkstyle-frames.xsl @@ -100,7 +100,7 @@ <h2>Frame Alert</h2> <p> - This document is designed to be viewed using the frames feature. + This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. </p> @@ -113,8 +113,8 @@

CheckStyle Audit

- Designed for use with - CheckStyle and + Designed for use with + CheckStyle and Ant. @@ -152,10 +152,10 @@ background-color:#FFFFFF; color:#000000; } - .a td { + .oddrow td { background: #efefef; } - .b td { + .evenrow td { background: #fff; } th, td { @@ -305,14 +305,17 @@

Summary

+ - + + +
FilesTotal FilesFiles With Errors Errors
@@ -320,8 +323,8 @@ - a - b + oddrow + evenrow diff --git a/src/etc/checkstyle/checkstyle-xdoc.xsl b/src/etc/checkstyle/checkstyle-xdoc.xsl index 4b7e26f24..691ba9a1c 100644 --- a/src/etc/checkstyle/checkstyle-xdoc.xsl +++ b/src/etc/checkstyle/checkstyle-xdoc.xsl @@ -91,7 +91,7 @@ - + @@ -139,14 +139,17 @@
+ + +
FilesFiles With Errors Errors
diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index d1a19d2ee..59b6e9916 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -63,12 +63,12 @@ import java.util.Enumeration; - ns param. It could be used to provide "namespaces" for properties, which may be more flexible. - Object value. In ant1.5 String is used for Properties - but it would be nice - to support generic Objects ( the property remains imutable - you can't change - the associated object ). This will also allow JSP-EL style setting using the - Object if an attribute contains only the property ( name="${property}" could - avoid Object->String->Object conversion ) - - Currently we "chain" only for get and set property ( probably most users - will only need that - if they need more they can replace the top helper ). + to support generic Objects (the property remains imutable - you can't change + the associated object). This will also allow JSP-EL style setting using the + Object if an attribute contains only the property (name="${property}" could + avoid Object->String->Object conversion) + - Currently we "chain" only for get and set property (probably most users + will only need that - if they need more they can replace the top helper). Need to discuss this and find if we need more. */ @@ -84,66 +84,89 @@ import java.util.Enumeration; */ public class PropertyHelper { - protected Project project; - protected PropertyHelper next; + private Project project; + private PropertyHelper next; /** Project properties map (usually String to String). */ - protected Hashtable properties = new Hashtable(); + private Hashtable properties = new Hashtable(); + /** * Map of "user" properties (as created in the Ant task, for example). * Note that these key/value pairs are also always put into the * project properties, so only the project properties need to be queried. * Mapping is String to String. */ - protected Hashtable userProperties = new Hashtable(); + private Hashtable userProperties = new Hashtable(); + /** * Map of inherited "user" properties - that are those "user" * properties that have been created by tasks and not been set * from the command line or a GUI tool. * Mapping is String to String. */ - protected Hashtable inheritedProperties = new Hashtable(); + private Hashtable inheritedProperties = new Hashtable(); + /** + * Default constructor. + */ protected PropertyHelper() { } // -------------------- Hook management -------------------- - public void setProject(Project p ) { - this.project=p; + /** + * Set the project for which this helper is performing property resolution + * + * @param p the projetc instance. + */ + public void setProject(Project p) { + this.project = p; } /** There are 2 ways to hook into property handling: * - you can replace the main PropertyHelper. The replacement is required - * to support the same semantics ( of course :-) + * to support the same semantics (of course :-) * * - you can chain a property helper capable of storing some properties. - * Again, you are required to respect the immutability semantics ( at - * least for non-dynamic properties ) + * Again, you are required to respect the immutability semantics (at + * least for non-dynamic properties) * - * @param next + * @param next the next property helper in the chain. */ - public void setNext( PropertyHelper next ) { - this.next=next; + public void setNext(PropertyHelper next) { + this.next = next; } + /** + * Get the next property helper in the chain. + * + * @return the next proprty helper. + */ public PropertyHelper getNext() { return next; } - /** Factory method to create a property processor. - * Users can provide their own or replace it using "ant.PropertyHelper" - * reference. User tasks can also add themself to the chain, and provide - * dynamic properties. + /** + * Factory method to create a property processor. + * Users can provide their own or replace it using "ant.PropertyHelper" + * reference. User tasks can also add themself to the chain, and provide + * dynamic properties. + * + * @param project the project fro which the property helper is required. + * + * @return the project's property helper. */ public static PropertyHelper getPropertyHelper(Project project) { - PropertyHelper ph=(PropertyHelper)project.getReference( "ant.PropertyHelper" ); - if( ph!=null ) return ph; - ph=new PropertyHelper(); - ph.setProject( project ); + PropertyHelper helper + = (PropertyHelper) project.getReference("ant.PropertyHelper"); + if (helper != null) { + return helper; + } + helper = new PropertyHelper(); + helper.setProject(project); - project.addReference( "ant.PropertyHelper",ph ); - return ph; + project.addReference("ant.PropertyHelper", helper); + return helper; } // -------------------- Methods to override -------------------- @@ -161,19 +184,18 @@ public class PropertyHelper { * @param value The new value of the property. * Must not be null. * @return true if this helper has stored the property, false if it - * couldn't. Each helper should delegate to the next one ( unless it - * has a good reason not to ). + * couldn't. Each helper should delegate to the next one (unless it + * has a good reason not to). */ public boolean setPropertyHook(String ns, String name, Object value, boolean inherited, boolean user, - boolean isNew) - { - if( getNext()!=null ) { - boolean subst=getNext().setPropertyHook(ns, name, value, + boolean isNew) { + if (getNext() != null) { + boolean subst = getNext().setPropertyHook(ns, name, value, inherited, user, isNew); // If next has handled the property - if( subst ) { + if (subst) { return true; } } @@ -189,15 +211,19 @@ public class PropertyHelper { * @return */ public Object getPropertyHook(String ns, String name, boolean user) { - if( getNext() != null ) { - Object o=getNext().getPropertyHook(ns, name, user); - if( o!= null ) return o; + if (getNext() != null) { + Object o = getNext().getPropertyHook(ns, name, user); + if (o != null) { + return o; + } } // Experimental/Testing, will be removed - if( name.startsWith( "toString:" )) { - name=name.substring( "toString:".length()); - Object v=project.getReference( name ); - if( v==null ) return null; + if (name.startsWith("toString:")) { + name = name.substring("toString:".length()); + Object v = project.getReference(name); + if (v == null) { + return null; + } return v.toString(); } @@ -207,9 +233,9 @@ public class PropertyHelper { // -------------------- Optional methods -------------------- // You can override those methods if you want to optimize or - // do advanced things ( like support a special syntax ). + // do advanced things (like support a special syntax). // The methods do not chain - you should use them when embedding ant - // ( by replacing the main helper ) + // (by replacing the main helper) /** * Parses a string containing ${xxx} style property @@ -232,8 +258,7 @@ public class PropertyHelper { */ public void parsePropertyString(String value, Vector fragments, Vector propertyRefs) - throws BuildException - { + throws BuildException { parsePropertyStringDefault(value, fragments, propertyRefs); } @@ -256,8 +281,7 @@ public class PropertyHelper { */ public String replaceProperties(String ns, String value, Hashtable keys) - throws BuildException - { + throws BuildException { if (value == null) { return null; } @@ -274,22 +298,22 @@ public class PropertyHelper { String fragment = (String) i.nextElement(); if (fragment == null) { String propertyName = (String) j.nextElement(); - Object replacement=null; + Object replacement = null; // try to get it from the project or keys // Backward compatibility - if( keys!=null ) { - replacement=keys.get(propertyName); + if (keys != null) { + replacement = keys.get(propertyName); } - if( replacement==null ) { - replacement=getProperty(ns, propertyName); + if (replacement == null) { + replacement = getProperty(ns, propertyName); } - if (replacement == null ) { + if (replacement == null) { project.log("Property ${" + propertyName + "} has not been set", Project.MSG_VERBOSE); } - fragment = (replacement!=null) + fragment = (replacement != null) ? replacement.toString() : "${" + propertyName + "}"; } @@ -309,19 +333,18 @@ public class PropertyHelper { * added. */ public synchronized boolean setProperty(String ns, String name, - Object value, boolean verbose) - { - // user ( CLI ) properties take precedence + Object value, boolean verbose) { + // user (CLI) properties take precedence if (null != userProperties.get(name)) { - if( verbose ) { + if (verbose) { project.log("Override ignored for user property " + name, Project.MSG_VERBOSE); } return false; } - boolean done=this.setPropertyHook(ns, name, value, false, false, false); - if( done ) { + boolean done = setPropertyHook(ns, name, value, false, false, false); + if (done) { return true; } @@ -330,9 +353,9 @@ public class PropertyHelper { Project.MSG_VERBOSE); } - if( verbose ) { - project.log("Setting project property: " + name + " -> " + - value, Project.MSG_DEBUG); + if (verbose) { + project.log("Setting project property: " + name + " -> " + + value, Project.MSG_DEBUG); } properties.put(name, value); return true; @@ -350,22 +373,21 @@ public class PropertyHelper { * @since Ant 1.6 */ public synchronized void setNewProperty(String ns, String name, - Object value) - { + Object value) { if (null != properties.get(name)) { project.log("Override ignored for property " + name, Project.MSG_VERBOSE); return; } - boolean done=this.setPropertyHook(ns, name, value, false, true, false); - if( done ) { + boolean done = setPropertyHook(ns, name, value, false, true, false); + if (done) { return; } - project.log("Setting project property: " + name + " -> " + - value, Project.MSG_DEBUG); - if( name!= null && value!=null ) { + project.log("Setting project property: " + name + " -> " + + value, Project.MSG_DEBUG); + if (name != null && value != null) { properties.put(name, value); } } @@ -379,14 +401,13 @@ public class PropertyHelper { * Must not be null. */ public synchronized void setUserProperty(String ns, String name, - Object value) - { - project.log("Setting ro project property: " + name + " -> " + - value, Project.MSG_DEBUG); + Object value) { + project.log("Setting ro project property: " + name + " -> " + + value, Project.MSG_DEBUG); userProperties.put(name, value); - boolean done=this.setPropertyHook(ns, name, value, false, false, true); - if( done ) { + boolean done = setPropertyHook(ns, name, value, false, false, true); + if (done) { return; } properties.put(name, value); @@ -404,16 +425,15 @@ public class PropertyHelper { * Must not be null. */ public synchronized void setInheritedProperty(String ns, String name, - Object value) - { + Object value) { inheritedProperties.put(name, value); - project.log("Setting ro project property: " + name + " -> " + - value, Project.MSG_DEBUG); + project.log("Setting ro project property: " + name + " -> " + + value, Project.MSG_DEBUG); userProperties.put(name, value); - boolean done=this.setPropertyHook(ns, name, value, true, false, false); - if( done ) { + boolean done = setPropertyHook(ns, name, value, true, false, false); + if (done) { return; } properties.put(name, value); @@ -436,8 +456,8 @@ public class PropertyHelper { return null; } - Object o=getPropertyHook(ns, name, false); - if( o!= null ) { + Object o = getPropertyHook(ns, name, false); + if (o != null) { return o; } @@ -456,8 +476,8 @@ public class PropertyHelper { if (name == null) { return null; } - Object o=getPropertyHook(ns, name, true); - if( o!= null ) { + Object o = getPropertyHook(ns, name, true); + if (o != null) { return o; } return userProperties.get(name); @@ -466,7 +486,7 @@ public class PropertyHelper { // -------------------- Access to property tables -------------------- // This is used to support ant call and similar tasks. It should be - // deprecated, it is possible to use a better ( more efficient ) + // deprecated, it is possible to use a better (more efficient) // mechanism to preserve the context. // TODO: do we need to delegate ? @@ -559,16 +579,15 @@ public class PropertyHelper { // -------------------- Property parsing -------------------- // Moved from ProjectHelper. You can override the static method - - // this is used for backward compatibility ( for code that calls - // the parse method in ProjectHelper ). + // this is used for backward compatibility (for code that calls + // the parse method in ProjectHelper). /** Default parsing method. It is here only to support backward compat * for the static ProjectHelper.parsePropertyString(). */ static void parsePropertyStringDefault(String value, Vector fragments, Vector propertyRefs) - throws BuildException - { + throws BuildException { int prev = 0; int pos; //search for the next instance of $ from the 'prev' position diff --git a/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java b/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java index 60f0901ef..77a72c7b8 100644 --- a/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java +++ b/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java @@ -57,7 +57,13 @@ package org.apache.tools.ant.listener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogConfigurationException; import org.apache.commons.logging.LogFactory; -import org.apache.tools.ant.*; + +import org.apache.tools.ant.BuildListener; +import org.apache.tools.ant.BuildLogger; +import org.apache.tools.ant.BuildEvent; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.UnknownElement; import java.io.PrintStream; @@ -74,7 +80,7 @@ import java.io.PrintStream; * * In all target and project names we replace "." and " " with "-". * - * TODO: we should use the advanced context logging features ( and expose them + * TODO: we should use the advanced context logging features (and expose them * in c-l first :-) * TODO: this is _very_ inefficient. Switching the out and tracking the logs * can be optimized a lot - but may require few more changes to the core. @@ -96,18 +102,18 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { public CommonsLoggingListener() { } - private Log getLog( String cat, String suffix ) { - if( suffix != null ) { - suffix=suffix.replace('.', '-'); - suffix=suffix.replace(' ', '-'); - cat=cat + "." + suffix; + private Log getLog(String cat, String suffix) { + if (suffix != null) { + suffix = suffix.replace('.', '-'); + suffix = suffix.replace(' ', '-'); + cat = cat + "." + suffix; } - PrintStream tmpOut=System.out; - PrintStream tmpErr=System.err; - System.setOut( out ); - System.setErr( err ); + PrintStream tmpOut = System.out; + PrintStream tmpErr = System.err; + System.setOut(out); + System.setErr(err); - if( ! initialized ) { + if (!initialized) { try { logFactory = LogFactory.getFactory(); } catch (LogConfigurationException e) { @@ -117,9 +123,9 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { } initialized = true; - Log log=logFactory.getInstance(cat); - System.setOut( tmpOut ); - System.setErr( tmpErr ); + Log log = logFactory.getInstance(cat); + System.setOut(tmpOut); + System.setErr(tmpErr); return log; } @@ -127,11 +133,11 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { * @see BuildListener#buildStarted */ public void buildStarted(BuildEvent event) { - String categoryString= "org.apache.tools.ant.Project"; - Log log=getLog(categoryString, null); + String categoryString = "org.apache.tools.ant.Project"; + Log log = getLog(categoryString, null); if (initialized) { - realLog( log, "Build started.", Project.MSG_INFO, null); + realLog(log, "Build started.", Project.MSG_INFO, null); } } @@ -140,13 +146,13 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { */ public void buildFinished(BuildEvent event) { if (initialized) { - String categoryString= "org.apache.tools.ant.Project"; - Log log=getLog(categoryString, event.getProject().getName()); + String categoryString = "org.apache.tools.ant.Project"; + Log log = getLog(categoryString, event.getProject().getName()); if (event.getException() == null) { - realLog( log, "Build finished.", Project.MSG_INFO, null); + realLog(log, "Build finished.", Project.MSG_INFO, null); } else { - realLog( log, "Build finished with error.", Project.MSG_ERR, + realLog(log, "Build finished with error.", Project.MSG_ERR, event.getException()); } } @@ -158,10 +164,10 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { public void targetStarted(BuildEvent event) { if (initialized) { Log log = getLog("org.apache.tools.ant.Target", - event.getTarget().getName() ); + event.getTarget().getName()); // Since task log category includes target, we don't really // need this message - realLog( log, "Start: " + event.getTarget().getName(), + realLog(log, "Start: " + event.getTarget().getName(), Project.MSG_DEBUG, null); } } @@ -173,7 +179,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { if (initialized) { String targetName = event.getTarget().getName(); Log log = getLog("org.apache.tools.ant.Target", - event.getTarget().getName() ); + event.getTarget().getName()); if (event.getException() == null) { realLog(log, "Target end: " + targetName, Project.MSG_DEBUG, null); } else { @@ -190,16 +196,16 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { public void taskStarted(BuildEvent event) { if (initialized) { Task task = event.getTask(); - Object real=task; - if( task instanceof UnknownElement ) { - Object realObj=((UnknownElement)task).getTask(); - if( realObj!=null ) { - real=realObj; + Object real = task; + if (task instanceof UnknownElement) { + Object realObj = ((UnknownElement) task).getTask(); + if (realObj != null) { + real = realObj; } } Log log = getLog(real.getClass().getName(), null); - if( log.isTraceEnabled()) { - realLog( log, "Task \"" + task.getTaskName() + "\" started ", + if (log.isTraceEnabled()) { + realLog(log, "Task \"" + task.getTaskName() + "\" started ", Project.MSG_VERBOSE, null); } } @@ -211,21 +217,21 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { public void taskFinished(BuildEvent event) { if (initialized) { Task task = event.getTask(); - Object real=task; - if( task instanceof UnknownElement ) { - Object realObj=((UnknownElement)task).getTask(); - if( realObj!=null ) { - real=realObj; + Object real = task; + if (task instanceof UnknownElement) { + Object realObj = ((UnknownElement) task).getTask(); + if (realObj != null) { + real = realObj; } } Log log = getLog(real.getClass().getName(), null); if (event.getException() == null) { - if( log.isTraceEnabled() ) { - realLog( log, "Task \"" + task.getTaskName() + "\" finished.", + if (log.isTraceEnabled()) { + realLog(log, "Task \"" + task.getTaskName() + "\" finished.", Project.MSG_VERBOSE, null); } } else { - realLog( log, "Task \"" + task.getTaskName() + realLog(log, "Task \"" + task.getTaskName() + "\" finished with error.", Project.MSG_ERR, event.getException()); } @@ -239,63 +245,62 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { public void messageLogged(BuildEvent event) { if (initialized) { Object categoryObject = event.getTask(); - String categoryString=null; - String categoryDetail=null; + String categoryString = null; + String categoryDetail = null; if (categoryObject == null) { categoryObject = event.getTarget(); if (categoryObject == null) { categoryObject = event.getProject(); - categoryString="org.apache.tools.ant.Project"; - categoryDetail=event.getProject().getName(); + categoryString = "org.apache.tools.ant.Project"; + categoryDetail = event.getProject().getName(); } else { - categoryString= "org.apache.tools.ant.Target"; - categoryDetail=event.getTarget().getName(); + categoryString = "org.apache.tools.ant.Target"; + categoryDetail = event.getTarget().getName(); } } else { // It's a task - append the target - if( event.getTarget() != null ) { - categoryString=categoryObject.getClass().getName(); - categoryDetail=event.getTarget().getName(); + if (event.getTarget() != null) { + categoryString = categoryObject.getClass().getName(); + categoryDetail = event.getTarget().getName(); } else { - categoryString=categoryObject.getClass().getName(); + categoryString = categoryObject.getClass().getName(); } } Log log = getLog(categoryString, categoryDetail); - int priority=event.getPriority(); - String message=event.getMessage(); - realLog( log, message, priority , null); + int priority = event.getPriority(); + String message = event.getMessage(); + realLog(log, message, priority , null); } } - private void realLog( Log log, String message, int priority, Throwable t ) - { - PrintStream tmpOut=System.out; - PrintStream tmpErr=System.err; - System.setOut( out ); - System.setErr( err ); + private void realLog(Log log, String message, int priority, Throwable t) { + PrintStream tmpOut = System.out; + PrintStream tmpErr = System.err; + System.setOut(out); + System.setErr(err); switch (priority) { case Project.MSG_ERR: - if( t==null ) { + if (t == null) { log.error(message); } else { - log.error( message,t ); + log.error(message, t); } break; case Project.MSG_WARN: - if( t==null ) { + if (t == null) { log.warn(message); } else { - log.warn( message,t ); + log.warn(message, t); } break; case Project.MSG_INFO: - if( t==null ) { + if (t == null) { log.info(message); } else { - log.info( message,t ); + log.info(message, t); } break; case Project.MSG_VERBOSE: @@ -308,8 +313,8 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { log.error(message); break; } - System.setOut( tmpOut ); - System.setErr( tmpErr ); + System.setOut(tmpOut); + System.setErr(tmpErr); } PrintStream out; @@ -328,7 +333,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { } public void setErrorPrintStream(PrintStream err) { - this.err=err; + this.err = err; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Definer.java b/src/main/org/apache/tools/ant/taskdefs/Definer.java index 85d4720ae..cecb7989f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Definer.java +++ b/src/main/org/apache/tools/ant/taskdefs/Definer.java @@ -353,6 +353,7 @@ public abstract class Definer extends Task { try { is.close(); } catch (IOException e) { + // ignore } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/SubAnt.java b/src/main/org/apache/tools/ant/taskdefs/SubAnt.java index ffd875eb6..af9efc59a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SubAnt.java +++ b/src/main/org/apache/tools/ant/taskdefs/SubAnt.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2003 The Apache Software Foundation. All rights + * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java index 2c291ca87..99bc8bc57 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckout.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,6 +61,9 @@ package org.apache.tools.ant.taskdefs.optional.ccm; */ public class CCMCheckout extends CCMCheck { + /** + * default constructor + */ public CCMCheckout() { super(); setCcmAction(COMMAND_CHECKOUT); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java index 14092a1e2..b4d92cbe9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/AntAnalyzer.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,6 +71,9 @@ import org.apache.tools.ant.util.depend.AbstractAnalyzer; * @author Conor MacNeill */ public class AntAnalyzer extends AbstractAnalyzer { + /** + * Default constructor + */ public AntAnalyzer() { } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java index 3840923e9..b94ebcc12 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/ConstantPoolEntry.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -138,7 +138,7 @@ public abstract class ConstantPoolEntry { * be read. * @return the appropriate ConstantPoolEntry subclass representing the * constant pool entry from the stream. - * @exception IOException if the constant pool entry cannot be read + * @exception IOException if the constant pool entry cannot be read * from the stream */ public static ConstantPoolEntry readEntry(DataInputStream cpStream) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java index 1e9545d0a..7020bd571 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/DoubleCPInfo.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ import java.io.IOException; * @author Conor MacNeill */ public class DoubleCPInfo extends ConstantCPInfo { - /** + /** * Constructor */ public DoubleCPInfo() { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java index 3b4ff42c9..37cb51dad 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/constantpool/StringCPInfo.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -89,7 +89,7 @@ public class StringCPInfo extends ConstantCPInfo { * @return the string representation of this constant pool entry. */ public String toString() { - return "String Constant Pool Entry for " + return "String Constant Pool Entry for " + getValue() + "[" + index + "]"; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java index aa7d23123..ce2fa7807 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,38 +66,35 @@ import org.apache.tools.ant.Task; * @author Peter Donald * @ant.task name="jarlib-available" */ -public class JarLibAvailableTask - extends Task -{ +public class JarLibAvailableTask extends Task { /** * The library to display information about. */ - private File m_file; + private File libraryFile; /** * Filesets specifying all the librarys * to display information about. */ - private final Vector m_extensionSets = new Vector(); + private final Vector extensionFileSets = new Vector(); /** * The name of the property to set if extension is available. */ - private String m_property; + private String propertyName; /** * The extension that is required. */ - private ExtensionAdapter m_extension; + private ExtensionAdapter requiredExtension; /** * The name of property to set if extensions are available. * * @param property The name of property to set if extensions is available. */ - public void setProperty( final String property ) - { - m_property = property; + public void setProperty(final String property) { + this.propertyName = property; } /** @@ -105,9 +102,8 @@ public class JarLibAvailableTask * * @param file The jar library to check. */ - public void setFile( final File file ) - { - m_file = file; + public void setFile(final File file) { + this.libraryFile = file; } /** @@ -115,15 +111,13 @@ public class JarLibAvailableTask * * @param extension Set the Extension looking for. */ - public void addConfiguredExtension( final ExtensionAdapter extension ) - { - if( null != m_extension ) - { - final String message = "Can not specify extension to " + - "search for multiple times."; - throw new BuildException( message ); + public void addConfiguredExtension(final ExtensionAdapter extension) { + if (null != requiredExtension) { + final String message = "Can not specify extension to " + + "search for multiple times."; + throw new BuildException(message); } - m_extension = extension; + requiredExtension = extension; } /** @@ -131,47 +125,42 @@ public class JarLibAvailableTask * * @param extensionSet a set of extensions to search in. */ - public void addConfiguredExtensionSet( final ExtensionSet extensionSet ) - { - m_extensionSets.addElement( extensionSet ); + public void addConfiguredExtensionSet(final ExtensionSet extensionSet) { + extensionFileSets.addElement(extensionSet); } - public void execute() - throws BuildException - { + /** + * Execute the task. + * + * @throws BuildException if somethign goes wrong. + */ + public void execute() throws BuildException { validate(); - final Extension test = m_extension.toExtension(); + final Extension test = requiredExtension.toExtension(); // Check if list of files to check has been specified - if( !m_extensionSets.isEmpty() ) - { - final Iterator iterator = m_extensionSets.iterator(); - while( iterator.hasNext() ) - { - final ExtensionSet extensionSet = (ExtensionSet)iterator.next(); + if (!extensionFileSets.isEmpty()) { + final Iterator iterator = extensionFileSets.iterator(); + while (iterator.hasNext()) { + final ExtensionSet extensionSet + = (ExtensionSet) iterator.next(); final Extension[] extensions = - extensionSet.toExtensions( getProject() ); - for( int i = 0; i < extensions.length; i++ ) - { + extensionSet.toExtensions(getProject()); + for (int i = 0; i < extensions.length; i++) { final Extension extension = extensions[ i ]; - if( extension.isCompatibleWith( test ) ) - { - getProject().setNewProperty( m_property, "true" ); + if (extension.isCompatibleWith(test)) { + getProject().setNewProperty(propertyName, "true"); } } } - } - else - { - final Manifest manifest = ExtensionUtil.getManifest( m_file ); - final Extension[] extensions = Extension.getAvailable( manifest ); - for( int i = 0; i < extensions.length; i++ ) - { + } else { + final Manifest manifest = ExtensionUtil.getManifest(libraryFile); + final Extension[] extensions = Extension.getAvailable(manifest); + for (int i = 0; i < extensions.length; i++) { final Extension extension = extensions[ i ]; - if( extension.isCompatibleWith( test ) ) - { - getProject().setNewProperty( m_property, "true" ); + if (extension.isCompatibleWith(test)) { + getProject().setNewProperty(propertyName, "true"); } } } @@ -182,29 +171,23 @@ public class JarLibAvailableTask * * @throws BuildException if invalid parameters found */ - private void validate() - throws BuildException - { - if( null == m_extension ) - { + private void validate() throws BuildException { + if (null == requiredExtension) { final String message = "Extension element must be specified."; - throw new BuildException( message ); + throw new BuildException(message); } - if( null == m_file && m_extensionSets.isEmpty() ) - { + if (null == libraryFile && extensionFileSets.isEmpty()) { final String message = "File attribute not specified."; - throw new BuildException( message ); + throw new BuildException(message); } - if( null != m_file && !m_file.exists() ) - { - final String message = "File '" + m_file + "' does not exist."; - throw new BuildException( message ); + if (null != libraryFile && !libraryFile.exists()) { + final String message = "File '" + libraryFile + "' does not exist."; + throw new BuildException(message); } - if( null != m_file && !m_file.isFile() ) - { - final String message = "\'" + m_file + "\' is not a file."; - throw new BuildException( message ); + if (null != libraryFile && !libraryFile.isFile()) { + final String message = "\'" + libraryFile + "\' is not a file."; + throw new BuildException(message); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java index a8b7d8ceb..62f8d21fb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -75,28 +75,25 @@ import org.apache.tools.ant.types.FileSet; * @author Peter Donald * @ant.task name="jarlib-display" */ -public class JarLibDisplayTask - extends Task -{ +public class JarLibDisplayTask extends Task { /** * The library to display information about. */ - private File m_file; + private File libraryFile; /** * Filesets specifying all the librarys * to display information about. */ - private final Vector m_filesets = new Vector(); + private final Vector libraryFileSets = new Vector(); /** * The JAR library to display information for. * * @param file The jar library to display information for. */ - public void setFile( final File file ) - { - m_file = file; + public void setFile(final File file) { + this.libraryFile = file; } /** @@ -104,37 +101,35 @@ public class JarLibDisplayTask * * @param fileSet a set of files about which library data will be displayed. */ - public void addFileset( final FileSet fileSet ) - { - m_filesets.addElement( fileSet ); + public void addFileset(final FileSet fileSet) { + libraryFileSets.addElement(fileSet); } - public void execute() - throws BuildException - { + /** + * Execute the task. + * + * @throws BuildException if the task fails. + */ + public void execute() throws BuildException { validate(); final LibraryDisplayer displayer = new LibraryDisplayer(); // Check if list of files to check has been specified - if( !m_filesets.isEmpty() ) - { - final Iterator iterator = m_filesets.iterator(); - while( iterator.hasNext() ) - { - final FileSet fileSet = (FileSet)iterator.next(); - final DirectoryScanner scanner = fileSet.getDirectoryScanner( getProject() ); + if (!libraryFileSets.isEmpty()) { + final Iterator iterator = libraryFileSets.iterator(); + while (iterator.hasNext()) { + final FileSet fileSet = (FileSet) iterator.next(); + final DirectoryScanner scanner + = fileSet.getDirectoryScanner(getProject()); final File basedir = scanner.getBasedir(); final String[] files = scanner.getIncludedFiles(); - for( int i = 0; i < files.length; i++ ) - { - final File file = new File( basedir, files[ i ] ); - displayer.displayLibrary( file ); + for (int i = 0; i < files.length; i++) { + final File file = new File(basedir, files[ i ]); + displayer.displayLibrary(file); } } - } - else - { - displayer.displayLibrary( m_file ); + } else { + displayer.displayLibrary(libraryFile); } } @@ -143,23 +138,18 @@ public class JarLibDisplayTask * * @throws BuildException if invalid parameters found */ - private void validate() - throws BuildException - { - if( null == m_file && m_filesets.isEmpty() ) - { + private void validate() throws BuildException { + if (null == libraryFile && libraryFileSets.isEmpty()) { final String message = "File attribute not specified."; - throw new BuildException( message ); + throw new BuildException(message); } - if( null != m_file && !m_file.exists() ) - { - final String message = "File '" + m_file + "' does not exist."; - throw new BuildException( message ); + if (null != libraryFile && !libraryFile.exists()) { + final String message = "File '" + libraryFile + "' does not exist."; + throw new BuildException(message); } - if( null != m_file && !m_file.isFile() ) - { - final String message = "\'" + m_file + "\' is not a file."; - throw new BuildException( message ); + if (null != libraryFile && !libraryFile.isFile()) { + final String message = "\'" + libraryFile + "\' is not a file."; + throw new BuildException(message); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java index f59bc8200..3b7b5e633 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,9 +80,7 @@ import org.apache.tools.ant.Task; * @author Peter Donald * @ant.task name="jarlib-manifest" */ -public final class JarLibManifestTask - extends Task -{ +public final class JarLibManifestTask extends Task { /** * Version of manifest spec that task generates. */ @@ -96,58 +94,56 @@ public final class JarLibManifestTask /** * The library to display information about. */ - private File m_destfile; + private File destFile; /** * The extension supported by this library (if any). */ - private Extension m_extension; + private Extension extension; /** * ExtensionAdapter objects representing * dependencies required by library. */ - private final ArrayList m_dependencies = new ArrayList(); + private final ArrayList dependencies = new ArrayList(); /** * ExtensionAdapter objects representing optional * dependencies required by library. */ - private final ArrayList m_optionals = new ArrayList(); + private final ArrayList optionals = new ArrayList(); /** * Extra attributes the user specifies for main section * in manifest. */ - private final ArrayList m_extraAttributes = new ArrayList(); + private final ArrayList extraAttributes = new ArrayList(); /** * The location where generated manifest is placed. * - * @param destfile The location where generated manifest is placed. + * @param destFile The location where generated manifest is placed. */ - public void setDestfile( final File destfile ) - { - m_destfile = destfile; + public void setDestfile(final File destFile) { + this.destFile = destFile; } /** * Adds an extension that this library implements. * * @param extensionAdapter an extension that this library implements. + * + * @throws BuildException if there is multiple extensions detected + * in the library. */ - public void addConfiguredExtension( final ExtensionAdapter extensionAdapter ) - throws BuildException - { - if( null != m_extension ) - { + public void addConfiguredExtension(final ExtensionAdapter extensionAdapter) + throws BuildException { + if (null != extension) { final String message = "Can not have multiple extensions defined in one library."; - throw new BuildException( message ); - } - else - { - m_extension = extensionAdapter.toExtension(); + throw new BuildException(message); + } else { + extension = extensionAdapter.toExtension(); } } @@ -156,9 +152,8 @@ public final class JarLibManifestTask * * @param extensionSet a set of extensions that this library requires. */ - public void addConfiguredDepends( final ExtensionSet extensionSet ) - { - m_dependencies.add( extensionSet ); + public void addConfiguredDepends(final ExtensionSet extensionSet) { + dependencies.add(extensionSet); } /** @@ -166,9 +161,8 @@ public final class JarLibManifestTask * * @param extensionSet a set of extensions that this library optionally requires. */ - public void addConfiguredOptions( final ExtensionSet extensionSet ) - { - m_optionals.add( extensionSet ); + public void addConfiguredOptions(final ExtensionSet extensionSet) { + optionals.add(extensionSet); } /** @@ -176,56 +170,54 @@ public final class JarLibManifestTask * * @param attribute an attribute that is to be put in main section of manifest. */ - public void addConfiguredAttribute( final ExtraAttribute attribute ) - { - m_extraAttributes.add( attribute ); + public void addConfiguredAttribute(final ExtraAttribute attribute) { + extraAttributes.add(attribute); } - public void execute() - throws BuildException - { + /** + * Execute the task. + * + * @throws BuildException if the task fails. + */ + public void execute() throws BuildException { validate(); final Manifest manifest = new Manifest(); final Attributes attributes = manifest.getMainAttributes(); - attributes.put( Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION ); - final String createdBy = "Apache Ant " + getProject().getProperty( "ant.version" ); - attributes.putValue( CREATED_BY, createdBy ); + attributes.put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION); + final String createdBy = "Apache Ant " + getProject().getProperty("ant.version"); + attributes.putValue(CREATED_BY, createdBy); - appendExtraAttributes( attributes ); + appendExtraAttributes(attributes); - if( null != m_extension ) - { - Extension.addExtension( m_extension, attributes ); + if (null != extension) { + Extension.addExtension(extension, attributes); } //Add all the dependency data to manifest for dependencies - final ArrayList depends = toExtensions( m_dependencies ); - appendExtensionList( attributes, + final ArrayList depends = toExtensions(dependencies); + appendExtensionList(attributes, Extension.EXTENSION_LIST, "lib", - depends.size() ); - appendLibraryList( attributes, "lib", depends ); + depends.size()); + appendLibraryList(attributes, "lib", depends); //Add all the dependency data to manifest for "optional" //dependencies - final ArrayList option = toExtensions( m_optionals ); - appendExtensionList( attributes, + final ArrayList option = toExtensions(optionals); + appendExtensionList(attributes, Extension.OPTIONAL_EXTENSION_LIST, "opt", - option.size() ); - appendLibraryList( attributes, "opt", option ); + option.size()); + appendLibraryList(attributes, "opt", option); - try - { - final String message = "Generating manifest " + m_destfile.getAbsoluteFile(); - log( message, Project.MSG_INFO ); - writeManifest( manifest ); - } - catch( final IOException ioe ) - { - throw new BuildException( ioe.getMessage(), ioe ); + try { + final String message = "Generating manifest " + destFile.getAbsoluteFile(); + log(message, Project.MSG_INFO); + writeManifest(manifest); + } catch (final IOException ioe) { + throw new BuildException(ioe.getMessage(), ioe); } } @@ -234,18 +226,14 @@ public final class JarLibManifestTask * * @throws BuildException if invalid parameters found */ - private void validate() - throws BuildException - { - if( null == m_destfile ) - { + private void validate() throws BuildException { + if (null == destFile) { final String message = "Destfile attribute not specified."; - throw new BuildException( message ); + throw new BuildException(message); } - if( m_destfile.exists() && !m_destfile.isFile() ) - { - final String message = m_destfile + " is not a file."; - throw new BuildException( message ); + if (destFile.exists() && !destFile.isFile()) { + final String message = destFile + " is not a file."; + throw new BuildException(message); } } @@ -255,15 +243,13 @@ public final class JarLibManifestTask * @param attributes the manifest section to write * attributes to */ - private void appendExtraAttributes( final Attributes attributes ) - { - final Iterator iterator = m_extraAttributes.iterator(); - while( iterator.hasNext() ) - { + private void appendExtraAttributes(final Attributes attributes) { + final Iterator iterator = extraAttributes.iterator(); + while (iterator.hasNext()) { final ExtraAttribute attribute = - (ExtraAttribute)iterator.next(); - attributes.putValue( attribute.getName(), - attribute.getValue() ); + (ExtraAttribute) iterator.next(); + attributes.putValue(attribute.getName(), + attribute.getValue()); } } @@ -273,26 +259,19 @@ public final class JarLibManifestTask * @param manifest the manifest * @throws IOException if error writing file */ - private void writeManifest( final Manifest manifest ) - throws IOException - { + private void writeManifest(final Manifest manifest) + throws IOException { FileOutputStream output = null; - try - { - output = new FileOutputStream( m_destfile ); - manifest.write( output ); + try { + output = new FileOutputStream(destFile); + manifest.write(output); output.flush(); - } - finally - { - if( null != output ) - { - try - { + } finally { + if (null != output) { + try { output.close(); - } - catch( IOException e ) - { + } catch (IOException e) { + // ignore } } } @@ -309,17 +288,15 @@ public final class JarLibManifestTask * @param extensions the list of extensions * @throws BuildException if an error occurs */ - private void appendLibraryList( final Attributes attributes, + private void appendLibraryList(final Attributes attributes, final String listPrefix, - final ArrayList extensions ) - throws BuildException - { + final ArrayList extensions) + throws BuildException { final int size = extensions.size(); - for( int i = 0; i < size; i++ ) - { - final Extension extension = (Extension)extensions.get( i ); + for (int i = 0; i < size; i++) { + final Extension extension = (Extension) extensions.get(i); final String prefix = listPrefix + i + "-"; - Extension.addExtension( extension, prefix, attributes ); + Extension.addExtension(extension, prefix, attributes); } } @@ -334,21 +311,19 @@ public final class JarLibManifestTask * @param attributes the attributes to add key-value to * @param extensionKey the key to use */ - private void appendExtensionList( final Attributes attributes, + private void appendExtensionList(final Attributes attributes, final Attributes.Name extensionKey, final String listPrefix, - final int size ) - { + final int size) { final StringBuffer sb = new StringBuffer(); - for( int i = 0; i < size; i++ ) - { - sb.append( listPrefix + i ); - sb.append( ' ' ); + for (int i = 0; i < size; i++) { + sb.append(listPrefix + i); + sb.append(' '); } //add in something like //"Extension-List: javahelp java3d" - attributes.put( extensionKey, sb.toString() ); + attributes.put(extensionKey, sb.toString()); } /** @@ -357,19 +332,16 @@ public final class JarLibManifestTask * @param extensionSets the list of ExtensionSets to add to list * @throws BuildException if an error occurs */ - private ArrayList toExtensions( final ArrayList extensionSets ) - throws BuildException - { + private ArrayList toExtensions(final ArrayList extensionSets) + throws BuildException { final ArrayList results = new ArrayList(); final int size = extensionSets.size(); - for( int i = 0; i < size; i++ ) - { - final ExtensionSet set = (ExtensionSet)extensionSets.get( i ); - final Extension[] extensions = set.toExtensions( getProject() ); - for( int j = 0; j < extensions.length; j++ ) - { - results.add( extensions[ j ] ); + for (int i = 0; i < size; i++) { + final ExtensionSet set = (ExtensionSet) extensionSets.get(i); + final Extension[] extensions = set.toExtensions(getProject()); + for (int j = 0; j < extensions.length; j++) { + results.add(extensions[ j ]); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java index f1dcced0c..248fe1fb1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,24 +71,22 @@ import org.apache.tools.ant.taskdefs.optional.extension.resolvers.URLResolver; * @author Jeff Turner * @ant.task name="jarlib-resolve" */ -public class JarLibResolveTask - extends Task -{ +public class JarLibResolveTask extends Task { /** * The name of the property in which the location of * library is stored. */ - private String m_property; + private String propertyName; /** * The extension that is required. */ - private Extension m_extension; + private Extension requiredExtension; /** * The set of resolvers to use to attempt to locate library. */ - private final ArrayList m_resolvers = new ArrayList(); + private final ArrayList resolvers = new ArrayList(); /** * Flag to indicate that you should check that @@ -96,14 +94,14 @@ public class JarLibResolveTask * extension and if they don't then raise * an exception. */ - private boolean m_checkExtension = true; + private boolean checkExtension = true; /** * Flag indicating whether or not you should * throw a BuildException if you cannot resolve * library. */ - private boolean m_failOnError = true; + private boolean failOnError = true; /** * The name of the property in which the location of @@ -112,52 +110,56 @@ public class JarLibResolveTask * @param property The name of the property in which the location of * library is stored. */ - public void setProperty( final String property ) - { - m_property = property; + public void setProperty(final String property) { + this.propertyName = property; } /** - * If true, libraries returned by nested resolvers should be - * checked to see if they supply extension. + * Check nested libraries for extensions + * + * @param checkExtension if true, libraries returned by nested + * resolvers should be checked to see if they supply extension. */ - public void setCheckExtension( final boolean checkExtension ) - { - m_checkExtension = checkExtension; + public void setCheckExtension(final boolean checkExtension) { + this.checkExtension = checkExtension; } /** - * If true, failure to locate library should fail build. + * Set whether to fail if error. + * + * @param failOnError if true, failure to locate library should fail build. */ - public void setFailOnError( final boolean failOnError ) - { - m_failOnError = failOnError; + public void setFailOnError(final boolean failOnError) { + this.failOnError = failOnError; } /** * Adds location resolver to look for a library in a location * relative to project directory. + * + * @param location the resolver location to search. */ - public void addConfiguredLocation( final LocationResolver location ) - { - m_resolvers.add( location ); + public void addConfiguredLocation(final LocationResolver location) { + resolvers.add(location); } /** * Adds a URL resolver to download a library from a URL * to a local file. + * + * @param url the URL resolver from which to download the library */ - public void addConfiguredUrl( final URLResolver url ) - { - m_resolvers.add( url ); + public void addConfiguredUrl(final URLResolver url) { + resolvers.add(url); } /** * Adds Ant resolver to run an Ant build file to generate a library. + * + * @param ant the AntResolver to generate the library. */ - public void addConfiguredAnt( final AntResolver ant ) - { - m_resolvers.add( ant ); + public void addConfiguredAnt(final AntResolver ant) { + resolvers.add(ant); } /** @@ -165,74 +167,63 @@ public class JarLibResolveTask * * @param extension Set the Extension looking for. */ - public void addConfiguredExtension( final ExtensionAdapter extension ) - { - if( null != m_extension ) - { - final String message = "Can not specify extension to " + - "resolve multiple times."; - throw new BuildException( message ); + public void addConfiguredExtension(final ExtensionAdapter extension) { + if (null != requiredExtension) { + final String message = "Can not specify extension to " + + "resolve multiple times."; + throw new BuildException(message); } - m_extension = extension.toExtension(); + requiredExtension = extension.toExtension(); } - public void execute() - throws BuildException - { + /** + * Execute the task. + * + * @throws BuildException if the task fails. + */ + public void execute() throws BuildException { validate(); - getProject().log( "Resolving extension: " + m_extension, - Project.MSG_VERBOSE ); + getProject().log("Resolving extension: " + requiredExtension, + Project.MSG_VERBOSE); String candidate = - getProject().getProperty( m_property ); + getProject().getProperty(propertyName); - if( null != candidate ) - { + if (null != candidate) { final String message = "Property Already set to: " + candidate; - if( m_failOnError ) - { - throw new BuildException( message ); - } - else - { - getProject().log( message, Project.MSG_ERR ); + if (failOnError) { + throw new BuildException(message); + } else { + getProject().log(message, Project.MSG_ERR); return; } } - final int size = m_resolvers.size(); - for( int i = 0; i < size; i++ ) - { + final int size = resolvers.size(); + for (int i = 0; i < size; i++) { final ExtensionResolver resolver = - (ExtensionResolver)m_resolvers.get( i ); + (ExtensionResolver) resolvers.get(i); - getProject().log( "Searching for extension using Resolver:" + resolver, - Project.MSG_VERBOSE ); + getProject().log("Searching for extension using Resolver:" + resolver, + Project.MSG_VERBOSE); - try - { + try { final File file = - resolver.resolve( m_extension, getProject() ); - try - { - checkExtension( file ); + resolver.resolve(requiredExtension, getProject()); + try { + checkExtension(file); return; + } catch (final BuildException be) { + final String message = "File " + file + " returned by " + + "resolver failed to satisfy extension due to: " + + be.getMessage(); + getProject().log(message, Project.MSG_WARN); } - catch( final BuildException be ) - { - final String message = - "File " + file + " returned by resolver failed " + - "to satisfy extension due to: " + be.getMessage(); - getProject().log( message, Project.MSG_WARN ); - } - } - catch( final BuildException be ) - { - final String message = - "Failed to resolve extension to file " + - "using resolver " + resolver + " due to: " + be; - getProject().log( message, Project.MSG_WARN ); + } catch (final BuildException be) { + final String message = "Failed to resolve extension to file " + + "using resolver " + resolver + " due to: " + be; + getProject().log(message, Project.MSG_WARN); } } @@ -241,20 +232,16 @@ public class JarLibResolveTask /** * Utility method that will throw a {@link BuildException} - * if {@link #m_failOnError} is true else it just displays + * if {@link #failOnError} is true else it just displays * a warning. */ - private void missingExtension() - { + private void missingExtension() { final String message = "Unable to resolve extension to a file"; - if( m_failOnError ) - { - throw new BuildException( message ); - } - else - { - getProject().log( message, Project.MSG_ERR ); + if (failOnError) { + throw new BuildException(message); + } else { + getProject().log(message, Project.MSG_ERR); } } @@ -266,54 +253,44 @@ public class JarLibResolveTask * @param file the candidate library * @throws BuildException if library does not satisfy extension */ - private void checkExtension( final File file ) - { - if( !file.exists() ) - { + private void checkExtension(final File file) { + if (!file.exists()) { final String message = "File " + file + " does not exist"; - throw new BuildException( message ); + throw new BuildException(message); } - if( !file.isFile() ) - { + if (!file.isFile()) { final String message = "File " + file + " is not a file"; - throw new BuildException( message ); + throw new BuildException(message); } - if( !m_checkExtension ) - { - final String message = "Setting property to " + - file + " without verifying library satisfies extension"; - getProject().log( message, Project.MSG_VERBOSE ); - setLibraryProperty( file ); - } - else - { - getProject().log( "Checking file " + file + - " to see if it satisfies extension", - Project.MSG_VERBOSE ); + if (!checkExtension) { + final String message = "Setting property to " + file + + " without verifying library satisfies extension"; + getProject().log(message, Project.MSG_VERBOSE); + setLibraryProperty(file); + } else { + getProject().log("Checking file " + file + + " to see if it satisfies extension", Project.MSG_VERBOSE); final Manifest manifest = - ExtensionUtil.getManifest( file ); + ExtensionUtil.getManifest(file); final Extension[] extensions = - Extension.getAvailable( manifest ); - for( int i = 0; i < extensions.length; i++ ) - { + Extension.getAvailable(manifest); + for (int i = 0; i < extensions.length; i++) { final Extension extension = extensions[ i ]; - if( extension.isCompatibleWith( m_extension ) ) - { - setLibraryProperty( file ); + if (extension.isCompatibleWith(requiredExtension)) { + setLibraryProperty(file); return; } } - getProject().log( "File " + file + " skipped as it " + - "does not satisfy extension", - Project.MSG_VERBOSE ); + getProject().log("File " + file + " skipped as it " + + "does not satisfy extension", Project.MSG_VERBOSE); final String message = "File " + file + " does not satisfy extension"; - throw new BuildException( message ); + throw new BuildException(message); } } @@ -324,10 +301,9 @@ public class JarLibResolveTask * * @param file the library */ - private void setLibraryProperty( final File file ) - { - getProject().setNewProperty( m_property, - file.getAbsolutePath() ); + private void setLibraryProperty(final File file) { + getProject().setNewProperty(propertyName, + file.getAbsolutePath()); } /** @@ -335,19 +311,15 @@ public class JarLibResolveTask * * @throws BuildException if invalid parameters found */ - private void validate() - throws BuildException - { - if( null == m_property ) - { + private void validate() throws BuildException { + if (null == propertyName) { final String message = "Property attribute must be specified."; - throw new BuildException( message ); + throw new BuildException(message); } - if( null == m_extension ) - { + if (null == requiredExtension) { final String message = "Extension element must be specified."; - throw new BuildException( message ); + throw new BuildException(message); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java index c3ad03945..1056d18c5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java @@ -72,6 +72,11 @@ import org.apache.tools.ant.BuildException; */ public class P4Have extends P4Base { + /** + * Execute the Perforce have command. + * + * @throws BuildException if the command cannot be executed. + */ public void execute() throws BuildException { execP4Command("have " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this)); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java index 7c6c9944c..e427c1581 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Chgrp.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -116,7 +116,7 @@ public class Chgrp extends AbstractAccessTask { * @param e User supplied executable that we won't accept. */ public void setExecutable(String e) { - throw new BuildException(taskType + throw new BuildException(taskType + " doesn\'t support the executable" + " attribute", getLocation()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java index 5d7dd15c9..6a83fce5b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java @@ -138,7 +138,7 @@ public class MSVSSCHECKIN extends MSVSS { * * @param response The auto response value. */ - public void setAutoresponse(String response){ + public void setAutoresponse(String response) { super.setInternalAutoResponse(response); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java index 81343b319..19597b18a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java @@ -141,7 +141,7 @@ public class MSVSSLABEL extends MSVSS { * * @param response The auto response value. */ - public void setAutoresponse(String response){ + public void setAutoresponse(String response) { super.setInternalAutoResponse(response); } } diff --git a/src/main/org/apache/tools/ant/types/Parameterizable.java b/src/main/org/apache/tools/ant/types/Parameterizable.java index ce1178bae..9cddb3708 100644 --- a/src/main/org/apache/tools/ant/types/Parameterizable.java +++ b/src/main/org/apache/tools/ant/types/Parameterizable.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,5 +59,10 @@ package org.apache.tools.ant.types; * @author Magesh Umasankar */ public interface Parameterizable { + /** + * Set the parameters + * + * @param parameters an array of name/type/value parameters. + */ void setParameters(Parameter[] parameters); } diff --git a/src/main/org/apache/tools/ant/types/ResourceLocation.java b/src/main/org/apache/tools/ant/types/ResourceLocation.java index e41a82c73..8805729ec 100644 --- a/src/main/org/apache/tools/ant/types/ResourceLocation.java +++ b/src/main/org/apache/tools/ant/types/ResourceLocation.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ public class ResourceLocation { /** * name of the catalog entry type, as per OASIS spec. */ - protected String name = null; + private String name = null; /** publicId of the dtd/entity. */ private String publicId = null; diff --git a/src/main/org/apache/tools/ant/types/selectors/AndSelector.java b/src/main/org/apache/tools/ant/types/selectors/AndSelector.java index 4a5d371d0..cafb0791f 100644 --- a/src/main/org/apache/tools/ant/types/selectors/AndSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/AndSelector.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,6 +72,9 @@ public class AndSelector extends BaseSelectorContainer { public AndSelector() { } + /** + * @return a string representation of the selector + */ public String toString() { StringBuffer buf = new StringBuffer(); if (hasSelectors()) { diff --git a/src/main/org/apache/tools/ant/types/selectors/FileSelector.java b/src/main/org/apache/tools/ant/types/selectors/FileSelector.java index eddfb512d..038e95b27 100644 --- a/src/main/org/apache/tools/ant/types/selectors/FileSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/FileSelector.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -78,7 +78,7 @@ public interface FileSelector { * @return whether the file should be selected or not * @exception BuildException if the selector was not configured correctly */ - public boolean isSelected(File basedir, String filename, File file) + boolean isSelected(File basedir, String filename, File file) throws BuildException; } diff --git a/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java b/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java index 1966dbc81..6069ada1a 100644 --- a/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -73,6 +73,9 @@ public class NoneSelector extends BaseSelectorContainer { public NoneSelector() { } + /** + * @return a string representation of the selector + */ public String toString() { StringBuffer buf = new StringBuffer(); if (hasSelectors()) { diff --git a/src/main/org/apache/tools/ant/types/selectors/NotSelector.java b/src/main/org/apache/tools/ant/types/selectors/NotSelector.java index f769a72cf..274af19c9 100644 --- a/src/main/org/apache/tools/ant/types/selectors/NotSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/NotSelector.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,6 +72,9 @@ public class NotSelector extends NoneSelector { public NotSelector() { } + /** + * @return a string representation of the selector + */ public String toString() { StringBuffer buf = new StringBuffer(); if (hasSelectors()) { @@ -88,8 +91,8 @@ public class NotSelector extends NoneSelector { */ public void verifySettings() { if (selectorCount() != 1) { - setError("One and only one selector is allowed within the " + - " tag"); + setError("One and only one selector is allowed within the " + + " tag"); } } diff --git a/src/main/org/apache/tools/ant/types/selectors/OrSelector.java b/src/main/org/apache/tools/ant/types/selectors/OrSelector.java index 064aec47f..bd9bdbd24 100644 --- a/src/main/org/apache/tools/ant/types/selectors/OrSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/OrSelector.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,6 +72,9 @@ public class OrSelector extends BaseSelectorContainer { public OrSelector() { } + /** + * @return a string representation of the selector + */ public String toString() { StringBuffer buf = new StringBuffer(); if (hasSelectors()) { diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index c6fd55982..a73feba51 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -165,9 +165,15 @@ public class FileUtils { * Convienence method to copy a file from a source to a destination. * No filtering is performed. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * + * @throws IOException if the copying fails */ - public void copyFile(String sourceFile, String destFile) throws IOException { + public void copyFile(String sourceFile, String destFile) + throws IOException { copyFile(new File(sourceFile), new File(destFile), null, false, false); } @@ -175,11 +181,19 @@ public class FileUtils { * Convienence method to copy a file from a source to a destination * specifying if token filtering must be used. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * + * @throws IOException if the copying fails */ - public void copyFile(String sourceFile, String destFile, FilterSetCollection filters) + public void copyFile(String sourceFile, String destFile, + FilterSetCollection filters) throws IOException { - copyFile(new File(sourceFile), new File(destFile), filters, false, false); + copyFile(new File(sourceFile), new File(destFile), filters, + false, false); } /** @@ -187,7 +201,15 @@ public class FileUtils { * destination specifying if token filtering must be used and if * source files may overwrite newer destination files. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * + * @throws IOException if the copying fails */ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite) throws IOException { @@ -202,7 +224,18 @@ public class FileUtils { * last modified time of destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * + * @throws IOException if the copying fails */ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified) @@ -218,9 +251,21 @@ public class FileUtils { * last modified time of destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param encoding the encoding used to read and write the files. + * + * @throws IOException if the copying fails * - * @since 1.14, Ant 1.5 + * @since Ant 1.5 */ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, @@ -238,9 +283,23 @@ public class FileUtils { * destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param filterChains filterChains to apply during the copy. + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param encoding the encoding used to read and write the files. + * @param project the project instance + * + * @throws IOException if the copying fails * - * @since 1.15, Ant 1.5 + * @since Ant 1.5 */ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, Vector filterChains, @@ -260,7 +319,22 @@ public class FileUtils { * destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile Name of file to copy from. + * Must not be null. + * @param destFile Name of file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param filterChains filterChains to apply during the copy. + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param inputEncoding the encoding used to read the files. + * @param outputEncoding the encoding used to write the files. + * @param project the project instance + * + * @throws IOException if the copying fails * * @since Ant 1.6 */ @@ -279,7 +353,12 @@ public class FileUtils { * Convienence method to copy a file from a source to a destination. * No filtering is performed. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * + * @throws IOException if the copying fails */ public void copyFile(File sourceFile, File destFile) throws IOException { copyFile(sourceFile, destFile, null, false, false); @@ -289,7 +368,13 @@ public class FileUtils { * Convienence method to copy a file from a source to a destination * specifying if token filtering must be used. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * + * @throws IOException if the copying fails */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters) throws IOException { @@ -301,7 +386,15 @@ public class FileUtils { * destination specifying if token filtering must be used and if * source files may overwrite newer destination files. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * + * @throws IOException if the copying fails */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite) throws IOException { @@ -315,7 +408,18 @@ public class FileUtils { * last modified time of destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * + * @throws IOException if the copying fails */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified) @@ -332,9 +436,21 @@ public class FileUtils { * equal to the last modified time of sourceFile and * which character encoding to assume. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param encoding the encoding used to read and write the files. + * + * @throws IOException if the copying fails * - * @since 1.14, Ant 1.5 + * @since Ant 1.5 */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, @@ -352,9 +468,23 @@ public class FileUtils { * destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param filterChains filterChains to apply during the copy. + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param encoding the encoding used to read and write the files. + * @param project the project instance * - * @since 1.15, Ant 1.5 + * @throws IOException if the copying fails + * + * @since Ant 1.5 */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, @@ -373,9 +503,25 @@ public class FileUtils { * destFile file should be made equal * to the last modified time of sourceFile. * - * @throws IOException + * @param sourceFile the file to copy from. + * Must not be null. + * @param destFile the file to copy to. + * Must not be null. + * @param filters the collection of filters to apply to this copy + * @param filterChains filterChains to apply during the copy. + * @param overwrite Whether or not the destination file should be + * overwritten if it already exists. + * @param preserveLastModified Whether or not the last modified time of + * the resulting file should be set to that + * of the source file. + * @param inputEncoding the encoding used to read the files. + * @param outputEncoding the encoding used to write the files. + * @param project the project instance * - * @since 1.15, Ant 1.6 + * + * @throws IOException if the copying fails + * + * @since Ant 1.6 */ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, @@ -384,8 +530,8 @@ public class FileUtils { Project project) throws IOException { - if (overwrite || !destFile.exists() || - destFile.lastModified() < sourceFile.lastModified()) { + if (overwrite || !destFile.exists() + || destFile.lastModified() < sourceFile.lastModified()) { if (destFile.exists() && destFile.isFile()) { destFile.delete(); @@ -411,19 +557,19 @@ public class FileUtils { if (inputEncoding == null) { in = new BufferedReader(new FileReader(sourceFile)); } else { - in = - new BufferedReader(new InputStreamReader( - new FileInputStream(sourceFile), - inputEncoding)); + InputStreamReader isr + = new InputStreamReader(new FileInputStream(sourceFile), + inputEncoding); + in = new BufferedReader(isr); } if (outputEncoding == null) { out = new BufferedWriter(new FileWriter(destFile)); } else { - out = - new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(destFile), - outputEncoding)); + OutputStreamWriter osw + = new OutputStreamWriter(new FileOutputStream(destFile), + outputEncoding); + out = new BufferedWriter(osw); } if (filterChainsAvailable) { @@ -442,7 +588,8 @@ public class FileUtils { String line = lineTokenizer.getToken(in); while (line != null) { if (line.length() == 0) { - // this should not happen, because the lines are returned with the end of line delimiter + // this should not happen, because the lines are + // returned with the end of line delimiter out.newLine(); } else { newline = filters.replaceTokens(line); @@ -495,7 +642,7 @@ public class FileUtils { Reader rdr = crh.getAssembledReader(); in = new BufferedReader(rdr); } - char buffer[] = new char[1024*8]; + char[] buffer = new char[1024 * 8]; while (true) { int nRead = in.read(buffer, 0, buffer.length); if (nRead == -1) { @@ -542,6 +689,8 @@ public class FileUtils { /** * see whether we have a setLastModified method in File and return it. + * + * @return a method to setLastModified. */ protected final Method getSetLastModified() { if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { @@ -564,8 +713,14 @@ public class FileUtils { /** * Calls File.setLastModified(long time) in a Java 1.1 compatible way. + * + * @param file the file whose modified time is to be set + * @param time the time to which the last modified time is to be set. + * + * @throws BuildException if the time cannot be set. */ - public void setFileLastModified(File file, long time) throws BuildException { + public void setFileLastModified(File file, long time) + throws BuildException { if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { return; } @@ -665,6 +820,9 @@ public class FileUtils { * \ as the separator. * * + * @param path the path to be normalized + * @param the normalized version of the path. + * * @throws java.lang.NullPointerException if the file path is * equal to null. */ @@ -678,10 +836,10 @@ public class FileUtils { int colon = path.indexOf(":"); if (!onNetWare) { - if (!path.startsWith(File.separator) && - !(path.length() >= 2 && - Character.isLetter(path.charAt(0)) && - colon == 1)) { + if (!path.startsWith(File.separator) + && !(path.length() >= 2 + && Character.isLetter(path.charAt(0)) + && colon == 1)) { String msg = path + " is not an absolute path"; throw new BuildException(msg); } @@ -696,11 +854,10 @@ public class FileUtils { boolean dosWithDrive = false; String root = null; // Eliminate consecutive slashes after the drive spec - if ((!onNetWare && - path.length() >= 2 && - Character.isLetter(path.charAt(0)) && - path.charAt(1) == ':') || - (onNetWare && colon > -1)) { + if ((!onNetWare && path.length() >= 2 + && Character.isLetter(path.charAt(0)) + && path.charAt(1) == ':') + || (onNetWare && colon > -1)) { dosWithDrive = true; @@ -792,6 +949,7 @@ public class FileUtils { * current working directory will be assumed if this parameter is * null. * + * @return a File reference to the new temporary file. * @since ant 1.5 */ public File createTempFile(String prefix, String suffix, File parentDir) { @@ -820,6 +978,13 @@ public class FileUtils { * buffers followed by long comparisions apart from the final 1-7 * bytes.

* + * @param f1 the file whose content is to be compared. + * @param f2 the other file whose content is to be compared. + * + * @return true if the content of the files is the same. + * + * @throws IOException if the files cannot be read. + * * @since 1.9 */ public boolean contentEquals(File f1, File f2) throws IOException { @@ -885,6 +1050,10 @@ public class FileUtils { /** * Emulation of File.getParentFile for JDK 1.1 * + * + * @param f the file whose parent is required. + * @return the given file's parent, or null if the file does not have a + * parent. * @since 1.10 */ public File getParentFile(File f) { @@ -899,6 +1068,11 @@ public class FileUtils { /** * Read from reader till EOF + * @param rdr the reader from which to read. + * @return the contents read out of the given reader + * + * @throws IOException if the contents could not be read out from the + * reader. */ public static final String readFully(Reader rdr) throws IOException { return readFully(rdr, 8192); @@ -906,8 +1080,17 @@ public class FileUtils { /** * Read from reader till EOF + * + * @param rdr the reader from which to read. + * @param bufferSize the buffer size to use when reading + * + * @return the contents read out of the given reader + * + * @throws IOException if the contents could not be read out from the + * reader. */ - public static final String readFully(Reader rdr, int bufferSize) throws IOException { + public static final String readFully(Reader rdr, int bufferSize) + throws IOException { if (bufferSize <= 0) { throw new IllegalArgumentException("Buffer size must be greater " + "than 0"); @@ -939,7 +1122,9 @@ public class FileUtils { *

This method does not guarantee that the * operation is atomic.

* - * @since 1.21, Ant 1.5 + * @param f the file to be created + * @return true if the file did not exist already. + * @since Ant 1.5 */ public boolean createNewFile(File f) throws IOException { if (f != null) { @@ -972,6 +1157,7 @@ public class FileUtils { * @param parent the parent directory of the file to test * @param name the name of the file to test. * + * @return true if the file is a symbolic link. * @since Ant 1.5 */ public boolean isSymbolicLink(File parent, String name) @@ -1018,6 +1204,8 @@ public class FileUtils { * *

This code doesn't handle non-ASCII characters properly.

* + * @param path the path in the local file system + * @return the URI version of the local path. * @since Ant 1.6 */ public String toURI(String path) { @@ -1065,6 +1253,8 @@ public class FileUtils { *

Swallows '%' that are not followed by two characters, * doesn't deal with non-ASCII characters.

* + * @param uri the URI designating a file in the local filesystem. + * @return the local file system path for the file. * @since Ant 1.6 */ public String fromURI(String uri) { @@ -1119,6 +1309,11 @@ public class FileUtils { * the absolute paths and "normalize" the filenames * before comparing them.

* + * @param f1 the file whose name is to be compared. + * @param f2 the other file whose name is to be compared. + * + * @return true if the file are for the same file. + * * @since Ant 1.5.3 */ public boolean fileNameEquals(File f1, File f2) { diff --git a/src/main/org/apache/tools/ant/util/TimeoutObserver.java b/src/main/org/apache/tools/ant/util/TimeoutObserver.java index cf095e8cd..4da170dc0 100644 --- a/src/main/org/apache/tools/ant/util/TimeoutObserver.java +++ b/src/main/org/apache/tools/ant/util/TimeoutObserver.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2002 The Apache Software Foundation. All rights + * Copyright (c) 2002-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,10 @@ package org.apache.tools.ant.util; */ public interface TimeoutObserver { + /** + * Called when the watchdow times out. + * + * @param w the watchdog that timed out. + */ void timeoutOccured(Watchdog w); - }