com.caucho.xpath
Class Expr

java.lang.Object
  extended by com.caucho.xpath.Expr
Direct Known Subclasses:
AbstractNumberExpr, AbstractStringExpr, BooleanExpr, FunExpr, IdExpr, NewJavaExpr, NodeSetExpr, NumericExpr, ObjectExpr, ObjectJavaExpr, StaticJavaExpr, StringExpr, VarExpr

public abstract class Expr
extends java.lang.Object

Compute values from nodes. Because the expressions themselves are untyped, the class provides methods for creating the type of the desired result.


Field Summary
protected static int ADD
           
protected static int AND
           
protected static int ATTRIBUTE
           
protected static int BASE_URI
           
protected static int BOOLEAN
           
protected static int BOOLEAN_EQ
           
protected static int BOOLEAN_NEQ
           
protected static int CEILING
           
protected static int CONCAT
           
protected static int CONST
           
protected static int CONTAINS
           
protected static int COUNT
           
protected static int DIV
           
protected static int ELEMENT
           
protected static int EQ
           
protected static int FALSE
           
protected static int FLOOR
           
protected static int FORMAT_NUMBER
           
protected static int FUNCTION_AVAILABLE
           
protected static int GE
           
protected static int GENERATE_ID
           
protected static int GT
           
protected static int ID
           
protected static int IF
           
protected static int LANG
           
protected static int LAST
           
protected static int LAST_FUN
           
protected static int LE
           
protected static int LOCAL_PART
           
protected static int LT
           
protected static int MOD
           
protected static int MUL
           
protected static int NAMESPACE
           
protected static int NEG
           
protected static int NEQ
           
protected static int NODE_SET
           
protected static int NORMALIZE
           
protected static int NOT
           
protected static int NUMBER
           
protected static int NUMBER_EQ
           
protected static int NUMBER_GE
           
protected static int NUMBER_GT
           
protected static int NUMBER_LE
           
protected static int NUMBER_LT
           
protected static int NUMBER_NEQ
           
protected static int OR
           
static int POSITION
           
protected static int QNAME
           
protected static int QUO
           
protected static int ROUND
           
protected static int SELF
           
protected static int SELF_NAME
           
protected static int STARTS_WITH
           
protected static int STRING
           
protected static int STRING_EQ
           
protected static int STRING_LENGTH
           
protected static int STRING_NEQ
           
protected static int SUB
           
protected static int SUBSTRING
           
protected static int SUBSTRING_AFTER
           
protected static int SUBSTRING_BEFORE
           
protected static int SUM
           
protected static int SYSTEM_PROPERTY
           
protected static int TRANSLATE
           
protected static int TRUE
           
 
Constructor Summary
protected Expr()
           
 
Method Summary
 void addParam(Env newEnv, java.lang.String name, org.w3c.dom.Node node, Env env)
          Adds a param with the expression's value.
 void addVar(Env newEnv, java.lang.String name, org.w3c.dom.Node node, Env env)
          Adds a variable with the expression's value.
 boolean evalBoolean(org.w3c.dom.Node node)
          Returns the boolean value of the node.
abstract  boolean evalBoolean(org.w3c.dom.Node node, ExprEnvironment env)
          Returns the boolean value of the node.
 NodeIterator evalNodeSet(org.w3c.dom.Node node)
          Returns an iterator of matching nodes
 NodeIterator evalNodeSet(org.w3c.dom.Node node, ExprEnvironment env)
          Returns an iterator of matching nodes
 double evalNumber(org.w3c.dom.Node node)
          Evaluates the expression as a double using the node as a context.
abstract  double evalNumber(org.w3c.dom.Node node, ExprEnvironment env)
          Evaluates the expression as a number.
 java.lang.Object evalObject(org.w3c.dom.Node node)
          Returns the object value of the node.
abstract  java.lang.Object evalObject(org.w3c.dom.Node node, ExprEnvironment env)
          Returns the object value of the node.
 void evalString(CharBuffer cb, org.w3c.dom.Node node)
          Fills a char buffer with the evaluated string results.
 void evalString(CharBuffer cb, org.w3c.dom.Node node, ExprEnvironment env)
          Fills a char buffer with the evaluated string results.
 java.lang.String evalString(org.w3c.dom.Node node)
          Returns the expression evaluated as a string.
