|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.clearsilver.jsilver.compiler.JavaExpression
public abstract class JavaExpression
Represents a node of a Java expression. This class contains static helper methods for common types of expressions, or you can just create your own subclass.
Nested Class Summary | |
---|---|
static class |
JavaExpression.BooleanLiteralExpression
A JavaExpression to represent boolean literal values ('true' or 'false'). |
static class |
JavaExpression.StringExpression
|
static class |
JavaExpression.Type
Simple type enumeration to allow us to compare the return types of expressions easily and cast expressions nicely. |
Constructor Summary | |
---|---|
JavaExpression(JavaExpression.Type type)
Creates a typed expression. |
Method Summary | |
---|---|
static JavaExpression |
assign(JavaExpression.Type type,
String name,
JavaExpression value)
A typed assignment (e.g. |
static JavaExpression |
bool(boolean value)
A boolean |
static JavaExpression |
call(JavaExpression.Type type,
String method,
JavaExpression... params)
A typed method call (e.g. |
static JavaExpression |
call(String method,
JavaExpression... params)
An untyped method call (e.g. |
static JavaExpression |
callFindVariable(JavaExpression expression,
boolean create)
|
static JavaExpression |
callOn(JavaExpression.Type type,
JavaExpression instance,
String method,
JavaExpression... params)
A typed method call on an instance (e.g. |
static JavaExpression |
callOn(JavaExpression instance,
String method,
JavaExpression... params)
An untyped method call on an instance (e.g. |
JavaExpression |
cast(JavaExpression.Type destType)
Cast this expression to the destination type (possibly a no-op) |
static JavaExpression |
declare(JavaExpression.Type type,
String name,
JavaExpression value)
A typed assignment with declaration (e.g. |
JavaExpression.Type |
getType()
Gets the type of this expression (or null if unknown). |
static JavaExpression |
increment(JavaExpression.Type type,
JavaExpression accumulator,
JavaExpression incr)
An increment statement (e.g. |
static JavaExpression |
infix(JavaExpression.Type type,
String operator,
JavaExpression left,
JavaExpression right)
An infix expression (e.g. |
static JavaExpression |
inlineIf(JavaExpression.Type type,
JavaExpression query,
JavaExpression trueExp,
JavaExpression falseExp)
A three term inline if expression (e.g. |
static JavaExpression |
integer(int value)
An integer. |
static JavaExpression |
integer(String value)
An integer. |
static JavaExpression |
literal(JavaExpression.Type type,
String value)
A literal expression (e.g. |
static JavaExpression |
macro(String value)
|
static JavaExpression |
prefix(JavaExpression.Type type,
String operator,
JavaExpression expression)
An prefix expression (e.g. |
static JavaExpression |
string(String value)
A Java string (e.g. |
static JavaExpression |
symbol(JavaExpression.Type type,
String value)
A typed symbol (e.g. |
static JavaExpression |
symbol(String value)
An untyped symbol (e.g. |
String |
toString()
|
abstract void |
write(PrintWriter out)
Implementations use this to output the expression as Java code. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JavaExpression(JavaExpression.Type type)
type
- the Type of the expression. Must be from the enum above and represent a primitive
or a Class name or void.Method Detail |
---|
public JavaExpression cast(JavaExpression.Type destType)
public JavaExpression.Type getType()
null
if unknown).
public abstract void write(PrintWriter out)
public String toString()
toString
in class Object
public static JavaExpression call(String method, JavaExpression... params)
public static JavaExpression call(JavaExpression.Type type, String method, JavaExpression... params)
public static JavaExpression callOn(JavaExpression instance, String method, JavaExpression... params)
public static JavaExpression callOn(JavaExpression.Type type, JavaExpression instance, String method, JavaExpression... params)
public static JavaExpression string(String value)
public static JavaExpression integer(String value)
public static JavaExpression integer(int value)
public static JavaExpression bool(boolean value)
public static JavaExpression symbol(String value)
public static JavaExpression symbol(JavaExpression.Type type, String value)
public static JavaExpression macro(String value)
public static JavaExpression assign(JavaExpression.Type type, String name, JavaExpression value)
public static JavaExpression declare(JavaExpression.Type type, String name, JavaExpression value)
public static JavaExpression infix(JavaExpression.Type type, String operator, JavaExpression left, JavaExpression right)
public static JavaExpression prefix(JavaExpression.Type type, String operator, JavaExpression expression)
public static JavaExpression inlineIf(JavaExpression.Type type, JavaExpression query, JavaExpression trueExp, JavaExpression falseExp)
public static JavaExpression increment(JavaExpression.Type type, JavaExpression accumulator, JavaExpression incr)
public static JavaExpression literal(JavaExpression.Type type, String value)
public static JavaExpression callFindVariable(JavaExpression expression, boolean create)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |