org.exolab.adaptx.xpath.engine
Class FilterBase

java.lang.Object
  extended byorg.exolab.adaptx.xpath.engine.FilterBase
All 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(org.exolab.adaptx.xpath.engine.PredicateExprImpl predicate)
          Adds the given Expression to this FilterBase's predicate List.
 void addPredicate(XPathExpression expr)
          Adds the given Expression to this FilterBase's predicate List.
abstract  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()
           
abstract  double getDefaultPriority()
          Determines the priority of a PatternExpr as follows:
abstract  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.
abstract  boolean matches(XPathNode node, XPathContext context)
          Determines if the given node is matched by this MatchExpr with respect to the given context.
 java.lang.String toString()
          Returns the String representation of this FilterBase
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_OP

public static final int NO_OP
See Also:
Constant Field Values

PARENT_OP

public static final int PARENT_OP
See Also:
Constant Field Values
Constructor Detail

FilterBase

public FilterBase(int ancestryOp)
Creates a new FilterBase

Method Detail

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
Throws:
XPathException

addPredicate

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

Throws:
XPathException

getDefaultPriority

public abstract 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 abstract short getExprType()
Description copied from interface: XPathExpression
Returns the type of this expression.

Specified by:
getExprType in interface XPathExpression
Returns:
The type of this expression

evaluate

public abstract 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.

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.

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
context - the XPathContext for use during evaluation.
Throws:
XPathException

getAncestryOp

public int getAncestryOp()

matches

public abstract 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 java.lang.String toString()
Returns the String representation of this FilterBase

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