Browse Source

style fixes

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274441 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
a602511573
10 changed files with 110 additions and 60 deletions
  1. +7
    -7
      check.xml
  2. +1
    -2
      src/main/org/apache/tools/ant/IntrospectionHelper.java
  3. +48
    -33
      src/main/org/apache/tools/ant/Project.java
  4. +14
    -0
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  5. +2
    -1
      src/main/org/apache/tools/ant/filters/BaseFilterReader.java
  6. +6
    -5
      src/main/org/apache/tools/ant/filters/EscapeUnicode.java
  7. +2
    -1
      src/main/org/apache/tools/ant/filters/StripLineComments.java
  8. +2
    -1
      src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
  9. +2
    -1
      src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
  10. +26
    -9
      src/main/org/apache/tools/ant/taskdefs/Parallel.java

+ 7
- 7
check.xml View File

@@ -1,20 +1,20 @@
<project default="checkstyle" name="CheckAnt">
<property name="java.dir" value="src/main"/>
<property name="tocheck" value="**/*.java"/>
<property name="tocheck" value="**/*.java"/>
<property name="javadoc.scope" value="public"/>
<target name="checkstyle">
<taskdef name="checkstyle"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/>
<checkstyle>
<property key="checkstyle.header.file" file="src/etc/RequiredHeader.txt"/>
<property key="checkstyle.header.ignoreline" value="4"/>
<property key="checkstyle.javadoc.scope" value="${javadoc.scope}"/>
<checkstyle headerFile="src/etc/RequiredHeader.txt"
headerIgnoreLine="4"
allowProtected="true"
javadocScope="${javadoc.scope}">
<fileset dir="${java.dir}">
<include name="${tocheck}"/>
</fileset>
</checkstyle>
</target>
</project>


+ 1
- 2
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -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.";


+ 48
- 33
src/main/org/apache/tools/ant/Project.java View File

@@ -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;
}

}
}

+ 14
- 0
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -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;


+ 2
- 1
src/main/org/apache/tools/ant/filters/BaseFilterReader.java View File

@@ -143,7 +143,8 @@ public abstract class BaseFilterReader
* @exception IllegalArgumentException If <code>n</code> 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");
}


+ 6
- 5
src/main/org/apache/tools/ant/filters/EscapeUnicode.java View File

@@ -66,8 +66,9 @@ import org.apache.tools.ant.types.Parameter;
*
* Or:
*
* <pre>&lt;filterreader classname=&quot;org.apache.tools.ant.filters.EscapeUnicode&quot;/&gt;
* </pre>
* <pre>&lt;filterreader
classname=&quot;org.apache.tools.ant.filters.EscapeUnicode&quot;/&gt;
* </pre>
*
* @author <a href="mailto:levylambert@tiscali-dsl.de">Antoine Levy-Lambert</a>
* @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 {


+ 2
- 1
src/main/org/apache/tools/ant/filters/StripLineComments.java View File

@@ -73,7 +73,8 @@ import org.apache.tools.ant.types.Parameter;
*
* Or:
*
* <pre>&lt;filterreader classname=&quot;org.apache.tools.ant.filters.StripLineComments&quot;&gt;
* <pre>&lt;filterreader
* classname=&quot;org.apache.tools.ant.filters.StripLineComments&quot;&gt;
* &lt;param type=&quot;comment&quot; value="#&quot;/&gt;
* &lt;param type=&quot;comment&quot; value=&quot;--&quot;/&gt;
* &lt;param type=&quot;comment&quot; value=&quot;REM &quot;/&gt;


+ 2
- 1
src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java View File

@@ -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();


+ 2
- 1
src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java View File

@@ -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;


+ 26
- 9
src/main/org/apache/tools/ant/taskdefs/Parallel.java View File

@@ -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 <code>threadCount</code>
* tasks will be executed at one time. If <code>threadsPerProcessor</code>
* 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 = {};


Loading…
Cancel
Save