Straightforward; the 'whenempty' attr can only take fixed values. This is
cleaner and helps GUIs present the task more nicely.

Note that I initially tried to keep code-level compatibility, for what it's
worth, but IntrospectionHelper does not seem to be happy with the overload; it
reports the type as String, I think.

-Jesse

-- 
Jesse Glick   <mailto:[EMAIL PROTECTED]>
NetBeans, Open APIs  <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR
Index: src/main/org/apache/tools/ant/taskdefs/Zip.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.33
diff -c -t -r1.33 Zip.java
*** src/main/org/apache/tools/ant/taskdefs/Zip.java     2001/03/08 13:42:06     
1.33
--- src/main/org/apache/tools/ant/taskdefs/Zip.java     2001/03/08 20:28:17
***************
*** 122,127 ****
--- 122,134 ----
      }
  
  
+     /** 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: <code>fail</code> (throw an exception
***************
*** 131,143 ****
       * Default for zip tasks is <code>skip</code>;
       * for jar tasks, <code>create</code>.
       */
!     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 execute() throws BuildException {
          if (baseDir == null && filesets.size() == 0 && 
"zip".equals(archiveType)) {
--- 138,154 ----
       * Default for zip tasks is <code>skip</code>;
       * for jar tasks, <code>create</code>.
       */
!     public void setWhenempty(WhenEmpty we) {
!         emptyBehavior = we.getValue();
      }
+ 
+     /** @deprecated Please use [EMAIL PROTECTED] 
#setWhenempty(Zip.WhenEmpty)} instead.
+      * DOESN'T SEEM TO WORK
+     public void setWhenempty(String we) throws BuildException {
+         WhenEmpty we2 = new WhenEmpty();
+         we2.setValue(we.toLowerCase());
+         setWhenempty(we2);
+     }*/
  
      public void execute() throws BuildException {
          if (baseDir == null && filesets.size() == 0 && 
"zip".equals(archiveType)) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to