You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by um...@apache.org on 2001/12/05 03:06:58 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java

umagesh     01/12/04 18:06:57

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
  Log:
  setAction(String) replaced with setAction(FTP.Action) for action attribute of the FTP task.  setAction(String) has been deprecated.
  
  Revision  Changes    Path
  1.14      +52 -31    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FTP.java	2001/11/23 19:17:45	1.13
  +++ FTP.java	2001/12/05 02:06:57	1.14
  @@ -62,6 +62,7 @@
   import org.apache.tools.ant.FileScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.types.EnumeratedAttribute;
   import org.apache.tools.ant.types.FileSet;
   
   import java.io.BufferedInputStream;
  @@ -97,6 +98,7 @@
    *
    * @author Roger Vaughn <a href="mailto:rvaughn@seaconinc.com">rvaughn@seaconinc.com</a>
    * @author Glenn McAllister <a href="mailto:glennm@ca.ibm.com">glennm@ca.ibm.com</a>
  + * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    */
   public class FTP
       extends Task
  @@ -343,38 +345,27 @@
   
       /**
        * Sets the FTP action to be taken.  Currently accepts "put", "get",
  -     * "del", and "list".
  +     * "del", "mkdir" and "list".
  +     *
  +     * @deprecated setAction(String) is deprecated and is replaced with
  +     *             setAction(FTP.Action) to make Ant's Introspection
  +     *             mechanism do the work and also to encapsulate operations on
  +     *             the type in its own class.
  +     */
  +    public void setAction(String action) throws BuildException {
  +        log("DEPRECATED - The setAction(String) method has been deprecated."
  +            + " Use setAction(FTP.Action) instead.");
  +        Action a = new Action();
  +        a.setValue(action);
  +        this.action = a.getAction();
  +    }
  +
  +    /**
  +     * Sets the FTP action to be taken.  Currently accepts "put", "get",
  +     * "del", "mkdir" and "list".
        */
  -    public void setAction(String action) throws BuildException
  -    {
  -        String actionL = action.toLowerCase(Locale.US);
  -        if (actionL.equals("send") ||
  -            actionL.equals("put"))
  -        {
  -            this.action = SEND_FILES;
  -        }
  -        else if (actionL.equals("recv") ||
  -                 actionL.equals("get"))
  -        {
  -            this.action = GET_FILES;
  -        }
  -        else if (actionL.equals("del") ||
  -                 actionL.equals("delete" ))
  -        {
  -            this.action = DEL_FILES;
  -        }
  -        else if (actionL.equals("list"))
  -        {
  -            this.action = LIST_FILES;
  -        }
  -        else if (actionL.equals("mkdir"))
  -        {
  -            this.action = MK_DIR;
  -        }
  -        else
  -        {
  -            throw new BuildException("action " + action + " is not supported");
  -        }
  +    public void setAction(Action action) throws BuildException {
  +        this.action = action.getAction();
       }
   
       /**
  @@ -941,6 +932,36 @@
                       // ignore it
                   }
               }
  +        }
  +    }
  +
  +    public static class Action extends EnumeratedAttribute {
  +
  +        private final static String[] validActions = {
  +            "send", "put", "recv", "get", "del", "delete", "list", "mkdir"
  +        };
  +
  +        public String[] getValues() {
  +            return validActions;
  +        }
  +
  +        public int getAction() {
  +            String actionL = getValue().toLowerCase(Locale.US);
  +            if (actionL.equals("send") ||
  +                actionL.equals("put")) {
  +                return SEND_FILES;
  +            } else if (actionL.equals("recv") ||
  +                     actionL.equals("get")) {
  +                return GET_FILES;
  +            } else if (actionL.equals("del") ||
  +                     actionL.equals("delete" )) {
  +                return DEL_FILES;
  +            } else if (actionL.equals("list")) {
  +                return LIST_FILES;
  +            } else if (actionL.equals("mkdir")) {
  +                return MK_DIR;
  +            }
  +            return SEND_FILES;
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java

Posted by Magesh Umasankar <um...@apache.org>.
>   Modified:    src/main/org/apache/tools/ant/taskdefs/optional/net
FTP.java
>   Log:
>   setAction(String) replaced with setAction(FTP.Action) for action
>   attribute of the FTP task.  setAction(String) has been deprecated.

With this commit, I have converted most of the setFoo(String) to
setFoo(EnumeratedAttribute) where applicable.  CSharp and Ilsam
of the dotnet package are the only files that are left now with a
potential to migrate to using ExtendedAttribute instead of
String.  Attributes here are TargetType and WarnLevel.
But I don't have an environment to compile this.  (Steve, perhaps?)

There are other setFoo(String) methods which don't take
in enumerated attributes.  I will look at them next...

Magesh




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>