Hello all.
There are times when I want a different value than "true" when using the
available task. �This patch lets you set it to any value, defaulting to
"true".
Index: jakarta-ant/docs/index.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/index.html,v
retrieving revision 1.48
diff -u -r1.48 index.html
--- jakarta-ant/docs/index.html � � � �2000/07/14 12:09:09 � � � �1.48
+++ jakarta-ant/docs/index.html � � � �2000/07/14 13:52:11
@@ -632,8 +632,9 @@
�<h3>Description</h3>
�<p>Sets a property if a resource is available at runtime. This resource
can be a
�file resource, a class in classpath or a JVM system resource.</p>
-<p>The value part of the properties being set is <i>true</i> if the
resource is
-present, otherwise, the property is not set.</p>
+<p>If the resource is present, the property value is set to true by
default,
+otherwise the property is not set. �You can set the value to something
specific by
+using the value attribute.</p>
�<p>Normally, this task is used to set properties that are useful to avoid
target
�execution depending on system parameters.</p>
�<h3>Parameters</h3>
@@ -647,6 +648,11 @@
� � �<td valign="top">property</td>
� � �<td valign="top">the name of the property to set.</td>
� � �<td valign="top" align="center">Yes</td>
+ �</tr>
+ �<tr>
+ � �<td valign="top">value</td>
+ � �<td valign="top">the value to set the property to. Defaults to
"true".</td>
+ � �<td valign="top" align="center">No</td>
� �</tr>
� �<tr>
� � �<td valign="top">classname</td>
Index: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java,v
retrieving revision 1.6
diff -u -r1.6 Available.java
--- jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java
2000/07/06 16:48:13 � � � �1.6
+++ jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java
2000/07/14 13:52:17
@@ -70,6 +70,7 @@
� � �private String classname;
� � �private String file;
� � �private String resource;
+ � �private String value = "true";
� � �public void setProperty(String property) {
� � � � �this.property = property;
@@ -93,13 +94,17 @@
� � �public void setResource(String resource) {
� � � � �this.resource = resource;
� � �}
+
+ � �public void setValue(String value) {
+ � � � �this.value = value;
+ � �}
� � �public void init() throws BuildException {
� � � � �if ((classname != null) && !checkClass(classname)) return;
� � � � �if ((file != null) && !checkFile(file)) return;
� � � � �if ((resource != null) && !checkResource(resource)) return;
- � � � �this.project.setProperty(property, "true");
+ � � � �this.project.setProperty(property, value);
� � �}
� � �private boolean checkFile(String file) {
Glenn McAllister
TID - Software Developer - VisualAge for Java
IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey