Package com.sun.codemodel
Class JExpr
- java.lang.Object
-
- com.sun.codemodel.JExpr
-
public abstract class JExpr extends Object
Factory methods that generate variousJExpression
s.
-
-
Field Summary
Fields Modifier and Type Field Description static JExpression
FALSE
Boolean constant that representsfalse
static JExpression
TRUE
Boolean constant that representstrue
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JInvocation
_new(JClass c)
static JInvocation
_new(JType t)
static JExpression
_null()
static JExpression
_super()
Returns a reference to "super", an implicit reference to the super class.static JExpression
_this()
Returns a reference to "this", an implicit reference to the current object.static JExpression
assign(JAssignmentTarget lhs, JExpression rhs)
static JExpression
assignPlus(JAssignmentTarget lhs, JExpression rhs)
static com.sun.codemodel.JCast
cast(JType type, JExpression expr)
static com.sun.codemodel.JArrayCompRef
component(JExpression lhs, JExpression index)
static JExpression
direct(String source)
Creates an expression directly from a source code fragment.static JExpression
dotclass(JClass cl)
static JInvocation
invoke(JExpression lhs, JMethod method)
static JInvocation
invoke(JExpression lhs, String method)
static JInvocation
invoke(JMethod method)
static JInvocation
invoke(String method)
static JExpression
lit(boolean b)
static JExpression
lit(char c)
static JExpression
lit(double d)
static JExpression
lit(float f)
static JExpression
lit(int n)
static JExpression
lit(long n)
static JExpression
lit(String s)
static JArray
newArray(JType type)
static JArray
newArray(JType type, int size)
Generatesnew T[size]
.static JArray
newArray(JType type, JExpression size)
Generatesnew T[size]
.static String
quotify(char quote, String s)
Escapes the given string, then surrounds it by the specified quotation mark.static JFieldRef
ref(JExpression lhs, JVar field)
static JFieldRef
ref(JExpression lhs, String field)
static JFieldRef
ref(String field)
static JFieldRef
refthis(String field)
-
-
-
Field Detail
-
TRUE
public static final JExpression TRUE
Boolean constant that representstrue
-
FALSE
public static final JExpression FALSE
Boolean constant that representsfalse
-
-
Method Detail
-
assign
public static JExpression assign(JAssignmentTarget lhs, JExpression rhs)
-
assignPlus
public static JExpression assignPlus(JAssignmentTarget lhs, JExpression rhs)
-
_new
public static JInvocation _new(JClass c)
-
_new
public static JInvocation _new(JType t)
-
invoke
public static JInvocation invoke(String method)
-
invoke
public static JInvocation invoke(JMethod method)
-
invoke
public static JInvocation invoke(JExpression lhs, JMethod method)
-
invoke
public static JInvocation invoke(JExpression lhs, String method)
-
ref
public static JFieldRef ref(JExpression lhs, JVar field)
-
ref
public static JFieldRef ref(JExpression lhs, String field)
-
dotclass
public static JExpression dotclass(JClass cl)
-
component
public static com.sun.codemodel.JArrayCompRef component(JExpression lhs, JExpression index)
-
cast
public static com.sun.codemodel.JCast cast(JType type, JExpression expr)
-
newArray
public static JArray newArray(JType type, JExpression size)
Generatesnew T[size]
.- Parameters:
type
- The type of the array component. 'T' ornew T[size]
.
-
newArray
public static JArray newArray(JType type, int size)
Generatesnew T[size]
.- Parameters:
type
- The type of the array component. 'T' ornew T[size]
.
-
_this
public static JExpression _this()
Returns a reference to "this", an implicit reference to the current object.
-
_super
public static JExpression _super()
Returns a reference to "super", an implicit reference to the super class.
-
_null
public static JExpression _null()
-
lit
public static JExpression lit(boolean b)
-
lit
public static JExpression lit(int n)
-
lit
public static JExpression lit(long n)
-
lit
public static JExpression lit(float f)
-
lit
public static JExpression lit(double d)
-
quotify
public static String quotify(char quote, String s)
Escapes the given string, then surrounds it by the specified quotation mark.
-
lit
public static JExpression lit(char c)
-
lit
public static JExpression lit(String s)
-
direct
public static JExpression direct(String source)
Creates an expression directly from a source code fragment.This method can be used as a short-cut to create a JExpression. For example, instead of
_a.gt(_b)
, you can write it as:JExpr.direct("a>b")
.Be warned that there is a danger in using this method, as it obfuscates the object model.
-
-