From a60251157378e7231a85b7e3d1e5cf972a646f78 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Mon, 14 Apr 2003 11:58:04 +0000 Subject: [PATCH] style fixes git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274441 13f79535-47bb-0310-9956-ffa450edef68 --- check.xml | 14 ++-- .../apache/tools/ant/IntrospectionHelper.java | 3 +- src/main/org/apache/tools/ant/Project.java | 81 +++++++++++-------- .../apache/tools/ant/RuntimeConfigurable.java | 14 ++++ .../tools/ant/filters/BaseFilterReader.java | 3 +- .../tools/ant/filters/EscapeUnicode.java | 11 +-- .../tools/ant/filters/StripLineComments.java | 3 +- .../ant/filters/util/ChainReaderHelper.java | 3 +- .../tools/ant/helper/ProjectHelperImpl.java | 3 +- .../apache/tools/ant/taskdefs/Parallel.java | 35 +++++--- 10 files changed, 110 insertions(+), 60 deletions(-) diff --git a/check.xml b/check.xml index bdadc62e9..91ccf4168 100755 --- a/check.xml +++ b/check.xml @@ -1,20 +1,20 @@ - + - + - - - - + - + diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index 2ef44675b..2f826ecf4 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -436,8 +436,7 @@ public class IntrospectionHelper implements BuildListener { DynamicConfigurator dc = (DynamicConfigurator) element; dc.setDynamicAttribute(attributeName, value); return; - } - else { + } else { String msg = getElementName(p, element) + " doesn't support the \"" + attributeName + "\" attribute."; diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 7e55affdf..c9483afbc 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -903,8 +903,7 @@ public class Project { && oldLoader instanceof AntClassLoader && newLoader instanceof AntClassLoader && ((AntClassLoader) oldLoader).getClasspath() - .equals(((AntClassLoader) newLoader).getClasspath()) - ) { + .equals(((AntClassLoader) newLoader).getClasspath())) { // same classname loaded from the same // classpath components logLevel = MSG_VERBOSE; @@ -2071,7 +2070,7 @@ public class Project { int priority) { event.setMessage(message, priority); Vector listeners = getBuildListeners(); - synchronized(this) { + synchronized (this) { if (loggingMessage) { throw new BuildException("Listener attempted to access " + (priority == MSG_ERR ? "System.err" : "System.out") @@ -2171,7 +2170,7 @@ public class Project { // Should move to a separate public class - and have API to add // listeners, etc. private static class AntRefTable extends Hashtable { - Project project; + private Project project; public AntRefTable(Project project) { super(); this.project = project; @@ -2212,9 +2211,9 @@ public class Project { } private static class AntTaskTable extends LazyHashtable { - Project project; - Properties props; - boolean tasks = false; + private Project project; + private Properties props; + private boolean tasks = false; public AntTaskTable(Project p, boolean tasks) { this.project = p; @@ -2226,46 +2225,57 @@ public class Project { } protected void initAll() { - if (initAllDone ) return; + if (initAllDone) { + return; + } project.log("InitAll", Project.MSG_DEBUG); - if (props==null ) return; + if (props == null) { + return; + } Enumeration enum = props.propertyNames(); while (enum.hasMoreElements()) { String key = (String) enum.nextElement(); - Class taskClass=getTask( key ); - if (taskClass!=null ) { + Class taskClass = getTask(key); + if (taskClass != null) { // This will call a get() and a put() - if (tasks ) + if (tasks) { project.addTaskDefinition(key, taskClass); - else - project.addDataTypeDefinition(key, taskClass ); + } else { + project.addDataTypeDefinition(key, taskClass); + } } } - initAllDone=true; + initAllDone = true; } protected Class getTask(String key) { - if (props==null ) return null; // for tasks loaded before init() - String value=props.getProperty(key); - if (value==null) { - //project.log( "No class name for " + key, Project.MSG_VERBOSE ); + if (props == null) { + return null; // for tasks loaded before init() + } + String value = props.getProperty(key); + if (value == null) { + //project.log( "No class name for " + key, Project.MSG_VERBOSE); return null; } try { - Class taskClass=null; + Class taskClass = null; if (project.getCoreLoader() != null && !("only".equals(project.getProperty("build.sysclasspath")))) { try { - taskClass=project.getCoreLoader().loadClass(value); - if (taskClass != null ) return taskClass; - } catch( Exception ex ) { + taskClass = project.getCoreLoader().loadClass(value); + if (taskClass != null) { + return taskClass; + } + } catch (Exception ex) { + // ignore } } taskClass = Class.forName(value); return taskClass; } catch (NoClassDefFoundError ncdfe) { project.log("Could not load a dependent class (" - + ncdfe.getMessage() + ") for task " + key, Project.MSG_DEBUG); + + ncdfe.getMessage() + ") for task " + + key, Project.MSG_DEBUG); } catch (ClassNotFoundException cnfe) { project.log("Could not load class (" + value + ") for task " + key, Project.MSG_DEBUG); @@ -2274,20 +2284,25 @@ public class Project { } // Hashtable implementation - public Object get( Object key ) { - Object orig=super.get( key ); - if (orig!= null ) return orig; - if (! (key instanceof String) ) return null; - project.log("Get task " + key, Project.MSG_DEBUG ); - Object taskClass=getTask( (String) key); - if (taskClass != null) - super.put( key, taskClass ); + public Object get(Object key) { + Object orig = super.get(key); + if (orig != null) { + return orig; + } + if (!(key instanceof String)) { + return null; + } + + project.log("Get task " + key, Project.MSG_DEBUG); + Object taskClass = getTask((String) key); + if (taskClass != null) { + super.put(key, taskClass); + } return taskClass; } public boolean containsKey(Object key) { return get(key) != null; } - } } diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java index 5ba0a67c3..8ca8cfcaa 100644 --- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -133,6 +133,12 @@ public class RuntimeConfigurable implements Serializable { proxyConfigured = false; } + /** + * Get the object for which this RuntimeConfigurable holds the configuration + * information + * + * @return the object whose configure is held by this instance. + */ public Object getProxy() { return wrappedObject; } @@ -151,6 +157,12 @@ public class RuntimeConfigurable implements Serializable { } } + /** + * Set an attribute to a given value + * + * @param name the name of the attribute. + * @param value the attribute's value. + */ public void setAttribute(String name, String value) { attributeNames.addElement(name); attributeMap.put(name, value); @@ -357,6 +369,8 @@ public class RuntimeConfigurable implements Serializable { /** * Reconfigure the element, even if it has already been configured. + * + * @param p the project instance for this configuration. */ public void reconfigure(Project p) { proxyConfigured = false; diff --git a/src/main/org/apache/tools/ant/filters/BaseFilterReader.java b/src/main/org/apache/tools/ant/filters/BaseFilterReader.java index db22ceb78..5c141fd7f 100644 --- a/src/main/org/apache/tools/ant/filters/BaseFilterReader.java +++ b/src/main/org/apache/tools/ant/filters/BaseFilterReader.java @@ -143,7 +143,8 @@ public abstract class BaseFilterReader * @exception IllegalArgumentException If n is negative. * @exception IOException If an I/O error occurs */ - public final long skip(final long n) throws IOException { + public final long skip(final long n) + throws IOException, IllegalArgumentException { if (n < 0L) { throw new IllegalArgumentException("skip value is negative"); } diff --git a/src/main/org/apache/tools/ant/filters/EscapeUnicode.java b/src/main/org/apache/tools/ant/filters/EscapeUnicode.java index 3eea26a0e..2d6339774 100644 --- a/src/main/org/apache/tools/ant/filters/EscapeUnicode.java +++ b/src/main/org/apache/tools/ant/filters/EscapeUnicode.java @@ -66,8 +66,9 @@ import org.apache.tools.ant.types.Parameter; * * Or: * - *
<filterreader classname="org.apache.tools.ant.filters.EscapeUnicode"/>
-*  
+ *
<filterreader 
+        classname="org.apache.tools.ant.filters.EscapeUnicode"/>
+ *  
* * @author Antoine Levy-Lambert * @since Ant 1.6 @@ -107,7 +108,7 @@ public class EscapeUnicode * @return the next character in the resulting stream, or -1 * if the end of the resulting stream has been reached * - * @exception java.io.IOException if the underlying stream throws + * @exception IOException if the underlying stream throws * an IOException during reading */ public final int read() throws IOException { @@ -116,7 +117,7 @@ public class EscapeUnicode setInitialized(true); } - int ch= - 1; + int ch = -1; if (unicodeBuf.length() == 0) { ch = in.read(); if (ch != -1) { @@ -130,7 +131,7 @@ public class EscapeUnicode - s.length() + i, s.charAt(i)); } - ch='\\'; + ch = '\\'; } } } else { diff --git a/src/main/org/apache/tools/ant/filters/StripLineComments.java b/src/main/org/apache/tools/ant/filters/StripLineComments.java index f7ad7a746..1caf7dfe2 100644 --- a/src/main/org/apache/tools/ant/filters/StripLineComments.java +++ b/src/main/org/apache/tools/ant/filters/StripLineComments.java @@ -73,7 +73,8 @@ import org.apache.tools.ant.types.Parameter; * * Or: * - *
<filterreader classname="org.apache.tools.ant.filters.StripLineComments">
+ * 
<filterreader 
+ *      classname="org.apache.tools.ant.filters.StripLineComments">
  *   <param type="comment" value="#"/>
  *   <param type="comment" value="--"/>
  *   <param type="comment" value="REM "/>
diff --git a/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java b/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
index 0dd5037ab..b2d8802e7 100644
--- a/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
+++ b/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
@@ -161,7 +161,8 @@ public final class ChainReaderHelper {
                 Object o = finalFilters.elementAt(i);
 
                 if (o instanceof AntFilterReader) {
-                    final AntFilterReader filter = (AntFilterReader) finalFilters.elementAt(i);
+                    final AntFilterReader filter 
+                        = (AntFilterReader) finalFilters.elementAt(i);
                     final String className = filter.getClassName();
                     final Path classpath = filter.getClasspath();
                     final Project project = filter.getProject();
diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
index f42ff7f00..999257c0d 100644
--- a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
+++ b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
@@ -135,7 +135,8 @@ public class ProjectHelperImpl extends ProjectHelper {
      */
     public void parse(Project project, Object source) throws BuildException {
         if (!(source instanceof File)) {
-            throw new BuildException("Only File source supported by default plugin");
+            throw new BuildException("Only File source supported by " 
+                + "default plugin");
         }
         File buildFile = (File) source;
         FileInputStream inputStream = null;
diff --git a/src/main/org/apache/tools/ant/taskdefs/Parallel.java b/src/main/org/apache/tools/ant/taskdefs/Parallel.java
index 54f9613bb..f97729f11 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Parallel.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Parallel.java
@@ -92,19 +92,19 @@ public class Parallel extends Task
     private final Object semaphore = new Object();
     
     /** Total number of threads to run */
-    int numThreads = 0;
+    private int numThreads = 0;
     
     /** Total number of threads per processor to run.  */
-    int numThreadsPerProcessor = 0;
+    private int numThreadsPerProcessor = 0;
     
     /** Interval (in ms) to poll for finished threads. */
-    int pollInterval = 1000; // default is once a second
+    private int pollInterval = 1000; // default is once a second
 
     /**
      * Add a nested task to execute in parallel.
      * @param nestedTask  Nested task to be executed in parallel
      */
-    public void addTask(Task nestedTask) throws BuildException {
+    public void addTask(Task nestedTask) {
         nestedTasks.addElement(nestedTask);
     }
     
@@ -128,7 +128,8 @@ public class Parallel extends Task
      * simultaneously.  If there are less tasks than threads then all will be 
      * executed at once, if there are more then only threadCount 
      * tasks will be executed at one time.  If threadsPerProcessor 
-     * is set and the JVM is at least a 1.4 VM then this value is ignormed.; optional
+     * is set and the JVM is at least a 1.4 VM then this value is 
+     * ignored.; optional
      *
      * @param numThreads total number of therads.
      *
@@ -147,6 +148,11 @@ public class Parallel extends Task
         this.pollInterval = pollInterval;
     }
     
+    /**
+     * Execute the parallel tasks
+     *
+     * @exception BuildException if any of the threads failed.
+     */
     public void execute() throws BuildException {
         updateThreadCounts();
         if (numThreads == 0) {
@@ -155,6 +161,9 @@ public class Parallel extends Task
         spinThreads();
     }
     
+    /**
+     * Determine the number of threads based on the number of processors
+     */
     private void updateThreadCounts() {
         if (numThreadsPerProcessor != 0) {
             int numProcessors = getNumProcessors();
@@ -165,7 +174,9 @@ public class Parallel extends Task
     }
         
     /**
-     * Spin up threadCount threads.
+     * Spin up required threads with a maximum number active at any given time.
+     *
+     * @exception BuildException if any of the threads failed.
      */
     private void spinThreads() throws BuildException {
         final int numTasks = nestedTasks.size();
@@ -189,12 +200,13 @@ public class Parallel extends Task
         // now run them in limited numbers...
         outer:
         while (threadNumber < numTasks) {
-            synchronized(semaphore) {
+            synchronized (semaphore) {
                 for (int i = 0; i < maxRunning; i++) {
                     if (running[i] == null || !running[i].isAlive()) {
                         running[i] = threads[threadNumber++];
                         running[i].start();
-                        // countinue on outer while loop in case we used our last thread
+                        // countinue on outer while loop in case we 
+                        // used our last thread
                         continue outer;
                     }
                 }
@@ -252,7 +264,12 @@ public class Parallel extends Task
                                      firstLocation);
         }
     }
-        
+     
+    /**
+     * Determine the number of processors. Only effective on later VMs
+     *
+     * @return the number of processors available or 0 if not determinable.
+     */
     private int getNumProcessors() {
         try {
             Class[] paramTypes = {};