abstract  java.lang.String evalString(org.w3c.dom.Node node, ExprEnvironment env)
          Returns the string value of the node.
 Var evalVar(org.w3c.dom.Node node, ExprEnvironment env)
          Evaluates to a variable.
 AbstractPattern getListContext()
           
 boolean isBoolean()
          true if the expression prefers to return a boolean.
 boolean isNodeSet()
          true if the expression prefers to return a node set.
 boolean isNumber()
          true if the expression prefers to return a number.
 boolean isString()
          true if the expression prefers to return a string.
 void setListContext(AbstractPattern listContext)
           
 void setVar(java.lang.String name, org.w3c.dom.Node node, Env env)
          Sets a variable with the expression's value.
protected static double stringToNumber(java.lang.String string)
          Convert a string to a double following XPath.
static boolean toBoolean(java.lang.Object value)
          Convert a Java object to a boolean using the XPath rules.
static double toDouble(java.lang.Object value)
          Convert a Java object to a double using the XPath rules.
static org.w3c.dom.Node toNode(java.lang.Object value)
          Convert a Java object to a node using the XPath rules.
protected  AbstractPattern toNodeList()
          Convert from an expression to a pattern.
static java.lang.String toString(java.lang.Object value)
          Convert a Java object to a string using the XPath rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONST

protected static final int CONST
See Also:
Constant Field Values

NODE_SET

protected static final int NODE_SET
See Also:
Constant Field Values

ID

protected static final int ID
See Also:
Constant Field Values

OR

protected static final int OR
See Also:
Constant Field Values

AND

protected static final int AND
See Also:
Constant Field Values

EQ

protected static final int EQ
See Also:
Constant Field Values

NEQ

protected static final int NEQ
See Also:
Constant Field Values

LT

protected static final int LT
See Also:
Constant Field Values

LE

protected static final int LE
See Also:
Constant Field Values

GT

protected static final int GT
See Also:
Constant Field Values

GE

protected static final int GE
See Also:
Constant Field Values

BOOLEAN_EQ

protected static final int BOOLEAN_EQ
See Also:
Constant Field Values

BOOLEAN_NEQ

protected static final int BOOLEAN_NEQ
See Also:
Constant Field Values

NUMBER_EQ

protected static final int NUMBER_EQ
See Also:
Constant Field Values

NUMBER_NEQ

protected static final int NUMBER_NEQ
See Also:
Constant Field Values

NUMBER_LT

protected static final int NUMBER_LT
See Also:
Constant Field Values

NUMBER_LE

protected static final int NUMBER_LE
See Also:
Constant Field Values

NUMBER_GT

protected static final int NUMBER_GT
See Also:
Constant Field Values

NUMBER_GE

protected static final int NUMBER_GE
See Also:
Constant Field Values

STRING_EQ

protected static final int STRING_EQ
See Also:
Constant Field Values

STRING_NEQ

protected static final int STRING_NEQ
See Also:
Constant Field Values

NEG

protected static final int NEG
See Also:
Constant Field Values

ADD

protected static final int ADD
See Also:
Constant Field Values

SUB

protected static final int SUB
See Also:
Constant Field Values

MUL

protected static final int MUL
See Also:
Constant Field Values

DIV

protected static final int DIV
See Also:
Constant Field Values

QUO

protected static final int QUO
See Also:
Constant Field Values

MOD

protected static final int MOD
See Also:
Constant Field Values

TRUE

protected static final int TRUE
See Also:
Constant Field Values

FALSE

protected static final int FALSE
See Also:
Constant Field Values

NOT

protected static final int NOT
See Also:
Constant Field Values

BOOLEAN

protected static final int BOOLEAN
See Also:
Constant Field Values

LANG

protected static final int LANG
See Also:
Constant Field Values

NUMBER

protected static final int NUMBER
See Also:
Constant Field Values

SUM

