org.exolab.adaptx.xpath.engine

Class FilterBase

Implemented Interfaces:
MatchExpression, PathComponent, XPathExpression

public abstract class FilterBase
extends java.lang.Object
implements PathComponent

The base class for filters (now basically called paths)

Version:
$Revision: 1.2 $ $Date: 2003/05/13 07:59:08 $

Author:
Keith Visco

Field Summary

static int
NO_OP
static int
PARENT_OP

Fields inherited from interface org.exolab.adaptx.xpath.XPathExpression

BOOLEAN, ERROR, FILTER_EXPR, LOCATION_PATH, NODE_TEST, NUMBER, PATH_EXPR, PRIMARY, STEP, STRING, UNION_EXPR

Constructor Summary

FilterBase(int ancestryOp)
Creates a new FilterBase

Method Summary

void
addPredicate(XPathExpression expr)
Adds the given Expression to this FilterBase's predicate List.
void
addPredicate(org.exolab.adaptx.xpath.engine.PredicateExprImpl predicate)
Adds the given Expression to this FilterBase's predicate List.
XPathResult
evaluate(XPathContext context)
Evaluates the expression and returns the XPath result.
void
evaluatePredicates(NodeSet nodes, XPathContext context)
Evaluates the PredicateExpr of this FilterBase against the given Node.
int
getAncestryOp()
double
getDefaultPriority()
Determines the priority of a PatternExpr as follows:
  From the 19991116 XSLT 1.0 Recommendation:
  + If the pattern has the form of a QName preceded by a
    ChildOrAttributeAxisSpecifier or has the form 
    processing-instruction(Literal) then the priority is 0.
short
getExprType()
Returns the type of this expression.
PredicateExpr
getPredicate()
Returns the PredicateExpr of this Filter
boolean
hasPredicates()
Returns true if this FilterBase has predicates expressions.
boolean
matches(XPathNode node, XPathContext context)
Determines if the given node is matched by this MatchExpr with respect to the given context.
String
toString()
Returns the String representation of this FilterBase

Field Details

NO_OP

public static final int NO_OP

Field Value:
0


PARENT_OP

public static final int PARENT_OP

Field Value:
1

Constructor Details

FilterBase

public FilterBase(int ancestryOp)
Creates a new FilterBase

Method Details

addPredicate

public void addPredicate(XPathExpression expr)
            throws XPathException
Adds the given Expression to this FilterBase's predicate List.

Parameters:
expr - the Expr to add to the predicate list


addPredicate

public void addPredicate(org.exolab.adaptx.xpath.engine.PredicateExprImpl predicate)
            throws XPathException
Adds the given Expression to this FilterBase's predicate List.

Parameters:


evaluate

public XPathResult evaluate(XPathContext context)
            throws XPathException
Evaluates the expression and returns the XPath result.
Specified by:
evaluate in interface XPathExpression

Parameters:
context - The XPathContext to use during evaluation.

Returns:
The XPathResult (not null).

Throws:
XPathException - if an error occured while evaluating this expression.


evaluatePredicates

public void evaluatePredicates(NodeSet nodes,
                               XPathContext context)
            throws XPathException
Evaluates the PredicateExpr of this FilterBase against the given Node.
Specified by:
evaluatePredicates in interface PathComponent

Parameters:
nodes - the current NodeSet


getAncestryOp

public int getAncestryOp()


getDefaultPriority

public double getDefaultPriority()
Determines the priority of a PatternExpr as follows:
  From the 19991116 XSLT 1.0 Recommendation:
  + If the pattern has the form of a QName preceded by a
    ChildOrAttributeAxisSpecifier or has the form 
    processing-instruction(Literal) then the priority is 0.
  + If the pattern has the form NCName:* preceded by a 
    ChildOrAttributeAxisSpecifier, then the priority is -0.25
  + Otherwise if the pattern consists of just a NodeTest 
    preceded by a ChildOrAttributeAxisSpecifier then the
    priority is -0.5
  + Otherwise the priority is 0.5
 
Specified by:
getDefaultPriority in interface PathComponent

Returns:
the priority for this PatternExpr


getExprType

public short getExprType()
Returns the type of this expression.
Specified by:
getExprType in interface XPathExpression

Returns:
The type of this expression


getPredicate

public PredicateExpr getPredicate()
Returns the PredicateExpr of this Filter
Specified by:
getPredicate in interface PathComponent

Returns:
the PredicateExpr of this Filter


hasPredicates

public boolean hasPredicates()
Returns true if this FilterBase has predicates expressions.
Specified by:
hasPredicates in interface PathComponent

Returns:
true if this FilterBase has predicates expressions.


matches

public boolean matches(XPathNode node,
                       XPathContext context)
            throws XPathException
Determines if the given node is matched by this MatchExpr with respect to the given context.
Specified by:
matches in interface MatchExpression

Parameters:
node - the node to determine a match for
context - the XPathContext

Returns:
true if the given node is matched by this MatchExpr

Throws:
XPathException - when an error occurs during evaluation


toString

public String toString()
Returns the String representation of this FilterBase
Specified by:
toString in interface XPathExpression

Returns:
the String representation of this FilterBase