1 18 19 package org.apache.tools.ant.taskdefs.condition; 20 21 import org.apache.tools.ant.BuildException; 22 23 28 public class Equals implements Condition { 29 30 private String arg1, arg2; 31 private boolean trim = false; 32 private boolean caseSensitive = true; 33 34 39 public void setArg1(String a1) { 40 arg1 = a1; 41 } 42 43 48 public void setArg2(String a2) { 49 arg2 = a2; 50 } 51 52 57 public void setTrim(boolean b) { 58 trim = b; 59 } 60 61 67 public void setCasesensitive(boolean b) { 68 caseSensitive = b; 69 } 70 71 75 public boolean eval() throws BuildException { 76 if (arg1 == null || arg2 == null) { 77 throw new BuildException("both arg1 and arg2 are required in " 78 + "equals"); 79 } 80 81 if (trim) { 82 arg1 = arg1.trim(); 83 arg2 = arg2.trim(); 84 } 85 86 return caseSensitive ? arg1.equals(arg2) : arg1.equalsIgnoreCase(arg2); 87 } 88 } 89 | Popular Tags |