com.caucho.el
Class Expr

java.lang.Object
  extended by javax.el.Expression
      extended by javax.el.ValueExpression
          extended by com.caucho.el.Expr
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbstractBooleanExpr, AddExpr, ArrayExpr, ArrayResolverExpr, BinaryExpr, CandiExpr, ConditionalExpr, ConditionalNullExpr, DivExpr, DoubleLiteral, FunctionExpr, IdExpr, ImplicitFieldExpr, ImplicitObjectExpr, ImplicitObjectExpr, InterpolateExpr, LongLiteral, MethodExpr, MinusExpr, ModExpr, MulExpr, NullLiteral, PathExpr, StaticMethodExpr, StringLiteral, SubExpr, UnaryExpr, ValueExpr

public abstract class Expr
extends ValueExpression

Abstract implementation class for an expression.

See Also:
Serialized Form

Field Summary
protected static L10N L
           
protected static java.util.logging.Logger log
           
 
Constructor Summary
Expr()
           
 
Method Summary
static java.lang.Object coerceToType(java.lang.Object obj, java.lang.Class<?> targetType)
           
 Expr createField(Expr field)
          Creates a field reference using this expression as the base object.
 Expr createField(java.lang.String field)
          Creates a field reference using this expression as the base object.
 Expr createMethod(Expr[] args)
          Creates a method call using this as the obj.method expression
 boolean equals(java.lang.Object o)
           
static java.lang.Object error(java.lang.Throwable e, ELContext env)
          Returns an error object
 java.math.BigDecimal evalBigDecimal(ELContext env)
          Evaluate the expression, knowing the value should be a BigDecimal.
 java.math.BigInteger evalBigInteger(ELContext env)
          Evaluate the expression, knowing the value should be a BigInteger.
 boolean evalBoolean(ELContext env)
          Evaluate the expression, knowing the value should be a boolean.
 char evalCharacter(ELContext env)
          Evaluate the expression, knowing the value should be a string
 double evalDouble(ELContext env)
          Evaluate the expression, knowing the value should be a double.
 long evalLong(ELContext env)
          Evaluate the expression, knowing the value should be a long
 java.lang.Object evalObject(ELContext env)
          Evaluates the expression, returning an object.
 long evalPeriod(ELContext env)
          Evaluate the expression, knowing the value should be a period
 java.lang.String evalString(ELContext env)
          Evaluate the expression, knowing the value should be a string
 java.lang.String evalStringWithNull(ELContext env)
          Evaluate the expression, knowing the value should be a string
 java.lang.Class<?> getExpectedType()
           
 java.lang.String getExpressionString()
           
 MethodInfo getMethodInfo(ELContext env, java.lang.Class<?> returnType, java.lang.Class<?>[] argTypes)
          Evaluates the expression, returning an object.
 java.lang.Class<?> getType(ELContext context)
           
abstract  java.lang.Object getValue(ELContext env)
          Evaluates the expression, returning an object.
 int hashCode()
           
static java.lang.Object invocationError(java.lang.Throwable e)
          Returns an error object
 java.lang.Object invoke(ELContext env, java.lang.Class<?>[] argTypes, java.lang.Object[] args)
          Evaluates the expression, returning an object.
 boolean isConstant()
          Returns true if the expression is constant.
static boolean isDouble(java.lang.Object o)
          Returns true for a double or double-equivalent.
protected static boolean isDoubleString(java.lang.Object obj)
           
 boolean isLiteralText()
          Returns true if the expression is literal text
 boolean isReadOnly(ELContext env)
          Returns true if the expression is read-only.
 boolean print(JspWriter out, ELContext env, boolean escapeXml)
          Evaluates directly to the output.
 boolean print(WriteStream out, ELContext env, boolean escapeXml)
          Evaluates directly to the output.
 void printCreate(WriteStream os)
          Generates the code to regenerate the expression.
static void printEscaped(WriteStream os, ReadStream is)
          Write to the *.java stream escaping Java reserved characters.
static void printEscapedString(WriteStream os, java.lang.String string)
          Write to the *.java stream escaping Java reserved characters.
static void setProperty(java.lang.Object target, java.lang.String property, java.lang.Object value)
           
 void setValue(ELContext env, java.lang.Object value)
          Evaluates the expression, setting an object.
static java.math.BigDecimal toBigDecimal(java.lang.Object value, ELContext env)
          Converts some unknown value to a big decimal
