KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class UnresolvedAnnotationBinding extends AnnotationBinding {
14     private LookupEnvironment env;
15     private boolean typeUnresolved = true;
16
17 UnresolvedAnnotationBinding(ReferenceBinding type, ElementValuePair[] pairs, LookupEnvironment env) {
18     super(type, pairs);
19     this.env = env;
20 }
21
22 public ReferenceBinding getAnnotationType() {
23     if (this.typeUnresolved) { // the type is resolved when requested
24
this.type = BinaryTypeBinding.resolveType(this.type, this.env, false);
25             // annotation type are never parameterized
26
this.typeUnresolved = false;
27     }
28     return this.type;
29 }
30
31 public ElementValuePair[] getElementValuePairs() {
32     if (this.env != null) {
33         if (this.typeUnresolved) {
34             getAnnotationType(); // resolve the annotation type
35
}
36         // resolve method binding and value type (if unresolved) for each pair
37
for (int i = this.pairs.length; --i >= 0;) {
38             ElementValuePair pair = this.pairs[i];
39             MethodBinding[] methods = this.type.getMethods(pair.getName());
40             // there should be exactly one since the type is an annotation type.
41
if (methods != null && methods.length == 1) {
42                 pair.setMethodBinding(methods[0]);
43             } // else silently leave a null there
44
Object JavaDoc value = pair.getValue();
45             if (value instanceof UnresolvedReferenceBinding) {
46                 pair.setValue(((UnresolvedReferenceBinding) value).
47                         resolve(this.env, false));
48                             // no parameterized types in annotation values
49
} // do nothing for UnresolvedAnnotationBinding-s, since their
50
// content is only accessed through get* methods
51
}
52         this.env = null;
53     }
54     return this.pairs;
55 }
56 }
57
Popular Tags