jd.xml.xpath.expr
Interface Expression

All Known Subinterfaces:
Function, Operator, XsltFunction
All Known Implementing Classes:
Available, BooleanFunction, BooleanOperator, DocumentFunction, ExpressionImpl, FormatNumber, KeyFunction, NodeSetFunction, NodeSetOperator, NumericFunction, NumericOperator, ScriptFunction, StringFunction, SystemProperty, VariableFunction

public interface Expression

Expression represents a XPath expression. An Expression can be evaluated with respect to a XPath context. An expression is evaluated to yield an object, which has one of the four basic XPath types: node-set, boolean, number or string,


Field Summary
static int DEP_CONTEXT_NODE
           
static int DEP_CONTEXT_POSITION
           
static int DEP_CONTEXT_SIZE
           
static int DEP_CONTEXT_STATIC
           
static int DEP_NONE
           
static int DEP_UNKNOWN
           
 
Method Summary
 void accept(ExpressionVisitor visitor)
          Accept a ExpressionVisitor.
 int getContextDependencies()
          Return a bitfield indicating the expression dependencies on the XPath context.
 int getResultType()
          Return the type of the result object, before any conversions to the desired result type are performed.
 boolean hasContextDependencies(int dependencies)
          Test if the expression has special dependecies.
 boolean isUniqueFilter()
          Test if this expression only matches one node when used as a predicate filter for a node-set.
 boolean matchesFilter(XPathContext context)
          Evaluate the expression and return if the context node matches the expression when used as predicate filter.
 boolean toBooleanValue(XPathContext context)
          Evaluate the Expression to a boolean.
 XPathNode toNode(XPathContext context)
          Evaluate the Expression to a XPathNode, i.e.
 XNodeSet toNodeSet(XPathContext context, int ordering)
          Evaluate the Expression to a XNodeSet.
 double toNumberValue(XPathContext context)
          Evaluate the Expression to a number.
 String toString()
          Return a string representation of the expression.
 String toStringValue(XPathContext context)
          Evaluate the Expression to a String.
 XObject toXObject(XPathContext context)
          Evaluate the expression to a XObject.
 

Field Detail

DEP_NONE

public static final int DEP_NONE
See Also:
Constant Field Values

DEP_CONTEXT_STATIC

public static final int DEP_CONTEXT_STATIC
See Also:
Constant Field Values

DEP_CONTEXT_SIZE

public static final int DEP_CONTEXT_SIZE
See Also:
Constant Field Values

DEP_CONTEXT_POSITION

public static final int DEP_CONTEXT_POSITION
See Also:
Constant Field Values

DEP_CONTEXT_NODE

public static final int DEP_CONTEXT_NODE
See Also:
Constant Field Values

DEP_UNKNOWN

public static final int DEP_UNKNOWN
See Also:
Constant Field Values
Method Detail

toXObject

public XObject toXObject(XPathContext context)
Evaluate the expression to a XObject.

Parameters:
context - the evaluation context

toNumberValue

public double toNumberValue(XPathContext context)
Evaluate the Expression to a number.

Parameters:
context - the evaluation context

toStringValue

public String toStringValue(XPathContext context)
Evaluate the Expression to a String.

Parameters:
context - the evaluation context

toBooleanValue

public boolean toBooleanValue(XPathContext context)
Evaluate the Expression to a boolean.

Parameters:
context - the evaluation context

toNodeSet

public XNodeSet toNodeSet(XPathContext context,
                          int ordering)
Evaluate the Expression to a XNodeSet.

Parameters:
context - the evaluation context
ordering - the ordering which the returned node-set must have

toNode

public XPathNode toNode(XPathContext context)
Evaluate the Expression to a XPathNode, i.e. evaluate to a node-set and return its first node or null if the node-set is empty.

Parameters:
context - the evaluation context

getResultType

public int getResultType()
Return the type of the result object, before any conversions to the desired result type are performed. If the result type is not known XObject.TYPE_VARIABLE is returned.


matchesFilter

public boolean matchesFilter(XPathContext context)
Evaluate the expression and return if the context node matches the expression when used as predicate filter.


isUniqueFilter

public boolean isUniqueFilter()
Test if this expression only matches one node when used as a predicate filter for a node-set. The default implementation returns true if the result type is NUMBER.


getContextDependencies

public int getContextDependencies()
Return a bitfield indicating the expression dependencies on the XPath context.


hasContextDependencies

public boolean hasContextDependencies(int dependencies)
Test if the expression has special dependecies.

Parameters:
dependencies - the dependency constants merge together with bitwise or

accept

public void accept(ExpressionVisitor visitor)
Accept a ExpressionVisitor.


toString

public String toString()
Return a string representation of the expression.