KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > declaration > AnnotationElementDeclarationImpl


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
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  * tyeung@bea.com - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.apt.core.internal.declaration;
13
14 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
15 import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
16 import com.sun.mirror.declaration.AnnotationValue;
17 import com.sun.mirror.declaration.ParameterDeclaration;
18 import com.sun.mirror.util.DeclarationVisitor;
19 import java.util.Collection JavaDoc;
20 import java.util.Collections JavaDoc;
21
22 import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
23 import org.eclipse.jdt.apt.core.internal.util.Factory;
24 import org.eclipse.jdt.core.dom.ASTNode;
25 import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
26 import org.eclipse.jdt.core.dom.IMethodBinding;
27
28 public class AnnotationElementDeclarationImpl extends MethodDeclarationImpl implements AnnotationTypeElementDeclaration
29 {
30     public AnnotationElementDeclarationImpl(final IMethodBinding binding,
31                                             final BaseProcessorEnv env)
32     {
33         super(binding, env);
34     }
35
36     public void accept(DeclarationVisitor visitor)
37     {
38         visitor.visitAnnotationTypeElementDeclaration(this);
39     }
40
41     public AnnotationTypeDeclaration getDeclaringType()
42     {
43         return (AnnotationTypeDeclaration)super.getDeclaringType();
44     }
45
46     /**
47      * @return the default value of this annotation element if one exists.
48      * Return null if the annotation element is defined in binary (feature not available right now).
49      * Return null if the annotation element is part of a seconary type that is defined outside
50      * the file associated with the environment.
51      */

52     public AnnotationValue getDefaultValue()
53     {
54         final IMethodBinding binding = getDeclarationBinding();
55         final Object JavaDoc defaultValue = binding.getDefaultValue();
56         return Factory.createDefaultValue(defaultValue, this, _env);
57     }
58     
59     ASTNode getAstNodeForDefault()
60     {
61         final AnnotationTypeMemberDeclaration decl = (AnnotationTypeMemberDeclaration)getAstNode();
62         if( decl != null )
63             return decl.getDefault();
64         
65         return null;
66     }
67
68     public Collection JavaDoc<ParameterDeclaration> getParameters(){ return Collections.emptyList(); }
69
70     public MirrorKind kind(){ return MirrorKind.ANNOTATION_ELEMENT; }
71 }
72
Popular Tags