KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > lookup > ParameterizedFieldBinding


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 package org.eclipse.jdt.internal.compiler.lookup;
12
13 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14 import org.eclipse.jdt.internal.compiler.impl.Constant;
15
16 /**
17  * Binding denoting a field after type substitution got performed.
18  * On parameterized type bindings, all fields got substituted, regardless whether
19  * their signature did involve generics or not, so as to get the proper declaringClass for
20  * these fields.
21  */

22 public class ParameterizedFieldBinding extends FieldBinding {
23     
24     public FieldBinding originalField;
25     
26 public ParameterizedFieldBinding(ParameterizedTypeBinding parameterizedDeclaringClass, FieldBinding originalField) {
27     super (
28             originalField.name,
29             (originalField.modifiers & ClassFileConstants.AccEnum) != 0
30                 ? parameterizedDeclaringClass // enum constant get paramType as its type
31
: (originalField.modifiers & ClassFileConstants.AccStatic) != 0
32                         ? originalField.type // no subst for static field
33
: Scope.substitute(parameterizedDeclaringClass, originalField.type),
34             originalField.modifiers,
35             parameterizedDeclaringClass,
36             null);
37     this.originalField = originalField;
38     this.tagBits = originalField.tagBits;
39     this.id = originalField.id;
40 }
41     
42 /**
43  * @see org.eclipse.jdt.internal.compiler.lookup.VariableBinding#constant()
44  */

45 public Constant constant() {
46     return this.originalField.constant();
47 }
48
49 /**
50  * @see org.eclipse.jdt.internal.compiler.lookup.FieldBinding#original()
51  */

52 public FieldBinding original() {
53     return this.originalField.original();
54 }
55
56 /**
57  * @see org.eclipse.jdt.internal.compiler.lookup.VariableBinding#constant()
58  */

59 public void setConstant(Constant constant) {
60     this.originalField.setConstant(constant);
61 }
62 }
63
Popular Tags