001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the "License"). You may not use this file except
005: * in compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://jwsdp.dev.java.net/CDDLv1.0.html
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * HEADER in each file and include the License file at
014: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
015: * add the following below this CDDL HEADER, with the
016: * fields enclosed by brackets "[]" replaced with your
017: * own identifying information: Portions Copyright [yyyy]
018: * [name of copyright owner]
019: */
020:
021: package com.sun.codemodel;
022:
023: /**
024: * A Java expression.
025: *
026: * <p>
027: * Unlike most of CodeModel, JExpressions are built bottom-up (
028: * meaning you start from leaves and then gradually build compliated expressions
029: * by combining them.)
030: *
031: * <p>
032: * {@link JExpression} defines a series of composer methods,
033: * which returns a complicated expression (by often taking other {@link JExpression}s
034: * as parameters.
035: * For example, you can build "5+2" by
036: * <tt>JExpr.lit(5).add(JExpr.lit(2))</tt>
037: */
038: public interface JExpression extends JGenerable {
039: /**
040: * Returns "-[this]" from "[this]".
041: */
042: JExpression minus();
043:
044: /**
045: * Returns "![this]" from "[this]".
046: */
047: JExpression not();
048:
049: /**
050: * Returns "~[this]" from "[this]".
051: */
052: JExpression complement();
053:
054: /**
055: * Returns "[this]++" from "[this]".
056: */
057: JExpression incr();
058:
059: /**
060: * Returns "[this]--" from "[this]".
061: */
062: JExpression decr();
063:
064: /**
065: * Returns "[this]+[right]"
066: */
067: JExpression plus(JExpression right);
068:
069: /**
070: * Returns "[this]-[right]"
071: */
072: JExpression minus(JExpression right);
073:
074: /**
075: * Returns "[this]*[right]"
076: */
077: JExpression mul(JExpression right);
078:
079: /**
080: * Returns "[this]/[right]"
081: */
082: JExpression div(JExpression right);
083:
084: /**
085: * Returns "[this]%[right]"
086: */
087: JExpression mod(JExpression right);
088:
089: /**
090: * Returns "[this]<<[right]"
091: */
092: JExpression shl(JExpression right);
093:
094: /**
095: * Returns "[this]>>[right]"
096: */
097: JExpression shr(JExpression right);
098:
099: /**
100: * Returns "[this]>>>[right]"
101: */
102: JExpression shrz(JExpression right);
103:
104: /** Bit-wise AND '&'. */
105: JExpression band(JExpression right);
106:
107: /** Bit-wise OR '|'. */
108: JExpression bor(JExpression right);
109:
110: /** Logical AND '&&'. */
111: JExpression cand(JExpression right);
112:
113: /** Logical OR '||'. */
114: JExpression cor(JExpression right);
115:
116: JExpression xor(JExpression right);
117:
118: JExpression lt(JExpression right);
119:
120: JExpression lte(JExpression right);
121:
122: JExpression gt(JExpression right);
123:
124: JExpression gte(JExpression right);
125:
126: JExpression eq(JExpression right);
127:
128: JExpression ne(JExpression right);
129:
130: /**
131: * Returns "[this] instanceof [right]"
132: */
133: JExpression _instanceof (JType right);
134:
135: /**
136: * Returns "[this].[method]".
137: *
138: * Arguments shall be added to the returned {@link JInvocation} object.
139: */
140: JInvocation invoke(JMethod method);
141:
142: /**
143: * Returns "[this].[method]".
144: *
145: * Arguments shall be added to the returned {@link JInvocation} object.
146: */
147: JInvocation invoke(String method);
148:
149: JFieldRef ref(JVar field);
150:
151: JFieldRef ref(String field);
152:
153: JArrayCompRef component(JExpression index);
154: }
|