static java.math.BigInteger toBigInteger(java.lang.Object value, ELContext env)
          Converts some unknown value to a big integer
static boolean toBoolean(java.lang.Object value, ELContext env)
          Converts some unknown value to a boolean.
static char toCharacter(java.lang.Object value, ELContext env)
          Converts some unknown value to a string.
static double toDouble(java.lang.Object value, ELContext env)
          Converts some unknown value to a double.
static java.lang.Object toEnum(java.lang.Object obj, java.lang.Class<? extends java.lang.Enum> enumType)
           
static long toLong(java.lang.Object value, ELContext env)
          Converts some unknown value to a long.
static void toStream(JspWriter out, java.lang.Object value)
          Write to the stream.
static boolean toStream(JspWriter out, java.lang.Object value, boolean isEscaped)
          Write to the stream.
static void toStream(WriteStream out, java.lang.Object value)
          Write to the stream.
static void toStreamEscaped(java.io.Writer out, java.lang.Object value)
          Write to the stream.
static void toStreamEscaped(java.io.Writer out, java.io.Reader in)
          Write to the stream escaping XML reserved characters.
static void toStreamEscaped(WriteStream out, java.lang.Object value)
          Write to the stream escaping XML reserved characters.
abstract  java.lang.String toString()
           
static java.lang.String toString(boolean value, ELContext env)
          Converts some unknown value to a string.
static java.lang.String toString(char value, ELContext env)
          Converts some unknown value to a string.
static java.lang.String toString(double value, ELContext env)
          Converts some unknown value to a string.
static java.lang.String toString(long value, ELContext env)
          Converts some unknown value to a string.
static java.lang.String toString(java.lang.Object value, ELContext env)
          Converts some unknown value to a string.
static java.lang.String toStringWithNull(java.lang.Object value, ELContext env)
          Converts some unknown value to a string.
 
Methods inherited from class javax.el.ValueExpression
getValueReference
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log

L

protected static final L10N L
Constructor Detail

Expr

public Expr()
Method Detail

isConstant

public boolean isConstant()
Returns true if the expression is constant.


isReadOnly

public boolean isReadOnly(ELContext env)
Returns true if the expression is read-only.

Specified by:
isReadOnly in class ValueExpression

isLiteralText

public boolean isLiteralText()
Returns true if the expression is literal text

Specified by:
isLiteralText in class Expression

createField

public Expr createField(Expr field)
Creates a field reference using this expression as the base object.

Parameters:
field - the expression for the field.

createField

public Expr createField(java.lang.String field)
Creates a field reference using this expression as the base object.

Parameters:
field - the string reference for the field.

createMethod

public Expr createMethod(Expr[] args)
Creates a method call using this as the obj.method expression

Parameters:
args - the arguments for the method

getValue

public abstract java.lang.Object getValue(ELContext env)
                                   throws ELException
Evaluates the expression, returning an object.

Specified by:
getValue in class ValueExpression
Parameters:
env - the variable environment
Returns:
the value of the expression as an object
Throws:
ELException

getMethodInfo

public MethodInfo getMethodInfo(ELContext env,
                                java.lang.Class<?> returnType,
                                java.lang.Class<?>[] argTypes)
                         throws ELException
Evaluates the expression, returning an object.

Parameters:
env - the variable environment
Returns:
the value of the expression as an object
Throws:
ELException

invoke

public java.lang.Object invoke(ELContext env,
                               java.lang.Class<?>[] argTypes,
                               java.lang.Object[] args)
                        throws ELException
Evaluates the expression, returning an object.

Parameters:
env - the variable environment
Returns:
the value of the expression as an object
Throws:
ELException

evalObject

public final java.lang.Object evalObject(ELContext env)
                                  throws ELException
Evaluates the expression, returning an object.

Parameters:
env - the variable environment
Returns:
the value of the expression as an object
Throws:
ELException

evalBoolean

public boolean evalBoolean(ELContext env)
                    throws ELException
Evaluate the expression, knowing the value should be a boolean.

Parameters:
env - the variable environment
Returns:
the value of the expression as a boolean
Throws:
ELException

evalDouble

public double evalDouble(ELContext env)
                  throws ELException
Evaluate the expression, knowing the value should be a double.

Parameters:
env - the variable environment
Returns:
the value of the expression as a double
Throws:
ELException

