From 9fb2961443b0e15a6fd0be0aceed9d78e8c9cad7 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Thu, 11 Apr 2002 07:38:15 +0000
Subject: [PATCH] Adding some @since tags.
cleanups.
Make sure honors property immutability rules.
Remove redundant Enumeration class from ConditionBase
(IntrospectionHelper will have taken care of it now).
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272364 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/tools/ant/taskdefs/Ant.java | 2 ++
.../tools/ant/taskdefs/AntStructure.java | 2 ++
.../apache/tools/ant/taskdefs/Available.java | 2 ++
.../apache/tools/ant/taskdefs/CallTarget.java | 2 ++
.../org/apache/tools/ant/taskdefs/Chmod.java | 2 ++
.../tools/ant/taskdefs/ConditionTask.java | 2 ++
.../apache/tools/ant/taskdefs/ExecuteOn.java | 4 ++-
.../org/apache/tools/ant/taskdefs/GUnzip.java | 2 ++
.../org/apache/tools/ant/taskdefs/GZip.java | 2 ++
.../apache/tools/ant/taskdefs/Transform.java | 2 --
.../apache/tools/ant/taskdefs/UpToDate.java | 23 +++++++++-----
.../tools/ant/taskdefs/condition/And.java | 3 +-
.../ant/taskdefs/condition/ConditionBase.java | 30 ++-----------------
.../ant/taskdefs/condition/Contains.java | 3 +-
.../tools/ant/taskdefs/condition/Equals.java | 4 ++-
.../ant/taskdefs/condition/FilesMatch.java | 10 ++++---
.../tools/ant/taskdefs/condition/Http.java | 10 ++++---
.../tools/ant/taskdefs/condition/IsSet.java | 6 ++--
.../tools/ant/taskdefs/condition/Not.java | 3 +-
.../tools/ant/taskdefs/condition/Or.java | 3 +-
.../tools/ant/taskdefs/condition/Os.java | 1 +
.../tools/ant/taskdefs/condition/Socket.java | 15 ++++++----
22 files changed, 73 insertions(+), 60 deletions(-)
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java
index 74aecedaf..b2ed56f61 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ant.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java
@@ -90,6 +90,8 @@ import java.util.Enumeration;
*
* @author costin@dnt.ro
*
+ * @since Ant 1.1
+ *
* @ant.task category="control"
*/
public class Ant extends Task {
diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
index 3996a7225..1e36fab0d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
@@ -79,6 +79,8 @@ import java.io.IOException;
*
* @version $Revision$
*
+ * @since Ant 1.1
+ *
* @ant.task category="xml"
*/
diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java
index d5e57745b..27efcb000 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Available.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Available.java
@@ -73,6 +73,8 @@ import org.apache.tools.ant.util.StringUtils;
* @author Stefano Mazzocchi stefano@apache.org
* @author Magesh Umasankar
*
+ * @since Ant 1.1
+ *
* @ant.task category="control"
*/
public class Available extends Task implements Condition {
diff --git a/src/main/org/apache/tools/ant/taskdefs/CallTarget.java b/src/main/org/apache/tools/ant/taskdefs/CallTarget.java
index 56310db82..3c50c9fbd 100644
--- a/src/main/org/apache/tools/ant/taskdefs/CallTarget.java
+++ b/src/main/org/apache/tools/ant/taskdefs/CallTarget.java
@@ -79,6 +79,8 @@ import org.apache.tools.ant.BuildException;
*
* @author Stefan Bodewig
*
+ * @since Ant 1.2
+ *
* @ant.task name="antcall" category="control"
*/
public class CallTarget extends Task {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Chmod.java b/src/main/org/apache/tools/ant/taskdefs/Chmod.java
index 687c590a8..33e901ae4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Chmod.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Chmod.java
@@ -71,6 +71,8 @@ import org.apache.tools.ant.types.PatternSet;
* @author Mariusz Nowostawski (Marni) mnowostawski@infoscience.otago.ac.nz
* @author Stefan Bodewig
*
+ * @since Ant 1.1
+ *
* @ant.task category="filesystem"
*/
public class Chmod extends ExecuteOn {
diff --git a/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java b/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
index 72f312e80..0571eba29 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
@@ -71,6 +71,8 @@ import org.apache.tools.ant.taskdefs.condition.ConditionBase;
* @author Stefan Bodewig
* @version $Revision$
*
+ * @since Ant 1.4
+ *
* @ant.task category="control"
*/
public class ConditionTask extends ConditionBase {
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
index 6c78183ac..18e72b9da 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
@@ -75,7 +75,9 @@ import java.io.IOException;
* @author Stefan Bodewig
* @author Mariusz Nowostawski
*
- * @ant.task name="execon"
+ * @since Ant 1.2
+ *
+ * @ant.task name="apply" category="control"
*/
public class ExecuteOn extends ExecTask {
diff --git a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
index 5b9951e1c..6eb63bbed 100644
--- a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
@@ -69,6 +69,8 @@ import java.util.zip.GZIPInputStream;
* @author Stefan Bodewig
* @author Magesh Umasankar
*
+ * @since Ant 1.1
+ *
* @ant.task category="packaging"
*/
diff --git a/src/main/org/apache/tools/ant/taskdefs/GZip.java b/src/main/org/apache/tools/ant/taskdefs/GZip.java
index 3996c64dd..663fcccce 100644
--- a/src/main/org/apache/tools/ant/taskdefs/GZip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/GZip.java
@@ -68,6 +68,8 @@ import java.util.zip.GZIPOutputStream;
* @author Jon S. Stevens jon@clearink.com
* @author Magesh Umasankar
*
+ * @since Ant 1.1
+ *
* @ant.task category="packaging"
*/
diff --git a/src/main/org/apache/tools/ant/taskdefs/Transform.java b/src/main/org/apache/tools/ant/taskdefs/Transform.java
index 22d11458e..5e5cf8f12 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Transform.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Transform.java
@@ -58,7 +58,5 @@ package org.apache.tools.ant.taskdefs;
* Has been merged into ExecuteOn, empty class for backwards compatibility.
*
* @author Stefan Bodewig
- *
- * @ant.task name="apply" category="control"
*/
public class Transform extends ExecuteOn {}
diff --git a/src/main/org/apache/tools/ant/taskdefs/UpToDate.java b/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
index b06f8295c..737c8436f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
+++ b/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
@@ -77,6 +77,8 @@ import java.util.Vector;
* @author Hiroaki Nakamura hnakamur@mc.neweb.ne.jp
* @author Stefan Bodewig
*
+ * @since Ant 1.2
+ *
* @ant.task category="control"
*/
@@ -162,15 +164,19 @@ public class UpToDate extends Task implements Condition {
*/
public boolean eval() {
if (sourceFileSets.size() == 0 && _sourceFile == null) {
- throw new BuildException("At least one srcfile or a nested element must be set.");
+ throw new BuildException("At least one srcfile or a nested "
+ + " element must be set.");
}
if (sourceFileSets.size() > 0 && _sourceFile != null) {
- throw new BuildException("Cannot specify both the srcfile attribute and a nested element.");
+ throw new BuildException("Cannot specify both the srcfile "
+ + "attribute and a nested "
+ + "element.");
}
if (_targetFile == null && mapperElement == null) {
- throw new BuildException("The targetfile attribute or a nested mapper element must be set.");
+ throw new BuildException("The targetfile attribute or a nested "
+ + "mapper element must be set.");
}
// if the target file is not there, then it can't be up-to-date
@@ -180,8 +186,9 @@ public class UpToDate extends Task implements Condition {
// if the source file isn't there, throw an exception
if (_sourceFile != null && !_sourceFile.exists()) {
- throw new BuildException(_sourceFile.getAbsolutePath() + " not found.");
- }
+ throw new BuildException(_sourceFile.getAbsolutePath()
+ + " not found.");
+ }
Enumeration enum = sourceFileSets.elements();
boolean upToDate = true;
@@ -216,10 +223,10 @@ public class UpToDate extends Task implements Condition {
public void execute() throws BuildException {
boolean upToDate = eval();
if (upToDate) {
- this.project.setProperty(_property, this.getValue());
+ this.project.setNewProperty(_property, getValue());
if (mapperElement == null) {
- log("File \"" + _targetFile.getAbsolutePath() + "\" is up-to-date.",
- Project.MSG_VERBOSE);
+ log("File \"" + _targetFile.getAbsolutePath()
+ + "\" is up-to-date.", Project.MSG_VERBOSE);
} else {
log("All target files are up-to-date.",
Project.MSG_VERBOSE);
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/And.java b/src/main/org/apache/tools/ant/taskdefs/condition/And.java
index 7823753b7..82a67f94a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/And.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/And.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ import org.apache.tools.ant.BuildException;
* evaluates to false.
*
* @author Stefan Bodewig
+ * @since Ant 1.4
* @version $Revision$
*/
public class And extends ConditionBase implements Condition {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java b/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
index 541b74d59..cb36ec399 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/ConditionBase.java
@@ -70,6 +70,7 @@ import org.apache.tools.ant.taskdefs.UpToDate;
* and the "container" conditions are in sync.
*
* @author Stefan Bodewig
+ * @since Ant 1.4
* @version $Revision$
*/
public abstract class ConditionBase extends ProjectComponent {
@@ -88,7 +89,7 @@ public abstract class ConditionBase extends ProjectComponent {
* @since 1.1
*/
protected final Enumeration getConditions() {
- return new ConditionEnumeration();
+ return conditions.elements();
}
/**
@@ -182,31 +183,4 @@ public abstract class ConditionBase extends ProjectComponent {
*/
public void addContains(Contains test) {conditions.addElement(test);}
- /**
- * Inner class that configures those conditions with a project
- * instance that need it.
- *
- * @since 1.1
- */
- private class ConditionEnumeration implements Enumeration {
- private int currentElement = 0;
-
- public boolean hasMoreElements() {
- return countConditions() > currentElement;
- }
-
- public Object nextElement() throws NoSuchElementException {
- Object o = null;
- try {
- o = conditions.elementAt(currentElement++);
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new NoSuchElementException();
- }
-
- if (o instanceof ProjectComponent) {
- ((ProjectComponent) o).setProject(getProject());
- }
- return o;
- }
- }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
index f4f2a3284..c6d56e506 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
@@ -101,7 +101,8 @@ public class Contains implements Condition {
*/
public boolean eval() throws BuildException {
if (string == null || subString == null) {
- throw new BuildException("both string and substring are required in contains");
+ throw new BuildException("both string and substring are required "
+ + "in contains");
}
return caseSensitive
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java b/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
index a44b27343..0a70d8382 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
@@ -60,6 +60,7 @@ import org.apache.tools.ant.BuildException;
* Simple String comparison condition.
*
* @author Stefan Bodewig
+ * @since Ant 1.4
* @version $Revision$
*/
public class Equals implements Condition {
@@ -96,7 +97,8 @@ public class Equals implements Condition {
public boolean eval() throws BuildException {
if (arg1 == null || arg2 == null) {
- throw new BuildException("both arg1 and arg2 are required in equals");
+ throw new BuildException("both arg1 and arg2 are required in "
+ + "equals");
}
if (trim) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
index 9fa18499f..b3b2160f1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
@@ -59,8 +59,8 @@ import java.io.File;
import java.io.IOException;
/**
- * Compares two files for bitwise equality based on size and content. Timestamps
- * are not looked at at all.
+ * Compares two files for bitwise equality based on size and
+ * content. Timestamps are not looked at at all.
*
* @author Steve Loughran
* @version $Revision$
@@ -109,7 +109,8 @@ public class FilesMatch implements Condition {
//validate
if (file1 == null || file2 == null) {
- throw new BuildException("both file1 and file2 are required in filesmatch");
+ throw new BuildException("both file1 and file2 are required in "
+ + "filesmatch");
}
//#now match the files
@@ -117,7 +118,8 @@ public class FilesMatch implements Condition {
try {
matches=fu.contentEquals(file1, file2);
} catch(IOException ioe) {
- throw new BuildException("when comparing files", ioe);
+ throw new BuildException("when comparing files: "+ioe.getMessage(),
+ ioe);
}
return matches;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
index 3d71dd37e..3849dfb7e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,9 +69,10 @@ import java.net.URL;
* url - the URL of the request.
*
* @author Denis Hennessy
+ * @since Ant 1.5
*/
public class Http extends ProjectComponent implements Condition {
- String spec = null;
+ private String spec = null;
public void setUrl(String url) {
spec = url;
@@ -79,7 +80,7 @@ public class Http extends ProjectComponent implements Condition {
public boolean eval() throws BuildException {
if (spec == null) {
- throw new BuildException("No url specified in HTTP task");
+ throw new BuildException("No url specified in http condition");
}
log("Checking for " + spec, Project.MSG_VERBOSE);
try {
@@ -89,7 +90,8 @@ public class Http extends ProjectComponent implements Condition {
if (conn instanceof HttpURLConnection) {
HttpURLConnection http = (HttpURLConnection) conn;
int code = http.getResponseCode();
- log("Result code for " + spec + " was " + code, Project.MSG_VERBOSE);
+ log("Result code for " + spec + " was " + code,
+ Project.MSG_VERBOSE);
if (code > 0 && code < 500) {
return true;
} else {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
index 5b14d4b6c..b280e0654 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsSet.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@ import org.apache.tools.ant.ProjectComponent;
* Condition that tests whether a given property has been set.
*
* @author Stefan Bodewig
+ * @since Ant 1.5
* @version $Revision$
*/
public class IsSet extends ProjectComponent implements Condition {
@@ -70,7 +71,8 @@ public class IsSet extends ProjectComponent implements Condition {
public boolean eval() throws BuildException {
if (property == null) {
- throw new BuildException("No property specified for isset condition");
+ throw new BuildException("No property specified for isset "
+ + "condition");
}
return getProject().getProperty(property) != null;
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Not.java b/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
index 9629ea1d1..75a07c7a1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Not.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,6 +63,7 @@ import org.apache.tools.ant.BuildException;
* and vice versa.
*
* @author Stefan Bodewig
+ * @since Ant 1.4
* @version $Revision$
*/
public class Not extends ConditionBase implements Condition {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
index 5e6666df1..3e312d0c5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Or.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,6 +65,7 @@ import org.apache.tools.ant.BuildException;
* evaluates to true.
*
* @author Stefan Bodewig
+ * @since Ant 1.4
* @version $Revision$
*/
public class Or extends ConditionBase implements Condition {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
index 1d8a8cb89..1613c8b4b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
@@ -63,6 +63,7 @@ import java.util.Locale;
*
* @author Stefan Bodewig
* @author Magesh Umasankar
+ * @since Ant 1.4
* @version $Revision$
*/
public class Os implements Condition {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
index 4f4caffd5..ed04d6590 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,10 +66,11 @@ import java.io.IOException;
* port - the port number of the socket.
*
* @author Denis Hennessy
+ * @since Ant 1.5
*/
public class Socket extends ProjectComponent implements Condition {
- String server = null;
- int port = 0;
+ private String server = null;
+ private int port = 0;
public void setServer(String server) {
this.server = server;
@@ -81,12 +82,14 @@ public class Socket extends ProjectComponent implements Condition {
public boolean eval() throws BuildException {
if (server == null) {
- throw new BuildException("No server specified in Socket task");
+ throw new BuildException("No server specified in socket "
+ + "condition");
}
if (port == 0) {
- throw new BuildException("No port specified in Socket task");
+ throw new BuildException("No port specified in socket condition");
}
- log("Checking for listener at " + server + ":" + port, Project.MSG_VERBOSE);
+ log("Checking for listener at " + server + ":" + port,
+ Project.MSG_VERBOSE);
try {
java.net.Socket socket = new java.net.Socket(server, port);
} catch (IOException e) {