diff --git a/src/main/org/apache/tools/ant/taskdefs/ConditionAndTask.java b/src/main/org/apache/tools/ant/taskdefs/ConditionAndTask.java deleted file mode 100644 index fbc726c72..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/ConditionAndTask.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.condition.Condition; - -/** - * Abstract task to allow defintion of a task or a condition. - * It has property and value (for the property) attributes. - * - * @since Ant 1.7 - * - * @ant.task category="control" - */ -public abstract class ConditionAndTask extends Task implements Condition { - - private String property; - private String value = "true"; - - /** - * Set the name of the property which will be set if the particular resource - * is available. - * - * @param property the name of the property to set. - */ - public void setProperty(String property) { - this.property = property; - } - - /** - * Set the value to be given to the property if the desired resource is - * available. - * - * @param value the value to be given. - */ - public void setValue(String value) { - this.value = value; - } - - /** - * This method should be overridden by derived classes. - * It is used by eval() to evaluate the condition. - * @return true if the condition passes, false otherwise. - */ - protected abstract boolean evaluate(); - - /** - * This method evaluates the condition. It calls evaluate in the - * derived class. - * It sets the property if a property is present and if the - * evaluate returns true. - * @return true if the condition passes, false otherwise. - */ - public boolean eval() { - if (evaluate()) { - if (property != null) { - getProject().setNewProperty(property, value); - } - return true; - } else { - return false; - } - } - - /** - * Entry point when operating as a task. - * - * @exception BuildException if the task is not configured correctly. - */ - public void execute() throws BuildException { - if (property == null) { - throw new BuildException("property attribute is required", - getLocation()); - } - eval(); - } - -} diff --git a/src/main/org/apache/tools/ant/taskdefs/IsSigned.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java similarity index 95% rename from src/main/org/apache/tools/ant/taskdefs/IsSigned.java rename to src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java index a8b4921d9..9f9a2bade 100644 --- a/src/main/org/apache/tools/ant/taskdefs/IsSigned.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java @@ -14,10 +14,11 @@ * limitations under the License. * */ -package org.apache.tools.ant.taskdefs; +package org.apache.tools.ant.taskdefs.condition; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.DataType; import java.io.File; import java.io.IOException; import java.util.zip.ZipEntry; @@ -30,7 +31,7 @@ import java.util.Enumeration; * particular signature; otherwise the file is checked for the * existence of any signature. */ -public class IsSigned extends ConditionAndTask { +public class IsSigned extends DataType implements Condition { private static final String SIG_START = "META-INF/"; private static final String SIG_END = ".SF"; @@ -63,7 +64,7 @@ public class IsSigned extends ConditionAndTask { * specified, if the file contains a signature. * @return true if the file is signed. */ - protected boolean evaluate() { + public boolean eval() { if (file == null) { throw new BuildException("The file attribute must be set."); } diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index a6bf2ed0c..bde9ce30a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -80,7 +80,6 @@ defaultexcludes=org.apache.tools.ant.taskdefs.DefaultExcludes presetdef=org.apache.tools.ant.taskdefs.PreSetDef macrodef=org.apache.tools.ant.taskdefs.MacroDef nice=org.apache.tools.ant.taskdefs.Nice -issigned=org.apache.tools.ant.taskdefs.IsSigned libraries=org.apache.tools.ant.taskdefs.repository.Libraries # optional tasks diff --git a/src/main/org/apache/tools/ant/types/defaults.properties b/src/main/org/apache/tools/ant/types/defaults.properties index 1792a716a..ccb1ec018 100644 --- a/src/main/org/apache/tools/ant/types/defaults.properties +++ b/src/main/org/apache/tools/ant/types/defaults.properties @@ -34,5 +34,6 @@ scriptfilter=org.apache.tools.ant.types.optional.ScriptFilter propertyset=org.apache.tools.ant.types.PropertySet assertions=org.apache.tools.ant.types.Assertions concatfilter=org.apache.tools.ant.filters.ConcatFilter +issigned=org.apache.tools.ant.taskdefs.condition.IsSigned ispingable=org.apache.tools.ant.taskdefs.optional.condition.IsPingable mavenrepository=org.apache.tools.ant.taskdefs.optional.repository.MavenRepository diff --git a/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java b/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java index 104c77619..e5cb2d14e 100644 --- a/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/SignedSelector.java @@ -18,7 +18,7 @@ package org.apache.tools.ant.types.selectors; import java.io.File; import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.taskdefs.IsSigned; +import org.apache.tools.ant.taskdefs.condition.IsSigned; /** * Selector that chooses files based on whether they are signed or not.