FileDocCategorySizeDatePackage
Comparison.javaAPI DocApache Ant 1.703233Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.types

Comparison

public class Comparison extends EnumeratedAttribute
EnumeratedAttribute for generic comparisons. Accepts values "equal", "greater", "more", "less", "ne" (not equal), "ge" (greater or equal), "le" (less or equal), "eq" (equal), "gt" (greater), "lt" (less).
since
Ant 1.7

Fields Summary
private static final String[]
VALUES
public static final Comparison
EQUAL
Equal Comparison.
public static final Comparison
NOT_EQUAL
Not-Equal Comparison.
public static final Comparison
GREATER
Greater Comparison.
public static final Comparison
LESS
Less Comparison.
public static final Comparison
GREATER_EQUAL
Greater-or-Equal Comparison.
public static final Comparison
LESS_EQUAL
Less-or-Equal Comparison.
private static final int[]
EQUAL_INDEX
private static final int[]
LESS_INDEX
private static final int[]
GREATER_INDEX
Constructors Summary
public Comparison()
Default constructor.


           
      
    
public Comparison(String value)
Construct a new Comparison with the specified value.

param
value the EnumeratedAttribute value.

        setValue(value);
    
Methods Summary
public booleanevaluate(int comparisonResult)
Evaluate a comparison result as from Comparator.compare() or Comparable.compareTo().

param
comparisonResult the result to evaluate.
return
true if the comparison result fell within the parameters of this Comparison.

        if (getIndex() == -1) {
            throw new BuildException("Comparison value not set.");
        }
        int[] i = comparisonResult < 0 ? LESS_INDEX
            : comparisonResult > 0 ? GREATER_INDEX : EQUAL_INDEX;
        return Arrays.binarySearch(i, getIndex()) >= 0;
    
public java.lang.String[]getValues()
Return the possible values.

return
String[] of EnumeratedAttribute values.

        return VALUES;