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:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @author Glenn McAllister <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">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: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>