Top Description Fields Constructors Methods
com.sun.org.apache.xpath.internal

public abstract Class Expression

extends Object
implements Serializable, ExpressionNode, XPathVisitable
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xpath.internal.XPathVisitable, com.sun.org.apache.xpath.internal.ExpressionNode, javax.xml.transform.SourceLocator, java.io.Serializable
Known Direct Subclasses
com.sun.org.apache.xpath.internal.functions.Function, com.sun.org.apache.xpath.internal.objects.XObject, com.sun.org.apache.xpath.internal.operations.Operation, com.sun.org.apache.xpath.internal.operations.UnaryOperation, com.sun.org.apache.xpath.internal.operations.Variable, com.sun.org.apache.xpath.internal.patterns.NodeTest, com.sun.org.apache.xpath.internal.patterns.UnionPattern
Imports
com.sun.org.apache.xalan.internal.res.XSLMessages, com.sun.org.apache.xml.internal.dtm.DTM, .DTMIterator, com.sun.org.apache.xml.internal.utils.QName, .XMLString, com.sun.org.apache.xpath.internal.objects.XNodeSet, .XObject, com.sun.org.apache.xpath.internal.res.XPATHErrorResources, java.util.List, javax.xml.transform.ErrorListener, .TransformerException, org.xml.sax.ContentHandler

This abstract class serves as the base for all expression objects. An Expression can be executed to return a com.sun.org.apache.xpath.internal.objects.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.

Field Summary

Modifier and TypeField and Description
private ExpressionNode
m_parent

The location where this expression was built from.

pack-priv static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public DTMIterator

Returns:

A valid DTMIterator.
asIterator
(XPathContext
The execution context.
xctxt
,
int
The node that "." expresses.
contextNode
)

Given an select expression and a context, evaluate the XPath and return the resulting iterator.

public DTMIterator

Returns:

A valid DTMIterator.
asIteratorRaw
(XPathContext
The execution context.
xctxt
,
int
The node that "." expresses.
contextNode
)

Given an select expression and a context, evaluate the XPath and return the resulting iterator, but do not clone.

public int

Returns:

the first node out of the nodeset, or DTM.NULL.
asNode
(XPathContext
The XPath runtime context.
xctxt
)

Return the first node out of the nodeset, if this expression is a nodeset expression.

public void
assertion(boolean
If false, a runtime exception will be thrown.
b
,
String
The assertion message, which should be informative.
msg
)

Tell the user of an assertion error, and probably throw an exception.

public boolean

Returns:

false
bool
(XPathContext
The XPath runtime context.
xctxt
)

Evaluate expression to a boolean.

public boolean

Returns:

true if traversal outside the context node's subtree can occur.
canTraverseOutsideSubtree
()

Tell if this expression or it's subexpressions can traverse outside the current subtree.

public abstract boolean

Returns:

true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.
deepEquals
(Expression
Another expression object.
expr
)

Compare this object with another object and see if they are equal, include the sub heararchy.

public void
error(XPathContext
The XPath runtime context.
xctxt
,
String
An error msgkey that corresponds to one of the constants found in com.sun.org.apache.xpath.internal.res.XPATHErrorResources, which is a key for a format string.
msg
,
Object[]
An array of arguments represented in the format string, which may be null.
args
)

Tell the user of an error, and probably throw an exception.

public XObject

Returns:

The result of the expression in the form of a XObject.
execute
(XPathContext
The XPath runtime context.
xctxt
,
int
The currentNode.
currentNode
)

Execute an expression in the XPath runtime context, and return the result of the expression.

public XObject

Returns:

The result of the expression in the form of a XObject.
execute
(XPathContext
The XPath runtime context.
xctxt
,
int
The currentNode.
currentNode
,
DTM
The DTM of the current node.
dtm
,
int
The expanded type ID of the current node.
expType
)

Execute an expression in the XPath runtime context, and return the result of the expression.

public abstract XObject

Returns:

The result of the expression in the form of a XObject.
execute
(XPathContext
The XPath runtime context.
xctxt
)

Execute an expression in the XPath runtime context, and return the result of the expression.

public XObject

Returns:

The result of the expression in the form of a XObject.
execute
(XPathContext
The XPath runtime context.
xctxt
,
boolean
true if a "safe" object doesn't need to be returned.
destructiveOK
)

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.

public void

Returns:

The result of the expression in the form of a XObject.
executeCharsToContentHandler
(XPathContext
The XPath runtime context. NEEDSDOC @param handler
xctxt
,
ContentHandler handler)

Execute an expression in the XPath runtime context, and return the result of the expression.

public void
exprAddChild(ExpressionNode n, int i)

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprAddChild.

This method tells the node to add its argument to the node's list of children.

public ExpressionNode
exprGetChild(int i)

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprGetChild.

This method returns a child node.

public int
exprGetNumChildren()

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprGetNumChildren.

Return the number of children the node has.

