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.
asIterator
public DTMIterator asIterator(XPathContext xctxt,
int contextNode)
throws TransformerException
Given an select expression and a context, evaluate the XPath
and return the resulting iterator.
xctxt
- The execution context.contextNode
- The node that "." expresses.
asIteratorRaw
public DTMIterator asIteratorRaw(XPathContext xctxt,
int contextNode)
throws TransformerException
Given an select expression and a context, evaluate the XPath
and return the resulting iterator, but do not clone.
xctxt
- The execution context.contextNode
- The node that "." expresses.
asNode
public int asNode(XPathContext xctxt)
throws TransformerException
Return the first node out of the nodeset, if this expression is
a nodeset expression.
xctxt
- The XPath runtime context.
- the first node out of the nodeset, or DTM.NULL.
assertion
public void assertion(boolean b,
String msg)
Tell the user of an assertion error, and probably throw an
exception.
b
- If false, a runtime exception will be thrown.msg
- The assertion message, which should be informative.
canTraverseOutsideSubtree
public boolean canTraverseOutsideSubtree()
Tell if this expression or it's subexpressions can traverse outside
the current subtree.
- true if traversal outside the context node's subtree can occur.
deepEquals
public abstract boolean deepEquals(Expression expr)
Compare this object with another object and see
if they are equal, include the sub heararchy.
expr
- Another expression object.
- true if this objects class and the expr
object's class are the same, and the data contained
within both objects are considered equal.
error
public void error(XPathContext xctxt,
String msg,
Object[] args)
throws TransformerException
Tell the user of an error, and probably throw an
exception.
xctxt
- The XPath runtime context.msg
- An error msgkey that corresponds to one of the constants 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.
execute
public abstract XObject execute(XPathContext xctxt)
throws TransformerException
Execute an expression in the XPath runtime context, and return the
result of the expression.
xctxt
- The XPath runtime context.
- The result of the expression in the form of a
XObject
.
execute
public XObject execute(XPathContext xctxt,
boolean destructiveOK)
throws TransformerException
Execute an expression in the XPath runtime context, and return the
result of the expression, but tell that a "safe" object doesn't have
to be returned. The default implementation just calls execute(xctxt).
xctxt
- The XPath runtime context.destructiveOK
- true if a "safe" object doesn't need to be returned.
- The result of the expression in the form of a
XObject
.
execute
public XObject execute(XPathContext xctxt,
int currentNode)
throws TransformerException
Execute an expression in the XPath runtime context, and return the
result of the expression.
xctxt
- The XPath runtime context.currentNode
- The currentNode.
- The result of the expression in the form of a
XObject
.
execute
public XObject execute(XPathContext xctxt,
int currentNode,
DTM dtm,
int expType)
throws TransformerException
Execute an expression in the XPath runtime context, and return the
result of the expression.
xctxt
- The XPath runtime context.currentNode
- The currentNode.dtm
- The DTM of the current node.expType
- The expanded type ID of the current node.
- The result of the expression in the form of a
XObject
.
executeCharsToContentHandler
public void executeCharsToContentHandler(XPathContext xctxt,
ContentHandler handler)
throws TransformerException,
org.xml.sax.SAXException
Execute an expression in the XPath runtime context, and return the
result of the expression.
xctxt
- The XPath runtime context.
NEEDSDOC @param handler
fixupVariables
public abstract void fixupVariables(Vector vars,
int globalsSize)
This function is used to fixup variables from QNames to stack frame
indexes at stylesheet build time.
vars
- List of QNames that correspond to variables. This list
should be searched backwards for the first qualified name that
corresponds to the variable reference qname. The position of the
QName in the vector from the start of the vector will be its position
in the stack frame (but variables above the globalsTop value will need
to be offset to the current stack frame).
NEEDSDOC @param globalsSize
getColumnNumber
public int getColumnNumber()
Return the character position where the current document event ends.
Warning: The return value from the method
is intended only as an approximation for the sake of error
reporting; it is not intended to provide sufficient information
to edit the character content of the original XML document.
The return value is an approximation of the column number
in the document entity or external parsed entity where the
markup that triggered the event appears.
- The column number, or -1 if none is available.
getExpressionOwner
public ExpressionNode getExpressionOwner()
Get the first non-Expression parent of this node.
- null or first ancestor that is not an Expression.
getLineNumber
public int getLineNumber()
Return the line number where the current document event ends.
Warning: The return value from the method
is intended only as an approximation for the sake of error
reporting; it is not intended to provide sufficient information
to edit the character content of the original XML document.
The return value is an approximation of the line number
in the document entity or external parsed entity where the
markup that triggered the event appears.
- The line number, or -1 if none is available.
getPublicId
public String getPublicId()
Return the public identifier for the current document event.
The return value is the public identifier of the document
entity or of the external parsed entity in which the markup that
triggered the event appears.
- A string containing the public identifier, or
null if none is available.
getSystemId
public String getSystemId()
Return the system identifier for the current document event.
The return value is the system identifier of the document
entity or of the external parsed entity in which the markup that
triggered the event appears.
If the system identifier is a URL, the parser must resolve it
fully before passing it to the application.
- A string containing the system identifier, or null
if none is available.
isNodesetExpr
public boolean isNodesetExpr()
Tell if the expression is a nodeset expression. In other words, tell
if you can execute asNode
without an exception.
- true if the expression can be represented as a nodeset.
isStableNumber
public boolean isStableNumber()
Tell if this expression returns a stable number that will not change during
iterations within the expression. This is used to determine if a proximity
position predicate can indicate that no more searching has to occur.
- true if the expression represents a stable number.
num
public double num(XPathContext xctxt)
throws TransformerException
Evaluate expression to a number.
xctxt
- The XPath runtime context.
- The expression evaluated as a double.
warn
public void warn(XPathContext xctxt,
String msg,
Object[] args)
throws TransformerException
Warn the user of an problem.
xctxt
- The XPath runtime context.msg
- An error msgkey that corresponds to one of the conststants 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.