protected static final int SUM
See Also:
Constant Field Values

FLOOR

protected static final int FLOOR
See Also:
Constant Field Values

CEILING

protected static final int CEILING
See Also:
Constant Field Values

ROUND

protected static final int ROUND
See Also:
Constant Field Values

POSITION

public static final int POSITION
See Also:
Constant Field Values

COUNT

protected static final int COUNT
See Also:
Constant Field Values

LAST

protected static final int LAST
See Also:
Constant Field Values

STRING

protected static final int STRING
See Also:
Constant Field Values

CONCAT

protected static final int CONCAT
See Also:
Constant Field Values

STARTS_WITH

protected static final int STARTS_WITH
See Also:
Constant Field Values

CONTAINS

protected static final int CONTAINS
See Also:
Constant Field Values

SUBSTRING

protected static final int SUBSTRING
See Also:
Constant Field Values

SUBSTRING_BEFORE

protected static final int SUBSTRING_BEFORE
See Also:
Constant Field Values

SUBSTRING_AFTER

protected static final int SUBSTRING_AFTER
See Also:
Constant Field Values

STRING_LENGTH

protected static final int STRING_LENGTH
See Also:
Constant Field Values

NORMALIZE

protected static final int NORMALIZE
See Also:
Constant Field Values

TRANSLATE

protected static final int TRANSLATE
See Also:
Constant Field Values

FORMAT_NUMBER

protected static final int FORMAT_NUMBER
See Also:
Constant Field Values

LOCAL_PART

protected static final int LOCAL_PART
See Also:
Constant Field Values

NAMESPACE

protected static final int NAMESPACE
See Also:
Constant Field Values

QNAME

protected static final int QNAME
See Also:
Constant Field Values

GENERATE_ID

protected static final int GENERATE_ID
See Also:
Constant Field Values

FUNCTION_AVAILABLE

protected static final int FUNCTION_AVAILABLE
See Also:
Constant Field Values

SYSTEM_PROPERTY

protected static final int SYSTEM_PROPERTY
See Also:
Constant Field Values

IF

protected static final int IF
See Also:
Constant Field Values

SELF

protected static final int SELF
See Also:
Constant Field Values

SELF_NAME

protected static final int SELF_NAME
See Also:
Constant Field Values

ATTRIBUTE

protected static final int ATTRIBUTE
See Also:
Constant Field Values

ELEMENT

protected static final int ELEMENT
See Also:
Constant Field Values

BASE_URI

protected static final int BASE_URI
See Also:
Constant Field Values

LAST_FUN

protected static final int LAST_FUN
See Also:
Constant Field Values
Constructor Detail

Expr

protected Expr()
Method Detail

setListContext

public void setListContext(AbstractPattern listContext)

getListContext

public AbstractPattern getListContext()

isNumber

public boolean isNumber()
true if the expression prefers to return a number.


evalNumber

public double evalNumber(org.w3c.dom.Node node)
                  throws XPathException
Evaluates the expression as a double using the node as a context.

Parameters:
node - the node to evaluate and use as a context
Returns:
the numeric value.
Throws:
XPathException

evalNumber

public abstract double evalNumber(org.w3c.dom.Node node,
                                  ExprEnvironment env)
                           throws XPathException
Evaluates the expression as a number.

Parameters:
node - the current node.
env - variable environment.
Returns:
the numeric value.
Throws:
XPathException

isBoolean

public boolean isBoolean()
true if the expression prefers to return a boolean.


evalBoolean

public boolean evalBoolean(org.w3c.dom.Node node)
                    throws XPathException
Returns the boolean value of the node.

Parameters:
node - the node to evaluate and use as a context
Returns:
the boolean value
Throws:
XPathException

evalBoolean

public abstract boolean evalBoolean(org.w3c.dom.Node node,
                                    ExprEnvironment env)
                             throws XPathException
Returns the boolean value of the node.

Parameters:
node - the node to evaluate and use as a context
env - variable environment.
Returns:
the boolean value.
Throws:
XPathException

evalString

public java.lang.String evalString(org.w3c.dom.Node node)
                            throws XPathException
