com.sas.util
Class NthPredicate

com.sas.util.NthPredicate
All Implemented Interfaces:
com.sas.util.PredicateInterface, java.io.Serializable

public class NthPredicate
implements com.sas.util.PredicateInterface, java.io.Serializable

NthPredicate is a predicate which defers to another predicate test and returns true only when that predicate has returned true n (or more) times.

See Also:
Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
NthPredicate(com.sas.util.PredicateInterface predicate, int n)
          Constructs a predicate which defers to another predicate test and returns true only when that predicate has returned true exactly n times.
NthPredicate(com.sas.util.PredicateInterface predicate, int n, boolean exactly)
          Constructs a predicate which defers to another predicate test and returns true only when that predicate has returned true n (or more) times.
 
Method Summary
 int getCount()
          Returns the number of times the input predicate has returned true.
 int getN()
          Returns the value of n.
 com.sas.util.PredicateInterface getPredicate()
          Returns the internal predicate.
 boolean predicate(java.lang.Object object)
          Runs the initial predicate on the object.
 void reset()
          Resets the count to 0.
 void setN(int n)
          Sets the value of n.
 void setPredicate(com.sas.util.PredicateInterface predicate)
          Sets the internal predicate.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

NthPredicate

public NthPredicate(com.sas.util.PredicateInterface predicate,
                    int n)
Constructs a predicate which defers to another predicate test and returns true only when that predicate has returned true exactly n times.

Parameters:
predicate - the predicate to test
n - return true only after the predicate has returned true n times.

NthPredicate

public NthPredicate(com.sas.util.PredicateInterface predicate,
                    int n,
                    boolean exactly)
Constructs a predicate which defers to another predicate test and returns true only when that predicate has returned true n (or more) times.

Parameters:
predicate - the predicate to test
n - return true only after the predicate has returned true n (or more) times.
exactly - specifies whether true should be returned only when predicate has returned true exactly n times or if any occurrence of true equal to or greater than n times also returns true (count == n vs. count >= n).
Method Detail

predicate

public boolean predicate(java.lang.Object object)
Runs the initial predicate on the object.

Specified by:
predicate in interface com.sas.util.PredicateInterface
Returns:
true after the input predicate has returned true exactly n times, otherwise false

reset

public void reset()
Resets the count to 0.


getCount

public int getCount()
Returns the number of times the input predicate has returned true.

Returns:
the number of times the input predicate has returned true

getN

public int getN()
Returns the value of n.

Returns:
the value of n
See Also:
setN(int)

setN

public void setN(int n)
Sets the value of n.

Parameters:
n - the new value for n #getN

getPredicate

public com.sas.util.PredicateInterface getPredicate()
Returns the internal predicate.

Returns:
the internal predicate
See Also:
setPredicate(com.sas.util.PredicateInterface)

setPredicate

public void setPredicate(com.sas.util.PredicateInterface predicate)
Sets the internal predicate.

Parameters:
predicate - the new value for the internal predicate
See Also:
getPredicate()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.