ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r574302 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
Date Mon, 10 Sep 2007 17:13:36 GMT
Author: mbenson
Date: Mon Sep 10 10:13:35 2007
New Revision: 574302

URL: http://svn.apache.org/viewvc?rev=574302&view=rev
Log:
equals BC to support subclasses :/

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java?rev=574302&r1=574301&r2=574302&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/Equals.java Mon Sep 10
10:13:35 2007
@@ -39,8 +39,11 @@
      * @since Ant 1.8
      */
     public void setArg1(Object arg1) {
-        this.arg1 = arg1;
-        args |= 1;
+        if (arg1 instanceof String) {
+            setArg1((String) arg1);
+        } else {
+            setArg1Internal(arg1);
+        }
     }
 
     /**
@@ -49,17 +52,25 @@
      * @param a1 the first string
      */
     public void setArg1(String a1) {
-        setArg1((Object) a1);
+        setArg1Internal(a1);
     }
 
+    private void setArg1Internal(Object arg1) {
+        this.arg1 = arg1;
+        args |= 1;
+    }
+    
     /**
      * Set the second argument
      * @param arg2 the second argument.
      * @since Ant 1.8
      */
     public void setArg2(Object arg2) {
-        this.arg2 = arg2;
-        args |= 2;
+        if (arg2 instanceof String) {
+            setArg2((String) arg2);
+        } else {
+            setArg2Internal(arg2);
+        }
     }
 
     /**
@@ -68,9 +79,14 @@
      * @param a2 the second string
      */
     public void setArg2(String a2) {
-        setArg2((Object) a2);
+        setArg2Internal(a2);
     }
 
+    private void setArg2Internal(Object arg2) {
+        this.arg2 = arg2;
+        args |= 2;
+    }
+    
     /**
      * Should we want to trim the arguments before comparing them?
      * @param b if true trim the arguments
@@ -99,13 +115,15 @@
             throw new BuildException("both arg1 and arg2 are required in equals");
         }
 
+        if (arg1 instanceof String && trim) {
+            arg1 = ((String) arg1).trim();
+        }
+        if (arg2 instanceof String && trim) {
+            arg2 = ((String) arg2).trim();
+        }
         if (arg1 instanceof String && arg2 instanceof String) {
             String s1 = (String) arg1;
             String s2 = (String) arg2;
-            if (trim) {
-                s1 = s1.trim();
-                s2 = s2.trim();
-            }
             return caseSensitive ? s1.equals(s2) : s1.equalsIgnoreCase(s2);
         }
         return arg1 == arg2 || arg1 != null && arg1.equals(arg2);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message