evalLong

public long evalLong(ELContext env)
              throws ELException
Evaluate the expression, knowing the value should be a long

Parameters:
env - the variable environment
Returns:
the value of the expression as a double
Throws:
ELException

evalString

public java.lang.String evalString(ELContext env)
                            throws ELException
Evaluate the expression, knowing the value should be a string

Parameters:
env - the variable environment
Returns:
the value of the expression as a string
Throws:
ELException

evalStringWithNull

public java.lang.String evalStringWithNull(ELContext env)
                                    throws ELException
Evaluate the expression, knowing the value should be a string

Parameters:
env - the variable environment
Returns:
the value of the expression as a string
Throws:
ELException

evalCharacter

public char evalCharacter(ELContext env)
                   throws ELException
Evaluate the expression, knowing the value should be a string

Parameters:
env - the variable environment
Returns:
the value of the expression as a string
Throws:
ELException

evalPeriod

public long evalPeriod(ELContext env)
                throws ELException
Evaluate the expression, knowing the value should be a period

Parameters:
env - the variable environment
Returns:
the value of the expression as a period
Throws:
ELException

evalBigInteger

public java.math.BigInteger evalBigInteger(ELContext env)
                                    throws ELException
Evaluate the expression, knowing the value should be a BigInteger.

Parameters:
env - the variable environment
Returns:
the value of the expression as a BigInteger
Throws:
ELException

evalBigDecimal

public java.math.BigDecimal evalBigDecimal(ELContext env)
                                    throws ELException
Evaluate the expression, knowing the value should be a BigDecimal.

Parameters:
env - the variable environment
Returns:
the value of the expression as a BigDecimal
Throws:
ELException

setValue

public void setValue(ELContext env,
                     java.lang.Object value)
              throws PropertyNotFoundException,
                     PropertyNotWritableException,
                     ELException
Evaluates the expression, setting an object.

Specified by:
setValue in class ValueExpression
Parameters:
env - the variable environment
Throws:
PropertyNotFoundException
PropertyNotWritableException
ELException

print

public boolean print(WriteStream out,
                     ELContext env,
                     boolean escapeXml)
              throws java.io.IOException,
                     ELException
Evaluates directly to the output. The method returns true if the default value should be printed instead.

Parameters:
out - the output writer
env - the variable environment
escapeXml - if true, escape reserved XML
Returns:
true if the object is null, otherwise false
Throws:
java.io.IOException
ELException

print

public boolean print(JspWriter out,
                     ELContext env,
                     boolean escapeXml)
              throws java.io.IOException,
                     ELException
Evaluates directly to the output. The method returns true if the default value should be printed instead.

Parameters:
out - the output writer
env - the variable environment
escapeXml - if true, escape reserved XML
Returns:
true if the object is null, otherwise false
Throws:
java.io.IOException
ELException

printCreate

public void printCreate(WriteStream os)
                 throws java.io.IOException
Generates the code to regenerate the expression.

Parameters:
os - the stream to the *.java page
Throws:
java.io.IOException

getExpressionString

public java.lang.String getExpressionString()
Specified by:
getExpressionString in class Expression

getExpectedType

public java.lang.Class<?> getExpectedType()
Specified by:
getExpectedType in class ValueExpression

getType

public java.lang.Class<?> getType(ELContext context)
                           throws PropertyNotFoundException,
                                  ELException
Specified by:
getType in class ValueExpression
Throws:
PropertyNotFoundException
ELException

isDouble

public static boolean isDouble(java.lang.Object o)
Returns true for a double or double-equivalent.


toStringWithNull

public static java.lang.String toStringWithNull(java.lang.Object value,
                                                ELContext env)
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.

toString

public static java.lang.String toString(java.lang.Object value,
                                        ELContext env)
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.

toString

public static java.lang.String toString(long value,
                                        ELContext env)
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.

toString

public static java.lang.String toString(double value,
                                        ELContext env)
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.

toString

public static java.lang.String toString(boolean value,
                                        ELContext env)
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.

toString

public static java.lang.String toString(char value,
                                        ELContext env)
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.

toCharacter

public static char toCharacter(java.lang.Object value,
                               ELContext env)
                        throws ELException
Converts some unknown value to a string.

Parameters:
value - the value to be converted.
Returns:
the string-converted value.
Throws:
ELException

toBoolean

