Class JExpr


  • public abstract class JExpr
    extends java.lang.Object
    Factory methods that generate various JExpressions.
    • Field Detail

      • TRUE

        public static final JExpression TRUE
        Boolean constant that represents true
      • FALSE

        public static final JExpression FALSE
        Boolean constant that represents false
    • Method Detail

      • invoke

        public static JInvocation invoke​(java.lang.String method)
      • ref

        public static JFieldRef ref​(java.lang.String field)
      • refthis

        public static JFieldRef refthis​(java.lang.String field)
      • 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)
      • newArray

        public static JArray newArray​(JType type,
                                      JExpression size)
        Generates new T[size].
        Parameters:
        type - The type of the array component. 'T' or new T[size].
      • newArray

        public static JArray newArray​(JType type,
                                      int size)
        Generates new T[size].
        Parameters:
        type - The type of the array component. 'T' or new 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.
      • quotify

        public static java.lang.String quotify​(char quote,
                                               java.lang.String s)
        Escapes the given string, then surrounds it by the specified quotation mark.
      • lit

        public static JExpression lit​(java.lang.String s)
      • direct

        public static JExpression direct​(java.lang.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.