Returns the expression evaluated as a string.

Parameters:
node - the node to evaluate and use as a context
Returns:
the string value of the expression.
Throws:
XPathException

isString

public boolean isString()
true if the expression prefers to return a string.


evalString

public abstract java.lang.String evalString(org.w3c.dom.Node node,
                                            ExprEnvironment env)
                                     throws XPathException
Returns the string value of the node.

Parameters:
node - the node to evaluate and use as a context
env - variable environment.
Throws:
XPathException

evalString

public void evalString(CharBuffer cb,
                       org.w3c.dom.Node node)
                throws XPathException
Fills a char buffer with the evaluated string results.

Parameters:
cb - the buffer containing the results.
node - the node to evaluate and use as a context
Throws:
XPathException

evalString

public void evalString(CharBuffer cb,
                       org.w3c.dom.Node node,
                       ExprEnvironment env)
                throws XPathException
Fills a char buffer with the evaluated string results.

Parameters:
cb - the buffer containing the results.
node - the node to evaluate and use as a context
env - the variable environment
Throws:
XPathException

isNodeSet

public boolean isNodeSet()
true if the expression prefers to return a node set.


evalNodeSet

public NodeIterator evalNodeSet(org.w3c.dom.Node node)
                         throws XPathException
Returns an iterator of matching nodes

Parameters:
node - the node to evaluate and use as a context
Returns:
the value as a node iterator.
Throws:
XPathException

evalNodeSet

public NodeIterator evalNodeSet(org.w3c.dom.Node node,
                                ExprEnvironment env)
                         throws XPathException
Returns an iterator of matching nodes

Parameters:
node - the node to evaluate and use as a context
env - variable environment.
Returns:
the value as a node iterator.
Throws:
XPathException

evalObject

public java.lang.Object evalObject(org.w3c.dom.Node node)
                            throws XPathException
Returns the object value of the node.

Parameters:
node - the node to evaluate and use as a context
Throws:
XPathException

evalObject

public abstract java.lang.Object evalObject(org.w3c.dom.Node node,
                                            ExprEnvironment env)
                                     throws XPathException
Returns the object value of the node.

Parameters:
node - the node to evaluate and use as a context
env - variable environment.
Throws:
XPathException

evalVar

public Var evalVar(org.w3c.dom.Node node,
                   ExprEnvironment env)
            throws XPathException
Evaluates to a variable.

Parameters:
node - the node to evaluate and use as a context.
env - the variable environment.
Returns:
a variable containing the value.
Throws:
XPathException

addVar

public void addVar(Env newEnv,
                   java.lang.String name,
                   org.w3c.dom.Node node,
                   Env env)
            throws XPathException
Adds a variable with the expression's value.

Throws:
XPathException

setVar

public void setVar(java.lang.String name,
                   org.w3c.dom.Node node,
                   Env env)
            throws XPathException
Sets a variable with the expression's value.

Throws:
XPathException

addParam

public void addParam(Env newEnv,
                     java.lang.String name,
                     org.w3c.dom.Node node,
                     Env env)
              throws XPathException
Adds a param with the expression's value.

Throws:
XPathException

toBoolean

public static boolean toBoolean(java.lang.Object value)
                         throws XPathException
Convert a Java object to a boolean using the XPath rules.

Throws:
XPathException

toDouble

public static double toDouble(java.lang.Object value)
                       throws XPathException
Convert a Java object to a double using the XPath rules.

Throws:
XPathException

toString

public static java.lang.String toString(java.lang.Object value)
                                 throws XPathException
Convert a Java object to a string using the XPath rules.

Throws:
XPathException

toNode

public static org.w3c.dom.Node toNode(java.lang.Object value)
                               throws XPathException
Convert a Java object to a node using the XPath rules.

Throws:
XPathException

stringToNumber

protected static double stringToNumber(java.lang.String string)
                                throws XPathException
Convert a string to a double following XPath.

Parameters:
string - string to be treated as a double.
Returns:
the double value.
Throws:
XPathException

toNodeList

protected AbstractPattern toNodeList()
Convert from an expression to a pattern.