com.sun.tools.apt.mirror.declaration
Class DeclarationImpl

java.lang.Object
  extended by com.sun.tools.apt.mirror.declaration.DeclarationImpl
All Implemented Interfaces:
Declaration
Direct Known Subclasses:
MemberDeclarationImpl, PackageDeclarationImpl, ParameterDeclarationImpl, TypeParameterDeclarationImpl

public abstract class DeclarationImpl
extends java.lang.Object
implements Declaration

Implementation of Declaration


Field Summary
protected  AptEnv env
           
protected static DeclarationFilter identityFilter
           
private  java.util.Collection<Symbol> members
           
private  java.util.EnumSet<Modifier> modifiers
           
 Symbol sym
           
 
Constructor Summary
protected DeclarationImpl(AptEnv env, Symbol sym)
          "sym" should be completed before this constructor is called.
 
Method Summary
 void accept(DeclarationVisitor v)
          Applies a visitor to this declaration.
 boolean equals(java.lang.Object obj)
          Tests whether an object represents the same declaration as this.
<A extends java.lang.annotation.Annotation>
A
getAnnotation(java.lang.Class<A> annoType)
          Returns the annotation of this declaration having the specified type. Overridden by ClassDeclarationImpl to handle @Inherited.
protected
<A extends java.lang.annotation.Annotation>
A
getAnnotation(java.lang.Class<A> annoType, Symbol annotated)
           
 java.util.Collection<AnnotationMirror> getAnnotationMirrors()
          Returns the annotations that are directly present on this declaration.
 java.lang.String getDocComment()
          Returns the text of the documentation ("javadoc") comment of this declaration.
private  Env<AttrContext> getEnterEnv()
          Returns this declaration's enter environment, or null if it has none.
protected  java.util.Collection<Symbol> getMembers(boolean cache)
          Returns the symbols of type or package members (and constructors) that are not synthetic or otherwise unwanted.
 java.util.Collection<Modifier> getModifiers()
          Returns the modifiers of this declaration, excluding annotations.
 SourcePosition getPosition()
          Returns the source position of the beginning of this declaration.
 java.lang.String getSimpleName()
          Returns the simple (unqualified) name of this declaration. Overridden in some subclasses.
 int hashCode()
          
private static boolean unwanted(Symbol s)
          Tests whether this is a symbol that should never be seen by clients, such as a synthetic class.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

env

protected final AptEnv env

sym

public final Symbol sym

identityFilter

protected static DeclarationFilter identityFilter

modifiers

private java.util.EnumSet<Modifier> modifiers

members

private java.util.Collection<Symbol> members
Constructor Detail

DeclarationImpl

protected DeclarationImpl(AptEnv env,
                          Symbol sym)
"sym" should be completed before this constructor is called.

Method Detail

equals

public boolean equals(java.lang.Object obj)
Tests whether an object represents the same declaration as this.

ParameterDeclarationImpl overrides this implementation.

Specified by:
equals in interface Declaration
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to be compared with this declaration
Returns:
true if the specified object represents the same declaration as this

hashCode

public int hashCode()

ParameterDeclarationImpl overrides this implementation.

Overrides:
hashCode in class java.lang.Object

getDocComment

public java.lang.String getDocComment()
Returns the text of the documentation ("javadoc") comment of this declaration.

Specified by:
getDocComment in interface Declaration
Returns:
the documentation comment of this declaration, or null if there is none

getAnnotationMirrors

public java.util.Collection<AnnotationMirror> getAnnotationMirrors()
Returns the annotations that are directly present on this declaration.

Specified by:
getAnnotationMirrors in interface Declaration
Returns:
the annotations directly present on this declaration; an empty collection if there are none

getAnnotation

public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> annoType)
Returns the annotation of this declaration having the specified type. The annotation may be either inherited or directly present on this declaration.

The annotation returned by this method could contain an element whose value is of type Class. This value cannot be returned directly: information necessary to locate and load a class (such as the class loader to use) is not available, and the class might not be loadable at all. Attempting to read a Class object by invoking the relevant method on the returned annotation will result in a MirroredTypeException, from which the corresponding TypeMirror may be extracted. Similarly, attempting to read a Class[]-valued element will result in a MirroredTypesException.

Note: This method is unlike others in this and related interfaces. It operates on run-time reflective information -- representations of annotation types currently loaded into the VM -- rather than on the mirrored representations defined by and used throughout these interfaces. It is intended for callers that are written to operate on a known, fixed set of annotation types.
Overridden by ClassDeclarationImpl to handle @Inherited.

Specified by:
getAnnotation in interface Declaration
Type Parameters:
A - the annotation type
Parameters:
annoType - the Class object corresponding to the annotation type
Returns:
the annotation of this declaration having the specified type
See Also:
Declaration.getAnnotationMirrors()

getAnnotation

protected <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> annoType,
                                                                      Symbol annotated)

getModifiers

public java.util.Collection<Modifier> getModifiers()
Returns the modifiers of this declaration, excluding annotations. Implicit modifiers, such as the public and static modifiers of interface members, are included.

Specified by:
getModifiers in interface Declaration
Returns:
the modifiers of this declaration in undefined order; an empty collection if there are none

getSimpleName

public java.lang.String getSimpleName()
Returns the simple (unqualified) name of this declaration. The name of a generic type does not include any reference to its formal type parameters. For example, the simple name of the interface declaration java.util.Set<E> is "Set". If this declaration represents the empty package, an empty string is returned. If it represents a constructor, the simple name of its declaring class is returned. Overridden in some subclasses.

Specified by:
getSimpleName in interface Declaration
Returns:
the simple name of this declaration

getPosition

public SourcePosition getPosition()
Returns the source position of the beginning of this declaration. Returns null if the position is unknown or not applicable.

This source position is intended for use in providing diagnostics, and indicates only approximately where a declaration begins.

Specified by:
getPosition in interface Declaration
Returns:
the source position of the beginning of this declaration, or null if the position is unknown or not applicable

accept

public void accept(DeclarationVisitor v)
Applies a visitor to this declaration.

Specified by:
accept in interface Declaration
Parameters:
v - the visitor operating on this declaration

getMembers

protected java.util.Collection<Symbol> getMembers(boolean cache)
Returns the symbols of type or package members (and constructors) that are not synthetic or otherwise unwanted. Caches the result if "cache" is true.


unwanted

private static boolean unwanted(Symbol s)
Tests whether this is a symbol that should never be seen by clients, such as a synthetic class. Note that a class synthesized by the compiler may not be flagged as synthetic: see bugid 4959932.


getEnterEnv

private Env<AttrContext> getEnterEnv()
Returns this declaration's enter environment, or null if it has none.