From 3f45fc1d3e95a270f2296d1f156a3bb21a73288a Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 9 Mar 2001 09:06:58 +0000 Subject: [PATCH] Make the whenempty attribute of zip use an EnumeratedAttribute - alows the DTD to be stricter. Submitted by: Jesse Glick git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268783 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Zip.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 43d0c6892..df0e34dad 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -122,6 +122,13 @@ public class Zip extends MatchingTask { } + /** Possible behaviors when there are no matching files for the task. */ + public static class WhenEmpty extends EnumeratedAttribute { + public String[] getValues() { + return new String[] {"fail", "skip", "create"}; + } + } + /** * Sets behavior of the task when no files match. * Possible values are: fail (throw an exception @@ -131,12 +138,8 @@ public class Zip extends MatchingTask { * Default for zip tasks is skip; * for jar tasks, create. */ - public void setWhenempty(String we) throws BuildException { - we = we.toLowerCase(); - // XXX could instead be using EnumeratedAttribute, but this works - if (!"fail".equals(we) && !"skip".equals(we) && !"create".equals(we)) - throw new BuildException("Unrecognized whenempty attribute: " + we); - emptyBehavior = we; + public void setWhenempty(WhenEmpty we) { + emptyBehavior = we.getValue(); } public void execute() throws BuildException {