org.jaxen.expr

Class PredicateSet

public class PredicateSet extends Object implements Serializable

Represents the collection of predicates that follow the node-test in a location path.

There is no rule that the same predicate may not appear twice in an XPath expression, nor does this class enforce any such rule. This is implemented more as a list than a set. However, adding the swme predicate twice should have no effect on the final result other than slowing it down.

Field Summary
Listpredicates
static longserialVersionUID
Constructor Summary
PredicateSet()
Create a new empty predicate set.
Method Summary
voidaddPredicate(Predicate predicate)
Add a predicate to the set.
booleananyMatchingNode(List contextNodeSet, ContextSupport support)
ListapplyPredicate(Predicate predicate, List nodes2Filter, ContextSupport support)
protected booleanevaluateAsBoolean(List contextNodeSet, ContextSupport support)

Returns true if any of the supplied nodes satisfy all the predicates in the set.

protected ListevaluatePredicates(List contextNodeSet, ContextSupport support)

Returns all of the supplied nodes that satisfy all the predicates in the set.

ListgetPredicates()
Returns the list containing the predicates.
StringgetText()
Returns the XPath string containing each of the predicates.
voidsimplify()
Simplify each of the predicates in the list.

Field Detail

predicates

private List predicates

serialVersionUID

private static final long serialVersionUID

Constructor Detail

PredicateSet

public PredicateSet()
Create a new empty predicate set.

Method Detail

addPredicate

public void addPredicate(Predicate predicate)
Add a predicate to the set.

Parameters: predicate the predicate to be inserted

anyMatchingNode

private boolean anyMatchingNode(List contextNodeSet, ContextSupport support)

applyPredicate

public List applyPredicate(Predicate predicate, List nodes2Filter, ContextSupport support)

evaluateAsBoolean

protected boolean evaluateAsBoolean(List contextNodeSet, ContextSupport support)

Returns true if any of the supplied nodes satisfy all the predicates in the set. Returns false if none of the supplied nodes matches all the predicates in the set. Returns false if the node-set is empty.

Parameters: contextNodeSet the nodes to test against these predicates support ????

Returns: true if any node in the contextNodeSet matches all the predicates

Throws: JaxenException

evaluatePredicates

protected List evaluatePredicates(List contextNodeSet, ContextSupport support)

Returns all of the supplied nodes that satisfy all the predicates in the set.

Parameters: contextNodeSet the nodes to test against these predicates support ????

Returns: all the nodes that match each of the predicates

Throws: JaxenException

getPredicates

public List getPredicates()
Returns the list containing the predicates. This list is live, not a copy.

Returns: a live list of predicates

getText

public String getText()
Returns the XPath string containing each of the predicates.

Returns: the XPath string containing each of the predicates

simplify

public void simplify()
Simplify each of the predicates in the list.