KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > NormalAnnotation


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.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.lookup.*;
15
16 /**
17  * Normal annotation node
18  */

19 public class NormalAnnotation extends Annotation {
20     
21     public MemberValuePair[] memberValuePairs;
22     
23     public NormalAnnotation(TypeReference type, int sourceStart) {
24         this.type = type;
25         this.sourceStart = sourceStart;
26         this.sourceEnd = type.sourceEnd;
27     }
28
29     public ElementValuePair[] computeElementValuePairs() {
30         int numberOfPairs = this.memberValuePairs == null ? 0 : this.memberValuePairs.length;
31         if (numberOfPairs == 0)
32             return Binding.NO_ELEMENT_VALUE_PAIRS;
33
34         ElementValuePair[] pairs = new ElementValuePair[numberOfPairs];
35         for (int i = 0; i < numberOfPairs; i++)
36             pairs[i] = this.memberValuePairs[i].compilerElementPair;
37         return pairs;
38     }
39
40     /**
41      * @see org.eclipse.jdt.internal.compiler.ast.Annotation#memberValuePairs()
42      */

43     public MemberValuePair[] memberValuePairs() {
44         return this.memberValuePairs == null ? NoValuePairs : this.memberValuePairs;
45     }
46     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
47         super.printExpression(indent, output);
48         output.append('(');
49         if (this.memberValuePairs != null) {
50             for (int i = 0, max = this.memberValuePairs.length; i < max; i++) {
51                 if (i > 0) {
52                     output.append(',');
53                 }
54                 this.memberValuePairs[i].print(indent, output);
55             }
56         }
57         output.append(')');
58         return output;
59     }
60     
61     public void traverse(ASTVisitor visitor, BlockScope scope) {
62         if (visitor.visit(this, scope)) {
63             if (this.memberValuePairs != null) {
64                 int memberValuePairsLength = this.memberValuePairs.length;
65                 for (int i = 0; i < memberValuePairsLength; i++)
66                     this.memberValuePairs[i].traverse(visitor, scope);
67             }
68         }
69         visitor.endVisit(this, scope);
70     }
71 }
72
Popular Tags