001: /*
002: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.codemodel.internal;
027:
028: /**
029: * A Java expression.
030: *
031: * <p>
032: * Unlike most of CodeModel, JExpressions are built bottom-up (
033: * meaning you start from leaves and then gradually build compliated expressions
034: * by combining them.)
035: *
036: * <p>
037: * {@link JExpression} defines a series of composer methods,
038: * which returns a complicated expression (by often taking other {@link JExpression}s
039: * as parameters.
040: * For example, you can build "5+2" by
041: * <tt>JExpr.lit(5).add(JExpr.lit(2))</tt>
042: */
043: public interface JExpression extends JGenerable {
044: /**
045: * Returns "-[this]" from "[this]".
046: */
047: JExpression minus();
048:
049: /**
050: * Returns "![this]" from "[this]".
051: */
052: JExpression not();
053:
054: /**
055: * Returns "~[this]" from "[this]".
056: */
057: JExpression complement();
058:
059: /**
060: * Returns "[this]++" from "[this]".
061: */
062: JExpression incr();
063:
064: /**
065: * Returns "[this]--" from "[this]".
066: */
067: JExpression decr();
068:
069: /**
070: * Returns "[this]+[right]"
071: */
072: JExpression plus(JExpression right);
073:
074: /**
075: * Returns "[this]-[right]"
076: */
077: JExpression minus(JExpression right);
078:
079: /**
080: * Returns "[this]*[right]"
081: */
082: JExpression mul(JExpression right);
083:
084: /**
085: * Returns "[this]/[right]"
086: */
087: JExpression div(JExpression right);
088:
089: /**
090: * Returns "[this]%[right]"
091: */
092: JExpression mod(JExpression right);
093:
094: /**
095: * Returns "[this]<<[right]"
096: */
097: JExpression shl(JExpression right);
098:
099: /**
100: * Returns "[this]>>[right]"
101: */
102: JExpression shr(JExpression right);
103:
104: /**
105: * Returns "[this]>>>[right]"
106: */
107: JExpression shrz(JExpression right);
108:
109: /** Bit-wise AND '&'. */
110: JExpression band(JExpression right);
111:
112: /** Bit-wise OR '|'. */
113: JExpression bor(JExpression right);
114:
115: /** Logical AND '&&'. */
116: JExpression cand(JExpression right);
117:
118: /** Logical OR '||'. */
119: JExpression cor(JExpression right);
120:
121: JExpression xor(JExpression right);
122:
123: JExpression lt(JExpression right);
124:
125: JExpression lte(JExpression right);
126:
127: JExpression gt(JExpression right);
128:
129: JExpression gte(JExpression right);
130:
131: JExpression eq(JExpression right);
132:
133: JExpression ne(JExpression right);
134:
135: /**
136: * Returns "[this] instanceof [right]"
137: */
138: JExpression _instanceof (JType right);
139:
140: /**
141: * Returns "[this].[method]".
142: *
143: * Arguments shall be added to the returned {@link JInvocation} object.
144: */
145: JInvocation invoke(JMethod method);
146:
147: /**
148: * Returns "[this].[method]".
149: *
150: * Arguments shall be added to the returned {@link JInvocation} object.
151: */
152: JInvocation invoke(String method);
153:
154: JFieldRef ref(JVar field);
155:
156: JFieldRef ref(String field);
157:
158: JArrayCompRef component(JExpression index);
159: }
|