Class AbstractPathComponent
java.lang.Object
org.exolab.adaptx.xpath.engine.AbstractPathComponent
- All Implemented Interfaces:
MatchExpression, PathComponent, XPathExpression
The base class for paths (now basically called paths)
- Version:
- $Revision: 4055 $ $Date: 2004-01-13 07:08:41 +0100 (Tue, 13 Jan 2004) $
- Author:
- Keith Visco
-
Field Summary
Fields inherited from interface XPathExpression
BOOLEAN, ERROR, FILTER_EXPR, LOCATION_PATH, NODE_TEST, NUMBER, PATH_EXPR, PRIMARY, STEP, STRING, UNION_EXPR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPredicate(org.exolab.adaptx.xpath.engine.PredicateExprImpl predicate) Adds the given Expression to this PathComponent's predicate List.voidaddPredicate(XPathExpression expr) Adds the given Expression to this PathComponent's predicate List.abstract XPathResultevaluate(XPathContext context) Evaluates the expression and returns the XPath result.voidevaluatePredicates(NodeSet nodes, XPathContext context) Evaluates the PredicateExpr of this PathComponent against the given Node.abstract doubleDetermines the priority of a PatternExpr as follows:abstract shortReturns the type of this expression.Returns the PredicateExpr of this PathComponentabstract XPathExpressionReturns the sub-expression encapsulated by this PathComponent.booleanReturns true if this FilterBase has predicates expressions.abstract booleanReturns true if this PathComponent is a FilterExpr.abstract booleanReturns true if this PathComponent is a LocationStep.abstract booleanmatches(XPathNode node, XPathContext context) Determines if the given node is matched by this MatchExpr with respect to the given context.toString()Returns the String representation of this PathComponent
-
Constructor Details
-
AbstractPathComponent
public AbstractPathComponent()Creates a new AbstractPathComponent
-
-
Method Details
-
addPredicate
Adds the given Expression to this PathComponent'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 PathComponent's predicate List.- Parameters:
expr- the Expr to add to the 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:
getDefaultPriorityin interfacePathComponent- Returns:
- the priority for this PatternExpr
-
getSubExpression
Returns the sub-expression encapsulated by this PathComponent. the sub-expression will either be a PrimaryExpr if this PathComponent is a FilterExpr, or a NodeExpression if this Pathcomponent is a LocationStep. This method may return null if no such sub-expression exists for the PathComponent.- Specified by:
getSubExpressionin interfacePathComponent- Returns:
- the sub-expression encapsulated by this PathComponent.
-
getExprType
public abstract short getExprType()Description copied from interface:XPathExpressionReturns the type of this expression.- Specified by:
getExprTypein interfaceXPathExpression- Returns:
- The type of this expression
-
evaluate
Evaluates the expression and returns the XPath result.- Specified by:
evaluatein interfaceXPathExpression- Parameters:
context- The XPathContext to use during evaluation.- Returns:
- The XPathResult (not null).
- Throws:
XPathException- if an error occured while evaluating this expression.
-
getPredicate
Returns the PredicateExpr of this PathComponent- Specified by:
getPredicatein interfacePathComponent- Returns:
- the PredicateExpr of this PathComponent
-
hasPredicates
public boolean hasPredicates()Returns true if this FilterBase has predicates expressions.- Specified by:
hasPredicatesin interfacePathComponent- Returns:
- true if this FilterBase has predicates expressions.
-
evaluatePredicates
Evaluates the PredicateExpr of this PathComponent against the given Node.- Specified by:
evaluatePredicatesin interfacePathComponent- Parameters:
nodes- the current NodeSetcontext- the XPathContext for use during evaluation.contextInfo- provides a way to retrieve additional context information needed to evaluate some expressions- Throws:
XPathException
-
isFilterExpr
public abstract boolean isFilterExpr()Returns true if this PathComponent is a FilterExpr. Note that if this method returns true, then a call to #isLocationStep must return false.- Specified by:
isFilterExprin interfacePathComponent- Returns:
- true if this PathComponent is a FilterExpr
- See Also:
-
isLocationStep
public abstract boolean isLocationStep()Returns true if this PathComponent is a LocationStep. Note that if this method returns true, then a call to #isFilterExpr must return false.- Specified by:
isLocationStepin interfacePathComponent- Returns:
- true if this PathComponent is a LocationStep
- See Also:
-
matches
Determines if the given node is matched by this MatchExpr with respect to the given context.- Specified by:
matchesin interfaceMatchExpression- Parameters:
node- the node to determine a match forcontext- the XPathContext- Returns:
- true if the given node is matched by this MatchExpr
- Throws:
XPathException- when an error occurs during evaluation
-
toString
Returns the String representation of this PathComponent- Specified by:
toStringin interfaceXPathExpression- Overrides:
toStringin classObject- Returns:
- the String representation of this PathComponent
-