public static boolean toBoolean(java.lang.Object value,
                                ELContext env)
                         throws ELException
Converts some unknown value to a boolean.

Parameters:
value - the value to be converted.
Returns:
the boolean-converted value.
Throws:
ELException

toDouble

public static double toDouble(java.lang.Object value,
                              ELContext env)
                       throws ELException
Converts some unknown value to a double.

Parameters:
value - the value to be converted.
Returns:
the double-converted value.
Throws:
ELException

toBigDecimal

public static java.math.BigDecimal toBigDecimal(java.lang.Object value,
                                                ELContext env)
                                         throws ELException
Converts some unknown value to a big decimal

Parameters:
value - the value to be converted.
Returns:
the BigDecimal-converted value.
Throws:
ELException

toBigInteger

public static java.math.BigInteger toBigInteger(java.lang.Object value,
                                                ELContext env)
                                         throws ELException
Converts some unknown value to a big integer

Parameters:
value - the value to be converted.
Returns:
the BigInteger-converted value.
Throws:
ELException

toLong

public static long toLong(java.lang.Object value,
                          ELContext env)
                   throws ELException
Converts some unknown value to a long.

Parameters:
value - the value to be converted.
Returns:
the long-converted value.
Throws:
ELException

toStream

public static boolean toStream(JspWriter out,
                               java.lang.Object value,
                               boolean isEscaped)
                        throws java.io.IOException
Write to the stream.

Parameters:
out - the output stream
value - the value to be written.
Returns:
true for null
Throws:
java.io.IOException

toStream

public static void toStream(WriteStream out,
                            java.lang.Object value)
                     throws java.io.IOException
Write to the stream.

Parameters:
out - the output stream
value - the value to be written.
Throws:
java.io.IOException

toStream

public static void toStream(JspWriter out,
                            java.lang.Object value)
                     throws java.io.IOException
Write to the stream.

Parameters:
out - the output stream
value - the value to be written.
Throws:
java.io.IOException

printEscapedString

public static void printEscapedString(WriteStream os,
                                      java.lang.String string)
                               throws java.io.IOException
Write to the *.java stream escaping Java reserved characters.

Parameters:
os - the output stream to the *.java code.
string - the value to be converted.
Throws:
java.io.IOException

toStreamEscaped

public static void toStreamEscaped(java.io.Writer out,
                                   java.lang.Object value)
                            throws java.io.IOException
Write to the stream.

Parameters:
out - the output stream
value - the value to be written.
Throws:
java.io.IOException

toStreamEscaped

public static void toStreamEscaped(WriteStream out,
                                   java.lang.Object value)
                            throws java.io.IOException
Write to the stream escaping XML reserved characters.

Parameters:
out - the output stream.
value - the value to be converted.
Throws:
java.io.IOException

toStreamEscaped

public static void toStreamEscaped(java.io.Writer out,
                                   java.io.Reader in)
                            throws java.io.IOException
Write to the stream escaping XML reserved characters.

Parameters:
out - the output stream.
in - the value to be converted.
Throws:
java.io.IOException

toEnum

public static java.lang.Object toEnum(java.lang.Object obj,
                                      java.lang.Class<? extends java.lang.Enum> enumType)

printEscaped

public static void printEscaped(WriteStream os,
                                ReadStream is)
                         throws java.io.IOException
Write to the *.java stream escaping Java reserved characters.

Parameters:
os - the output stream to the *.java code.
is - the value to be converted.
Throws:
java.io.IOException

setProperty

public static void setProperty(java.lang.Object target,
                               java.lang.String property,
                               java.lang.Object value)
                        throws ELException,
                               JspException
Throws:
ELException
JspException

isDoubleString

protected static boolean isDoubleString(java.lang.Object obj)

coerceToType

public static java.lang.Object coerceToType(java.lang.Object obj,
                                            java.lang.Class<?> targetType)
                                     throws ELException
Throws:
ELException

error

public static java.lang.Object error(java.lang.Throwable e,
                                     ELContext env)
                              throws ELException
Returns an error object

Throws:
ELException

hashCode

public int hashCode()
Specified by:
hashCode in class Expression

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in class Expression

toString

public abstract java.lang.String toString()
Overrides:
toString in class java.lang.Object

invocationError

public static java.lang.Object invocationError(java.lang.Throwable e)
                                        throws ELException
Returns an error object

Throws:
ELException