public ExpressionNode
public void
exprSetParent(ExpressionNode n)

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprSetParent.

This pair of methods are used to inform the node of its parent.

public abstract void
fixupVariables(List<QName>
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
vars
,
int globalsSize)

This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

public int

Returns:

The column number, or -1 if none is available.
getColumnNumber
()

Implements javax.xml.transform.SourceLocator.getColumnNumber.

Return the character position where the current document event ends.

public ExpressionNode

Returns:

null or first ancestor that is not an Expression.
getExpressionOwner
()

Get the first non-Expression parent of this node.

public int

Returns:

The line number, or -1 if none is available.
getLineNumber
()

Implements javax.xml.transform.SourceLocator.getLineNumber.

Return the line number where the current document event ends.

public String

Returns:

A string containing the public identifier, or null if none is available.
getPublicId
()

Implements javax.xml.transform.SourceLocator.getPublicId.

Return the public identifier for the current document event.

public String

Returns:

A string containing the system identifier, or null if none is available.
getSystemId
()

Implements javax.xml.transform.SourceLocator.getSystemId.

Return the system identifier for the current document event.

public boolean

Returns:

true if the expression can be represented as a nodeset.
isNodesetExpr
()

Tell if the expression is a nodeset expression.

protected final boolean

Returns:

true of the passed in class is the exact same class as this class.
isSameClass
(Expression expr)

This is a utility method to tell if the passed in class is the same class as this.

public boolean

Returns:

true if the expression represents a stable number.
isStableNumber
()

Tell if this expression returns a stable number that will not change during iterations within the expression.

public double

Returns:

The expression evaluated as a double.
num
(XPathContext
The XPath runtime context.
xctxt
)

Evaluate expression to a number.

public void
warn(XPathContext
The XPath runtime context.
xctxt
,
String
An error msgkey that corresponds to one of the conststants found in com.sun.org.apache.xpath.internal.res.XPATHErrorResources, which is a key for a format string.
msg
,
Object[]
An array of arguments represented in the format string, which may be null.
args
)

Warn the user of an problem.

public XMLString

Returns:

The string this wraps or the empty string if null
xstr
(XPathContext
The XPath runtime context.
xctxt
)

Cast result object to a string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_parentback to summary
private ExpressionNode m_parent

The location where this expression was built from. Need for diagnostic messages. May be null.

Annotations
@SuppressWarnings:serial
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Constructor Detail

Expressionback to summary
public Expression()

Method Detail

asIteratorback to summary
public DTMIterator asIterator(XPathContext xctxt, int contextNode) throws TransformerException

Given an select expression and a context, evaluate the XPath and return the resulting iterator.

Parameters
xctxt:XPathContext

The execution context.

contextNode:int

The node that "." expresses.

Returns:DTMIterator

A valid DTMIterator.

Exceptions
TransformerException:
thrown if the active ProblemListener decides the error condition is severe enough to halt processing.
asIteratorRawback to summary
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.

Parameters
xctxt:XPathContext

The execution context.

contextNode:int

The node that "." expresses.

Returns:DTMIterator

A valid DTMIterator.

Exceptions
TransformerException:
thrown if the active ProblemListener decides the error condition is severe enough to halt processing.
asNodeback to summary
public int asNode(XPathContext xctxt) throws TransformerException

Return the first node out of the nodeset, if this expression is a nodeset expression.

Parameters
xctxt:XPathContext

The XPath runtime context.

Returns:int

the first node out of the nodeset, or DTM.NULL.

assertionback to summary
public void assertion(boolean b, String msg)

Tell the user of an assertion error, and probably throw an exception.

Parameters
b:boolean

If false, a runtime exception will be thrown.

msg:String

The assertion message, which should be informative.

Exceptions
RuntimeException:
if the b argument is false.
boolback to summary
public boolean bool(XPathContext xctxt) throws TransformerException

Evaluate expression to a boolean.

Parameters
xctxt:XPathContext

The XPath runtime context.

Returns:boolean

false

canTraverseOutsideSubtreeback to summary
public boolean canTraverseOutsideSubtree()

Tell if this expression or it's subexpressions can traverse outside the current subtree.

Returns:boolean

true if traversal outside the context node's subtree can occur.

deepEqualsback to summary
public abstract boolean deepEquals(Expression expr)

Compare this object with another object and see if they are equal, include the sub heararchy.

Parameters
expr:Expression

Another expression object.

Returns:boolean

true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.

errorback to summary
public void error(XPathContext xctxt, String msg, Object[] args) throws TransformerException

Tell the user of an error, and probably throw an exception.

Parameters
xctxt:XPathContext

The XPath runtime context.

msg:String

An error msgkey that corresponds to one of the constants found in com.sun.org.apache.xpath.internal.res.XPATHErrorResources, which is a key for a format string.

args:Object[]

An array of arguments represented in the format string, which may be null.

