Browse Source

checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274945 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 22 years ago
parent
commit
d589263f67
8 changed files with 73 additions and 18 deletions
  1. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/Antlib.java
  2. +5
    -2
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  3. +34
    -3
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  4. +5
    -0
      src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  5. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Parallel.java
  6. +10
    -3
      src/main/org/apache/tools/ant/taskdefs/Patch.java
  7. +11
    -1
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  8. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetDefine.java

+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/Antlib.java View File

@@ -65,7 +65,6 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location; import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.helper.ProjectHelper2; import org.apache.tools.ant.helper.ProjectHelper2;
import org.apache.tools.ant.UnknownElement; import org.apache.tools.ant.UnknownElement;


@@ -104,13 +103,13 @@ public class Antlib extends Task implements TaskContainer {
// Should be safe to parse // Should be safe to parse
try { try {
ProjectHelper2 parser = new ProjectHelper2(); ProjectHelper2 parser = new ProjectHelper2();
UnknownElement ue =
UnknownElement ue =
parser.parseUnknownElement(project, antlibUrl); parser.parseUnknownElement(project, antlibUrl);
// Check name is "antlib" // Check name is "antlib"
if (!(ue.getTag().equals(TAG))) { if (!(ue.getTag().equals(TAG))) {
throw new BuildException( throw new BuildException(
"Unexpected tag " + ue.getTag() + " expecting " +
TAG, ue.getLocation());
"Unexpected tag " + ue.getTag() + " expecting "
+ TAG, ue.getLocation());
} }
Antlib antlib = new Antlib(); Antlib antlib = new Antlib();
antlib.setProject(project); antlib.setProject(project);


+ 5
- 2
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -101,6 +101,9 @@ import org.apache.tools.ant.util.FileUtils;
* @author Peter Reilly * @author Peter Reilly
*/ */
public class Concat extends Task { public class Concat extends Task {
// The size of buffers to be used
private static final int BUFFER_SIZE = 8192;


// Attributes. // Attributes.


@@ -442,7 +445,7 @@ public class Concat extends Task {
private void cat() { private void cat() {
OutputStream os = null; OutputStream os = null;
Reader reader = null; Reader reader = null;
char[] buffer = new char[8192];
char[] buffer = new char[BUFFER_SIZE];


try { try {


@@ -535,7 +538,7 @@ public class Concat extends Task {
throws IOException { throws IOException {
if (filterChains != null) { if (filterChains != null) {
ChainReaderHelper helper = new ChainReaderHelper(); ChainReaderHelper helper = new ChainReaderHelper();
helper.setBufferSize(8192);
helper.setBufferSize(BUFFER_SIZE);
helper.setPrimaryReader(in); helper.setPrimaryReader(in);
helper.setFilterChains(filterChains); helper.setFilterChains(filterChains);
helper.setProject(getProject()); helper.setProject(getProject());


+ 34
- 3
src/main/org/apache/tools/ant/taskdefs/Delete.java View File

@@ -100,6 +100,7 @@ import org.apache.tools.ant.types.selectors.FileSelector;
* @ant.task category="filesystem" * @ant.task category="filesystem"
*/ */
public class Delete extends MatchingTask { public class Delete extends MatchingTask {
private static final int DELETE_RETRY_SLEEP_MILLIS = 10;
protected File file = null; protected File file = null;
protected File dir = null; protected File dir = null;
protected Vector filesets = new Vector(); protected Vector filesets = new Vector();
@@ -170,20 +171,24 @@ public class Delete extends MatchingTask {


/** /**
* If true, delete empty directories. * If true, delete empty directories.
* @param includeEmpty if true delete empty directories (only
* for filesets). Default is false.
*/ */
public void setIncludeEmptyDirs(boolean includeEmpty) { public void setIncludeEmptyDirs(boolean includeEmpty) {
this.includeEmpty = includeEmpty; this.includeEmpty = includeEmpty;
} }


/** /**
* Adds a set of files to be deleted.
*/
* Adds a set of files to be deleted.
* @param set the set of files to be deleted
*/
public void addFileset(FileSet set) { public void addFileset(FileSet set) {
filesets.addElement(set); filesets.addElement(set);
} }


/** /**
* add a name entry on the include list * add a name entry on the include list
* @return a NameEntry object to be configured
*/ */
public PatternSet.NameEntry createInclude() { public PatternSet.NameEntry createInclude() {
usedMatchingTask = true; usedMatchingTask = true;
@@ -192,6 +197,7 @@ public class Delete extends MatchingTask {


/** /**
* add a name entry on the include files list * add a name entry on the include files list
* @return an NameEntry object to be configured
*/ */
public PatternSet.NameEntry createIncludesFile() { public PatternSet.NameEntry createIncludesFile() {
usedMatchingTask = true; usedMatchingTask = true;
@@ -200,6 +206,7 @@ public class Delete extends MatchingTask {


/** /**
* add a name entry on the exclude list * add a name entry on the exclude list
* @return an NameEntry object to be configured
*/ */
public PatternSet.NameEntry createExclude() { public PatternSet.NameEntry createExclude() {
usedMatchingTask = true; usedMatchingTask = true;
@@ -208,6 +215,7 @@ public class Delete extends MatchingTask {


/** /**
* add a name entry on the include files list * add a name entry on the include files list
* @return an NameEntry object to be configured
*/ */
public PatternSet.NameEntry createExcludesFile() { public PatternSet.NameEntry createExcludesFile() {
usedMatchingTask = true; usedMatchingTask = true;
@@ -216,6 +224,7 @@ public class Delete extends MatchingTask {


/** /**
* add a set of patterns * add a set of patterns
* @return PatternSet object to be configured
*/ */
public PatternSet createPatternSet() { public PatternSet createPatternSet() {
usedMatchingTask = true; usedMatchingTask = true;
@@ -301,6 +310,7 @@ public class Delete extends MatchingTask {


/** /**
* add a "Select" selector entry on the selector list * add a "Select" selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addSelector(SelectSelector selector) { public void addSelector(SelectSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -309,6 +319,7 @@ public class Delete extends MatchingTask {


/** /**
* add an "And" selector entry on the selector list * add an "And" selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addAnd(AndSelector selector) { public void addAnd(AndSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -317,6 +328,7 @@ public class Delete extends MatchingTask {


/** /**
* add an "Or" selector entry on the selector list * add an "Or" selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addOr(OrSelector selector) { public void addOr(OrSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -325,6 +337,7 @@ public class Delete extends MatchingTask {


/** /**
* add a "Not" selector entry on the selector list * add a "Not" selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addNot(NotSelector selector) { public void addNot(NotSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -333,6 +346,7 @@ public class Delete extends MatchingTask {


/** /**
* add a "None" selector entry on the selector list * add a "None" selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addNone(NoneSelector selector) { public void addNone(NoneSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -341,6 +355,7 @@ public class Delete extends MatchingTask {


/** /**
* add a majority selector entry on the selector list * add a majority selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addMajority(MajoritySelector selector) { public void addMajority(MajoritySelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -349,6 +364,7 @@ public class Delete extends MatchingTask {


/** /**
* add a selector date entry on the selector list * add a selector date entry on the selector list
* @param selector the selector to be added
*/ */
public void addDate(DateSelector selector) { public void addDate(DateSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -357,6 +373,7 @@ public class Delete extends MatchingTask {


/** /**
* add a selector size entry on the selector list * add a selector size entry on the selector list
* @param selector the selector to be added
*/ */
public void addSize(SizeSelector selector) { public void addSize(SizeSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -365,6 +382,7 @@ public class Delete extends MatchingTask {


/** /**
* add a selector filename entry on the selector list * add a selector filename entry on the selector list
* @param selector the selector to be added
*/ */
public void addFilename(FilenameSelector selector) { public void addFilename(FilenameSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -373,6 +391,7 @@ public class Delete extends MatchingTask {


/** /**
* add an extended selector entry on the selector list * add an extended selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addCustom(ExtendSelector selector) { public void addCustom(ExtendSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -381,6 +400,7 @@ public class Delete extends MatchingTask {


/** /**
* add a contains selector entry on the selector list * add a contains selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addContains(ContainsSelector selector) { public void addContains(ContainsSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -389,6 +409,7 @@ public class Delete extends MatchingTask {


/** /**
* add a present selector entry on the selector list * add a present selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addPresent(PresentSelector selector) { public void addPresent(PresentSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -397,6 +418,7 @@ public class Delete extends MatchingTask {


/** /**
* add a depth selector entry on the selector list * add a depth selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addDepth(DepthSelector selector) { public void addDepth(DepthSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -405,6 +427,7 @@ public class Delete extends MatchingTask {


/** /**
* add a depends selector entry on the selector list * add a depends selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addDepend(DependSelector selector) { public void addDepend(DependSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -413,6 +436,7 @@ public class Delete extends MatchingTask {


/** /**
* add a regular expression selector entry on the selector list * add a regular expression selector entry on the selector list
* @param selector the selector to be added
*/ */
public void addContainsRegexp(ContainsRegexpSelector selector) { public void addContainsRegexp(ContainsRegexpSelector selector) {
usedMatchingTask = true; usedMatchingTask = true;
@@ -421,6 +445,7 @@ public class Delete extends MatchingTask {


/** /**
* add an arbitary selector * add an arbitary selector
* @param selector the selector to be added
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void add(FileSelector selector) { public void add(FileSelector selector) {
@@ -430,6 +455,7 @@ public class Delete extends MatchingTask {


/** /**
* Delete the file(s). * Delete the file(s).
* @exception BuildException if an error occurs
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
if (usedMatchingTask) { if (usedMatchingTask) {
@@ -542,7 +568,7 @@ public class Delete extends MatchingTask {
private boolean delete(File f) { private boolean delete(File f) {
if (!f.delete()) { if (!f.delete()) {
try { try {
Thread.sleep(10);
Thread.sleep(DELETE_RETRY_SLEEP_MILLIS);
return f.delete(); return f.delete();
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
return f.delete(); return f.delete();
@@ -551,6 +577,11 @@ public class Delete extends MatchingTask {
return true; return true;
} }


/**
* Delete a directory
*
* @param d the directory to delete
*/
protected void removeDir(File d) { protected void removeDir(File d) {
String[] list = d.list(); String[] list = d.list();
if (list == null) { if (list == null) {


+ 5
- 0
src/main/org/apache/tools/ant/taskdefs/MatchingTask.java View File

@@ -111,6 +111,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {


/** /**
* add a name entry on the include list * add a name entry on the include list
* @return a NameEntry object to be configured
*/ */
public PatternSet.NameEntry createInclude() { public PatternSet.NameEntry createInclude() {
return fileset.createInclude(); return fileset.createInclude();
@@ -118,6 +119,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {


/** /**
* add a name entry on the include files list * add a name entry on the include files list
* @return an NameEntry object to be configured
*/ */
public PatternSet.NameEntry createIncludesFile() { public PatternSet.NameEntry createIncludesFile() {
return fileset.createIncludesFile(); return fileset.createIncludesFile();
@@ -125,6 +127,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {


/** /**
* add a name entry on the exclude list * add a name entry on the exclude list
* @return an NameEntry object to be configured
*/ */
public PatternSet.NameEntry createExclude() { public PatternSet.NameEntry createExclude() {
return fileset.createExclude(); return fileset.createExclude();
@@ -132,6 +135,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {


/** /**
* add a name entry on the include files list * add a name entry on the include files list
* @return an NameEntry object to be configured
*/ */
public PatternSet.NameEntry createExcludesFile() { public PatternSet.NameEntry createExcludesFile() {
return fileset.createExcludesFile(); return fileset.createExcludesFile();
@@ -139,6 +143,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {


/** /**
* add a set of patterns * add a set of patterns
* @return PatternSet object to be configured
*/ */
public PatternSet createPatternSet() { public PatternSet createPatternSet() {
return fileset.createPatternSet(); return fileset.createPatternSet();


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

@@ -250,7 +250,7 @@ public class Parallel extends Task
public synchronized void run() { public synchronized void run() {
try { try {
wait(timeout); wait(timeout);
synchronized(semaphore) {
synchronized (semaphore) {
stillRunning = false; stillRunning = false;
timedOut = true; timedOut = true;
semaphore.notifyAll(); semaphore.notifyAll();
@@ -290,7 +290,7 @@ public class Parallel extends Task
} }
} }


synchronized(semaphore) {
synchronized (semaphore) {
// are all threads finished // are all threads finished
outer2: outer2:
while (stillRunning) { while (stillRunning) {
@@ -318,7 +318,7 @@ public class Parallel extends Task
StringBuffer exceptionMessage = new StringBuffer(); StringBuffer exceptionMessage = new StringBuffer();
int numExceptions = 0; int numExceptions = 0;
Throwable firstException = null; Throwable firstException = null;
Location firstLocation = Location.UNKNOWN_LOCATION;;
Location firstLocation = Location.UNKNOWN_LOCATION;
for (int i = 0; i < numTasks; ++i) { for (int i = 0; i < numTasks; ++i) {
Throwable t = runnables[i].getException(); Throwable t = runnables[i].getException();
if (t != null) { if (t != null) {


+ 10
- 3
src/main/org/apache/tools/ant/taskdefs/Patch.java View File

@@ -80,6 +80,7 @@ public class Patch extends Task {
/** /**
* The file to patch; optional if it can be inferred from * The file to patch; optional if it can be inferred from
* the diff file * the diff file
* @param file the file to patch
*/ */
public void setOriginalfile(File file) { public void setOriginalfile(File file) {
originalFile = file; originalFile = file;
@@ -88,7 +89,7 @@ public class Patch extends Task {
/** /**
* The name of a file to send the output to, instead of patching * The name of a file to send the output to, instead of patching
* the file(s) in place; optional. * the file(s) in place; optional.
*
* @param file the file to send the output to
* @since Ant 1.6 * @since Ant 1.6
*/ */
public void setDestfile(File file) { public void setDestfile(File file) {
@@ -100,6 +101,7 @@ public class Patch extends Task {


/** /**
* The file containing the diff output; required. * The file containing the diff output; required.
* @param file the file containing the diff output
*/ */
public void setPatchfile(File file) { public void setPatchfile(File file) {
if (!file.exists()) { if (!file.exists()) {
@@ -113,6 +115,7 @@ public class Patch extends Task {


/** /**
* flag to create backups; optional, default=false * flag to create backups; optional, default=false
* @param backups if true create backups
*/ */
public void setBackups(boolean backups) { public void setBackups(boolean backups) {
if (backups) { if (backups) {
@@ -122,6 +125,7 @@ public class Patch extends Task {


/** /**
* flag to ignore whitespace differences; default=false * flag to ignore whitespace differences; default=false
* @param ignore if true ignore whitespace differences
*/ */
public void setIgnorewhitespace(boolean ignore) { public void setIgnorewhitespace(boolean ignore) {
if (ignore) { if (ignore) {
@@ -135,6 +139,7 @@ public class Patch extends Task {
* *
* <p>patch's <i>-p</i> option. * <p>patch's <i>-p</i> option.
* @param num number of lines to strip * @param num number of lines to strip
* @exception BuildException if num is < 0, or other errors
*/ */
public void setStrip(int num) throws BuildException { public void setStrip(int num) throws BuildException {
if (num < 0) { if (num < 0) {
@@ -145,6 +150,7 @@ public class Patch extends Task {


/** /**
* Work silently unless an error occurs; optional, default=false * Work silently unless an error occurs; optional, default=false
* @param q if true supress set the -s option on the patch command
*/ */
public void setQuiet(boolean q) { public void setQuiet(boolean q) {
if (q) { if (q) {
@@ -155,6 +161,7 @@ public class Patch extends Task {
/** /**
* Assume patch was created with old and new files swapped; optional, * Assume patch was created with old and new files swapped; optional,
* default=false * default=false
* @param r if true set the -R option on the patch command
*/ */
public void setReverse(boolean r) { public void setReverse(boolean r) {
if (r) { if (r) {
@@ -165,10 +172,10 @@ public class Patch extends Task {
/** /**
* The directory to run the patch command in, defaults to the * The directory to run the patch command in, defaults to the
* project's base directory. * project's base directory.
*
* @param directory the directory to run the patch command in
* @since Ant 1.5 * @since Ant 1.5
*/ */
public void setDir(File directory) throws BuildException {
public void setDir(File directory) {
this.directory = directory; this.directory = directory;
} }




+ 11
- 1
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -119,10 +119,18 @@ public class Replace extends MatchingTask {


private StringBuffer buf = new StringBuffer(); private StringBuffer buf = new StringBuffer();


/**
* the text of the element
*
* @param val the string to add
*/
public void addText(String val) { public void addText(String val) {
buf.append(val); buf.append(val);
} }


/**
* @return the text
*/
public String getText() { public String getText() {
return buf.substring(0); return buf.substring(0);
} }
@@ -183,6 +191,7 @@ public class Replace extends MatchingTask {


/** /**
* Get the replacement value for this filter token. * Get the replacement value for this filter token.
* @return the replacement value
*/ */
public String getReplaceValue() { public String getReplaceValue() {
if (property != null) { if (property != null) {
@@ -352,7 +361,7 @@ public class Replace extends MatchingTask {
/** /**
* helper method to load a properties file and throw a build exception * helper method to load a properties file and throw a build exception
* if it cannot be loaded * if it cannot be loaded
* @param propertyFile
* @param propertyFile the file to load the properties from
* @return loaded properties collection * @return loaded properties collection
* @throws BuildException if the file could not be found or read * @throws BuildException if the file could not be found or read
*/ */
@@ -600,6 +609,7 @@ public class Replace extends MatchingTask {


/** /**
* Add a nested &lt;replacefilter&gt; element. * Add a nested &lt;replacefilter&gt; element.
* @return a nested ReplaceFilter object to be configured
*/ */
public Replacefilter createReplacefilter() { public Replacefilter createReplacefilter() {
Replacefilter filter = new Replacefilter(); Replacefilter filter = new Replacefilter();


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/dotnet/DotnetDefine.java View File

@@ -71,7 +71,7 @@ public class DotnetDefine {
/** /**
* the name of a property which must be defined for * the name of a property which must be defined for
* the definition to be set. Optional. * the definition to be set. Optional.
* @param condition
* @param condition the name of the property
*/ */
public void setIf(String condition) { public void setIf(String condition) {
this.ifCond = condition; this.ifCond = condition;
@@ -80,7 +80,7 @@ public class DotnetDefine {
/** /**
* the name of a property which must be undefined for * the name of a property which must be undefined for
* the definition to be set. Optional. * the definition to be set. Optional.
* @param condition
* @param condition the name of the property
*/ */
public void setUnless(String condition) { public void setUnless(String condition) {
this.unlessCond = condition; this.unlessCond = condition;


Loading…
Cancel
Save