BEA Systems, Inc.


weblogic.apache.xpath
Class Expression

java.lang.Object
  |
  +--weblogic.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.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.

See Also:
Serialized Form

Field Summary
protected  javax.xml.transform.SourceLocator m_slocator
          The location where this expression was built from.
 
Constructor Summary
Expression()
           
 
Method Summary
 weblogic.apache.xml.dtm.DTMIterator asIterator(XPathContext xctxt, int contextNode)
           Given an select expression and a context, evaluate the XPath and return the resulting iterator.
 int asNode(XPathContext xctxt)
          Return the first node out of the nodeset, if this expression is a nodeset expression.
 void assertion(boolean b, java.lang.String msg)
          Tell the user of an assertion error, and probably throw an exception.
 boolean bool(XPathContext xctxt)
          Evaluate expression to a boolean.
 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.
 XObject execute(XPathContext xctxt, int currentNode)
          Execute an expression in the XPath runtime context, and return the result of the expression.
 XObject execute(XPathContext xctxt, int currentNode, weblogic.apache.xml.dtm.DTM dtm, int expType)
          Execute an expression in the XPath runtime context, and return the result of the expression.
 void executeCharsToContentHandler(XPathContext xctxt, org.xml.sax.ContentHandler handler)
          Execute an expression in the XPath runtime context, and return the result of the expression.
abstract  void fixupVariables(java.util.Vector vars, int globalsSize)
          This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.
 boolean isNodesetExpr()
          Tell if the expression is a nodeset expression.
 boolean isStableNumber()
          Tell if this expression returns a stable number that will not change during iterations within the expression.
 double num(XPathContext xctxt)
          Evaluate expression to a number.
 void setSourceLocator(javax.xml.transform.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.
 XMLString xstr(XPathContext xctxt)
          Cast result object to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_slocator

protected javax.xml.transform.SourceLocator m_slocator
The location where this expression was built from. Need for diagnostic messages. May be null.
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(javax.xml.transform.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 XObject execute(XPathContext xctxt,
                       int currentNode)
                throws javax.xml.transform.TransformerException
Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters:
xctxt - The XPath runtime context.
currentNode - The currentNode.
Returns:
The result of the expression in the form of a XObject.
Throws:
javax.xml.transform.TransformerException - if a runtime exception occurs.

execute

public XObject execute(XPathContext xctxt,
                       int currentNode,
                       weblogic.apache.xml.dtm.DTM dtm,
                       int expType)
                throws javax.xml.transform.TransformerException
Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters:
xctxt - The XPath runtime context.
currentNode - The currentNode.
dtm - The DTM of the current node.
expType - The expanded type ID of the current node.
Returns:
The result of the expression in the form of a XObject.
Throws:
javax.xml.transform.TransformerException - if a runtime exception occurs.

execute

public abstract XObject execute(XPathContext xctxt)
                         throws javax.xml.transform.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:
javax.xml.transform.TransformerException - if a runtime exception occurs.

num

public double num(XPathContext xctxt)
           throws javax.xml.transform.TransformerException
Evaluate expression to a number. NEEDSDOC @param xctxt

Returns:
0.0
Throws:
javax.xml.transform.TransformerException -  

bool

public boolean bool(XPathContext xctxt)
             throws javax.xml.transform.TransformerException
Evaluate expression to a boolean. NEEDSDOC @param xctxt

Returns:
false
Throws:
javax.xml.transform.TransformerException -  

xstr

public XMLString xstr(XPathContext xctxt)
               throws javax.xml.transform.TransformerException
Cast result object to a string. NEEDSDOC @param xctxt

Returns:
The string this wraps or the empty string if null
Throws:
javax.xml.transform.TransformerException -  

isNodesetExpr

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

Returns:
true if the expression can be represented as a nodeset.

asNode

public int asNode(XPathContext xctxt)
           throws javax.xml.transform.TransformerException
Return the first node out of the nodeset, if this expression is a nodeset expression.

Parameters:
xctxt - The XPath runtime context.
Returns:
the first node out of the nodeset, or DTM.NULL.
Throws:
javax.xml.transform.TransformerException -  

asIterator

public weblogic.apache.xml.dtm.DTMIterator asIterator(XPathContext xctxt,
                                                      int contextNode)
                                               throws javax.xml.transform.TransformerException
Given an select expression and a context, evaluate the XPath and return the resulting iterator.

Parameters:
xctxt - The execution context.
contextNode - The node that "." expresses. NEEDSDOC ($objectName$) @return
Throws:
javax.xml.transform.TransformerException - thrown if the active ProblemListener decides the error condition is severe enough to halt processing.
javax.xml.transform.TransformerException -  

executeCharsToContentHandler

public void executeCharsToContentHandler(XPathContext xctxt,
                                         org.xml.sax.ContentHandler handler)
                                  throws javax.xml.transform.TransformerException,
                                         org.xml.sax.SAXException
Execute an expression in the XPath runtime context, and return the result of the expression.

Parameters:
xctxt - The XPath runtime context. NEEDSDOC @param handler
Returns:
The result of the expression in the form of a XObject.
Throws:
javax.xml.transform.TransformerException - if a runtime exception occurs.
org.xml.sax.SAXException -  

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.

Returns:
true if the expression represents a stable number.

fixupVariables

public abstract void fixupVariables(java.util.Vector vars,
                                    int globalsSize)
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.

Parameters:
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

warn

public void warn(XPathContext xctxt,
                 int msg,
                 java.lang.Object[] args)
          throws javax.xml.transform.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:
javax.xml.transform.TransformerException - if the current ErrorListoner determines to throw an exception.
javax.xml.transform.TransformerException -  

assertion

public void assertion(boolean b,
                      java.lang.String msg)
               throws javax.xml.transform.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.
javax.xml.transform.TransformerException -  

error

public void error(XPathContext xctxt,
                  int msg,
                  java.lang.Object[] args)
           throws javax.xml.transform.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:
javax.xml.transform.TransformerException - if the current ErrorListoner determines to throw an exception.
javax.xml.transform.TransformerException -  

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs70

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference