FileDocCategorySizeDatePackage
Quantifier.javaAPI DocApache Ant 1.704751Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.types

Quantifier

public class Quantifier extends EnumeratedAttribute
EnumeratedAttribute for quantifier comparisons. Evaluates a boolean[] or raw true and false counts. Accepts the following values:
  • "all"
  • - none false
  • "each"
  • - none false
  • "every"
  • - none false
  • "any"
  • - at least one true
  • "some"
  • - at least one true
  • "one"
  • - exactly one true
  • "majority"
  • - more true than false
  • "most"
  • - more true than false
  • "none"
  • - none true
since
Ant 1.7

Fields Summary
private static final String[]
VALUES
public static final Quantifier
ALL
ALL instance
public static final Quantifier
ANY
ANY instance
public static final Quantifier
ONE
ONE instance
public static final Quantifier
MAJORITY
MAJORITY instance
public static final Quantifier
NONE
NONE instance
private static final Predicate
ALL_PRED
private static final Predicate
ANY_PRED
private static final Predicate
ONE_PRED
private static final Predicate
MAJORITY_PRED
private static final Predicate
NONE_PRED
private static final Predicate[]
PREDS
Constructors Summary
public Quantifier()
Default constructor.


     
        PREDS[0] = ALL_PRED;
        PREDS[1] = ALL_PRED;
        PREDS[2] = ALL_PRED;
        PREDS[3] = ANY_PRED;
        PREDS[4] = ANY_PRED;
        PREDS[5] = ONE_PRED;
        PREDS[6] = MAJORITY_PRED;
        PREDS[7] = MAJORITY_PRED;
        PREDS[8] = NONE_PRED;
    
    
public Quantifier(String value)
Construct a new Quantifier with the specified value.

param
value the EnumeratedAttribute value.

        setValue(value);
    
Methods Summary
public booleanevaluate(boolean[] b)
Evaluate a boolean array.

param
b the boolean[] to evaluate.
return
true if the argument fell within the parameters of this Quantifier.

        int t = 0;
        for (int i = 0; i < b.length; i++) {
            if (b[i]) {
                t++;
            }
        }
        return evaluate(t, b.length - t);
    
public booleanevaluate(int t, int f)
Evaluate integer true vs. false counts.

param
t the number of true values.
param
f the number of false values.
return
true if the arguments fell within the parameters of this Quantifier.

        int index = getIndex();
        if (index == -1) {
            throw new BuildException("Quantifier value not set.");
        }
        return PREDS[index].eval(t, f);
    
public java.lang.String[]getValues()
Return the possible values.

return
String[] of EnumeratedAttribute values.

        return VALUES;