KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > dom > Expression


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.core.dom;
13
14 /**
15  * Abstract base class of AST nodes that represent expressions.
16  * There are several kinds of expressions.
17  * <p>
18  * <pre>
19  * Expression:
20  * Name
21  * IntegerLiteral (includes decimal, hex, and octal forms; and long)
22  * FloatingPointLiteral (includes both float and double)
23  * CharacterLiteral
24  * NullLiteral
25  * BooleanLiteral
26  * StringLiteral
27  * TypeLiteral
28  * ThisExpression
29  * SuperFieldAccess
30  * FieldAccess
31  * Assignment
32  * ParenthesizedExpression
33  * ClassInstanceCreation
34  * ArrayCreation
35  * ArrayInitializer
36  * MethodInvocation
37  * SuperMethodInvocation
38  * ArrayAccess
39  * InfixExpression
40  * InstanceofExpression
41  * ConditionalExpression
42  * PostfixExpression
43  * PrefixExpression
44  * CastExpression
45  * VariableDeclarationExpression
46  * </pre>
47  * </p>
48  *
49  * @since 2.0
50  */

51 public abstract class Expression extends ASTNode {
52     
53     /**
54      * Creates a new AST node for an expression owned by the given AST.
55      * <p>
56      * N.B. This constructor is package-private.
57      * </p>
58      *
59      * @param ast the AST that is to own this node
60      */

61     Expression(AST ast) {
62         super(ast);
63     }
64
65     /**
66      * Resolves and returns the compile-time constant expression value as
67      * specified in JLS2 15.28, if this expression has one. Constant expression
68      * values are unavailable unless bindings are requested when the AST is
69      * being built. If the type of the value is a primitive type, the result
70      * is the boxed equivalent (i.e., int returned as an <code>Integer</code>);
71      * if the type of the value is <code>String</code>, the result is the string
72      * itself. If the expression does not have a compile-time constant expression
73      * value, the result is <code>null</code>.
74      * <p>
75      * Resolving constant expressions takes into account the value of simple
76      * and qualified names that refer to constant variables (JLS2 4.12.4).
77      * </p>
78      * <p>
79      * Note 1: enum constants are not considered constant expressions.
80      * The result is always <code>null</code> for these.
81      * </p>
82      * <p>
83      * Note 2: Compile-time constant expressions cannot denote <code>null</code>.
84      * So technically {@link NullLiteral} nodes are not constant expressions.
85      * The result is <code>null</code> for these nonetheless.
86      * </p>
87      *
88      * @return the constant expression value, or <code>null</code> if this
89      * expression has no constant expression value or if bindings were not
90      * requested when the AST was created
91      * @since 3.1
92      */

93     public final Object JavaDoc resolveConstantExpressionValue() {
94         return this.ast.getBindingResolver().resolveConstantExpressionValue(this);
95     }
96
97     /**
98      * Resolves and returns the binding for the type of this expression.
99      * <p>
100      * Note that bindings are generally unavailable unless requested when the
101      * AST is being built.
102      * </p>
103      *
104      * @return the binding for the type of this expression, or
105      * <code>null</code> if the type cannot be resolved
106      */

107     public final ITypeBinding resolveTypeBinding() {
108         return this.ast.getBindingResolver().resolveExpressionType(this);
109     }
110
111     /**
112      * Returns whether this expression node is the site of a boxing
113      * conversion (JLS3 5.1.7). This information is available only
114      * when bindings are requested when the AST is being built.
115      *
116      * @return <code>true</code> if this expression is the site of a
117      * boxing conversion, or <code>false</code> if either no boxing conversion
118      * is involved or if bindings were not requested when the AST was created
119      * @since 3.1
120      */

121     public final boolean resolveBoxing() {
122         return this.ast.getBindingResolver().resolveBoxing(this);
123     }
124     
125     /**
126      * Returns whether this expression node is the site of an unboxing
127      * conversion (JLS3 5.1.8). This information is available only
128      * when bindings are requested when the AST is being built.
129      *
130      * @return <code>true</code> if this expression is the site of an
131      * unboxing conversion, or <code>false</code> if either no unboxing
132      * conversion is involved or if bindings were not requested when the
133      * AST was created
134      * @since 3.1
135      */

136     public final boolean resolveUnboxing() {
137         return this.ast.getBindingResolver().resolveUnboxing(this);
138     }
139 }
140
141
Popular Tags