org.apache.xpath
Class Expression

java.lang.Object
  |
  +--org.apache.xpath.Expression
Direct Known Subclasses:
Function, NodeTest, Operation, UnaryOperation, UnionPathIterator, UnionPattern, Variable, XObject

public abstract class Expression
extends java.lang.Object
implements java.io.Serializable

This abstract class serves as the base for all expression objects. An Expression can be executed to return a XObject, normally has a location within a document or DOM, can send error and warning events, and normally do not hold state and are meant to be immutable once construction has completed. An exception to the immutibility rule is iterators and walkers, which must be cloned in order to be used -- the original must still be immutable.

See Also:
Serialized Form

Constructor Summary
Expression()
           
 
Method Summary
 void assertion(boolean b, java.lang.String msg)
          Tell the user of an assertion error, and probably throw an exception.
 boolean canTraverseOutsideSubtree()
          Tell if this expression or it's subexpressions can traverse outside the current subtree.
 void error(XPathContext xctxt, int msg, java.lang.Object[] args)
          Tell the user of an error, and probably throw an exception.
abstract  XObject execute(XPathContext xctxt)
          Execute an expression in the XPath runtime context, and return the result of the expression.
 void setSourceLocator(SourceLocator locator)
          Set the location where this expression was built from.
 void warn(XPathContext xctxt, int msg, java.lang.Object[] args)
          Warn the user of an problem.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expression

public Expression()
Method Detail

canTraverseOutsideSubtree

public boolean canTraverseOutsideSubtree()
Tell if this expression or it's subexpressions can traverse outside the current subtree.
Returns:
true if traversal outside the context node's subtree can occur.

setSourceLocator

public void setSourceLocator(SourceLocator locator)
Set the location where this expression was built from.
Parameters:
locator - the location where this expression was built from, may be null.

execute

public abstract XObject execute(XPathContext xctxt)
                         throws TransformerException
Execute an expression in the XPath runtime context, and return the result of the expression.
Parameters:
xctxt - The XPath runtime context.
Returns:
The result of the expression in the form of a XObject.
Throws:
TransformerException - if a runtime exception occurs.

warn

public void warn(XPathContext xctxt,
                 int msg,
                 java.lang.Object[] args)
          throws TransformerException
Warn the user of an problem.
Parameters:
xctxt - The XPath runtime context.
msg - An error number that corresponds to one of the numbers found in XPATHErrorResources, which is a key for a format string.
args - An array of arguments represented in the format string, which may be null.
Throws:
TransformerException - if the current ErrorListoner determines to throw an exception.

assertion

public void assertion(boolean b,
                      java.lang.String msg)
               throws TransformerException
Tell the user of an assertion error, and probably throw an exception.
Parameters:
b - If false, a runtime exception will be thrown.
msg - The assertion message, which should be informative.
Throws:
java.lang.RuntimeException - if the b argument is false.

error

public void error(XPathContext xctxt,
                  int msg,
                  java.lang.Object[] args)
           throws TransformerException
Tell the user of an error, and probably throw an exception.
Parameters:
xctxt - The XPath runtime context.
msg - An error number that corresponds to one of the numbers found in XPATHErrorResources, which is a key for a format string.
args - An array of arguments represented in the format string, which may be null.
Throws:
TransformerException - if the current ErrorListoner determines to throw an exception.


Copyright © 2000 Apache XML Project. All Rights Reserved.