com.caucho.xpath
Class Expr

java.lang.Object
  |
  +--com.caucho.xpath.Expr

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 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, Node node, Env env)
          Adds a param with the expression's value.
 void addVar(Env newEnv, java.lang.String name, Node node, Env env)
          Adds a variable with the expression's value.
 boolean evalBoolean(Node node)
          Returns the boolean value of the node.
abstract  boolean evalBoolean(Node node, ExprEnvironment env)
          Returns the boolean value of the node.
 com.caucho.xpath.pattern.NodeIterator evalNodeSet(Node node)
          Returns an iterator of matching nodes
 com.caucho.xpath.pattern.NodeIterator evalNodeSet(Node node, ExprEnvironment env)
          Returns an iterator of matching nodes
 double evalNumber(Node node)
          Evaluates the expression as a double using the node as a context.
abstract  double evalNumber(Node node, ExprEnvironment env)
          Evaluates the expression as a number.
 java.lang.Object evalObject(Node node)
          Returns the object value of the node.
abstract  java.lang.Object evalObject(Node node, ExprEnvironment env)
          Returns the object value of the node.
 void evalString(CharBuffer cb, Node node)
          Fills a char buffer with the evaluated string results.
 void evalString(CharBuffer cb, Node node, ExprEnvironment env)
          Fills a char buffer with the evaluated string results.
 java.lang.String evalString(Node node)
          Returns the expression evaluated as a string.
abstract  java.lang.String evalString(Node node, ExprEnvironment env)
          Returns the string value of the node.
 com.caucho.xpath.expr.Var evalVar(Node node, ExprEnvironment env)
          Evaluates to a variable.
 com.caucho.xpath.pattern.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(com.caucho.xpath.pattern.AbstractPattern listContext)
           
 void setVar(java.lang.String name, 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 Node toNode(java.lang.Object value)
          Convert a Java object to a node using the XPath rules.
protected  com.caucho.xpath.pattern.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

NODE_SET

protected static final int NODE_SET

ID

protected static final int ID

OR

protected static final int OR

AND

protected static final int AND

EQ

protected static final int EQ

NEQ

protected static final int NEQ

LT

protected static final int LT

LE

protected static final int LE

GT

protected static final int GT

GE

protected static final int GE

BOOLEAN_EQ

protected static final int BOOLEAN_EQ

BOOLEAN_NEQ

protected static final int BOOLEAN_NEQ

NUMBER_EQ

protected static final int NUMBER_EQ

NUMBER_NEQ

protected static final int NUMBER_NEQ

NUMBER_LT

protected static final int NUMBER_LT

NUMBER_LE

protected static final int NUMBER_LE

NUMBER_GT

protected static final int NUMBER_GT

NUMBER_GE

protected static final int NUMBER_GE

STRING_EQ

protected static final int STRING_EQ

STRING_NEQ

protected static final int STRING_NEQ

NEG

protected static final int NEG

ADD

protected static final int ADD

SUB

protected static final int SUB

MUL

protected static final int MUL

DIV

protected static final int DIV

QUO

protected static final int QUO

MOD

protected static final int MOD

TRUE

protected static final int TRUE

FALSE

protected static final int FALSE

NOT

protected static final int NOT

BOOLEAN

protected static final int BOOLEAN

LANG

protected static final int LANG

NUMBER

protected static final int NUMBER

SUM

protected static final int SUM

FLOOR

protected static final int FLOOR

CEILING

protected static final int CEILING

ROUND

protected static final int ROUND

POSITION

public static final int POSITION

COUNT

protected static final int COUNT

LAST

protected static final int LAST

STRING

protected static final int STRING

CONCAT

protected static final int CONCAT

STARTS_WITH

protected static final int STARTS_WITH

CONTAINS

protected static final int CONTAINS

SUBSTRING

protected static final int SUBSTRING

SUBSTRING_BEFORE

protected static final int SUBSTRING_BEFORE

SUBSTRING_AFTER

protected static final int SUBSTRING_AFTER

STRING_LENGTH

protected static final int STRING_LENGTH

NORMALIZE

protected static final int NORMALIZE

TRANSLATE

protected static final int TRANSLATE

FORMAT_NUMBER

protected static final int FORMAT_NUMBER

LOCAL_PART

protected static final int LOCAL_PART

NAMESPACE

protected static final int NAMESPACE

QNAME

protected static final int QNAME

GENERATE_ID

protected static final int GENERATE_ID

FUNCTION_AVAILABLE

protected static final int FUNCTION_AVAILABLE

SYSTEM_PROPERTY

protected static final int SYSTEM_PROPERTY

IF

protected static final int IF

SELF

protected static final int SELF

SELF_NAME

protected static final int SELF_NAME

ATTRIBUTE

protected static final int ATTRIBUTE

ELEMENT

protected static final int ELEMENT

LAST_FUN

protected static final int LAST_FUN
Constructor Detail

Expr

protected Expr()
Method Detail

setListContext

public void setListContext(com.caucho.xpath.pattern.AbstractPattern listContext)

getListContext

public com.caucho.xpath.pattern.AbstractPattern getListContext()

isNumber

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

evalNumber

public double evalNumber(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.

evalNumber

public abstract double evalNumber(Node node,
                                  ExprEnvironment env)
                           throws XPathException
Evaluates the expression as a number.
Parameters:
node - the current node.
env - variable environment.
Returns:
the numeric value.

isBoolean

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

evalBoolean

public boolean evalBoolean(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

evalBoolean

public abstract boolean evalBoolean(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.

evalString

public java.lang.String evalString(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.

isString

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

evalString

public abstract java.lang.String evalString(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.

evalString

public void evalString(CharBuffer cb,
                       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

evalString

public void evalString(CharBuffer cb,
                       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

isNodeSet

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

evalNodeSet

public com.caucho.xpath.pattern.NodeIterator evalNodeSet(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.

evalNodeSet

public com.caucho.xpath.pattern.NodeIterator evalNodeSet(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.

evalObject

public java.lang.Object evalObject(Node node)
                            throws XPathException
Returns the object value of the node.
Parameters:
node - the node to evaluate and use as a context

evalObject

public abstract java.lang.Object evalObject(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.

evalVar

public com.caucho.xpath.expr.Var evalVar(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.

addVar

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

setVar

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

addParam

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

toBoolean

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

toDouble

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

toString

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

toNode

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

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.

toNodeList

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