Exceptions
TransformerException:
if the current ErrorListoner determines to throw an exception.
executeback to summary
public XObject execute(XPathContext xctxt, int currentNode) throws TransformerException

Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters
xctxt:XPathContext

The XPath runtime context.

currentNode:int

The currentNode.

Returns:XObject

The result of the expression in the form of a XObject.

Exceptions
TransformerException:
if a runtime exception occurs.
executeback to summary
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.

Parameters
xctxt:XPathContext

The XPath runtime context.

currentNode:int

The currentNode.

dtm:DTM

The DTM of the current node.

expType:int

The expanded type ID of the current node.

Returns:XObject

The result of the expression in the form of a XObject.

Exceptions
TransformerException:
if a runtime exception occurs.
executeback to summary
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:XPathContext

The XPath runtime context.

Returns:XObject

The result of the expression in the form of a XObject.

Exceptions
TransformerException:
if a runtime exception occurs.
executeback to summary
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).

Parameters
xctxt:XPathContext

The XPath runtime context.

destructiveOK:boolean

true if a "safe" object doesn't need to be returned.

Returns:XObject

The result of the expression in the form of a XObject.

Exceptions
TransformerException:
if a runtime exception occurs.
executeCharsToContentHandlerback to summary
public void executeCharsToContentHandler(XPathContext xctxt, ContentHandler handler) throws TransformerException, SAXException

Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters
xctxt:XPathContext

The XPath runtime context. NEEDSDOC @param handler

Returns:void

The result of the expression in the form of a XObject.

Exceptions
TransformerException:
if a runtime exception occurs.
exprAddChildback to summary
public void exprAddChild(ExpressionNode n, int i)

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprAddChild.

This method tells the node to add its argument to the node's list of children.

exprGetChildback to summary
public ExpressionNode exprGetChild(int i)

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprGetChild.

This method returns a child node. The children are numbered from zero, left to right.

exprGetNumChildrenback to summary
public int exprGetNumChildren()

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprGetNumChildren.

Return the number of children the node has.

exprGetParentback to summary
public ExpressionNode exprGetParent()

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprGetParent.

exprSetParentback to summary
public void exprSetParent(ExpressionNode n)

Implements com.sun.org.apache.xpath.internal.ExpressionNode.exprSetParent.

This pair of methods are used to inform the node of its parent.

fixupVariablesback to summary
public abstract void fixupVariables(List<QName> vars, int globalsSize)

This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

Parameters
vars:List<QName>

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

getColumnNumberback to summary
public int getColumnNumber()

Implements javax.xml.transform.SourceLocator.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.

Returns:int

The column number, or -1 if none is available.

See Also
getLineNumber
getExpressionOwnerback to summary
public ExpressionNode getExpressionOwner()

Get the first non-Expression parent of this node.

Returns:ExpressionNode

null or first ancestor that is not an Expression.

getLineNumberback to summary
public int getLineNumber()

Implements javax.xml.transform.SourceLocator.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.

Returns:int

The line number, or -1 if none is available.

See Also
getColumnNumber
getPublicIdback to summary
public String getPublicId()

Implements javax.xml.transform.SourceLocator.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.

Returns:String

A string containing the public identifier, or null if none is available.

See Also
getSystemId
getSystemIdback to summary
public String getSystemId()

Implements javax.xml.transform.SourceLocator.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.

Returns:String

A string containing the system identifier, or null if none is available.

See Also
getPublicId
isNodesetExprback to summary
public boolean isNodesetExpr()

Tell if the expression is a nodeset expression. In other words, tell if you can execute asNode without an exception.

Returns:boolean

true if the expression can be represented as a nodeset.

isSameClassback to summary
protected final boolean isSameClass(Expression expr)

This is a utility method to tell if the passed in class is the same class as this. It is to be used by the deepEquals method. I'm bottlenecking it here because I'm not totally confident that comparing the class objects is the best way to do this.

Returns:boolean

true of the passed in class is the exact same class as this class.

isStableNumberback to summary
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.

Returns:boolean

true if the expression represents a stable number.

numback to summary
public double num(XPathContext xctxt) throws TransformerException

Evaluate expression to a number.

Parameters
xctxt:XPathContext

The XPath runtime context.

Returns:double

The expression evaluated as a double.

warnback to summary
public void warn(XPathContext xctxt, String msg, Object[] args) throws TransformerException

Warn the user of an problem.

Parameters
xctxt:XPathContext

The XPath runtime context.

msg:String

An error msgkey that corresponds to one of the conststants found in com.sun.org.apache.xpath.internal.res.XPATHErrorResources, which is a key for a format string.

args:Object[]

An array of arguments represented in the format string, which may be null.

Exceptions
TransformerException:
if the current ErrorListoner determines to throw an exception.
xstrback to summary
public XMLString xstr(XPathContext xctxt) throws TransformerException

Cast result object to a string.

Parameters
xctxt:XPathContext

The XPath runtime context.

Returns:XMLString

The string this wraps or the empty string if null