edu.rice.cs.cunit.subAnnot
Class AAnnotatedElementEx

java.lang.Object
  extended by edu.rice.cs.cunit.subAnnot.AAnnotatedElementEx
All Implemented Interfaces:
AnnotatedElementEx
Direct Known Subclasses:
ClassEx, ConstructorEx, FieldEx, MethodEx, PackageEx

public abstract class AAnnotatedElementEx
extends java.lang.Object
implements AnnotatedElementEx

Abstract class for annotated elements supporting annotations with subtyping.

Author:
Mathias Ricken

Field Summary
protected  RuntimeVisibleAnnotationsAttributeInfo[] _ai
          Annotations attribute.
protected  boolean _classFileNotFound
          True if the class file was not found and only the information given by Java's Class class is available.
protected  java.lang.ClassLoader _classLoader
          Class loader to use, or null to use the bootstrap class loader.
protected static java.util.ArrayList<java.lang.String> _classPath
          List of class path entries.
 
Constructor Summary
protected AAnnotatedElementEx()
          Constructor leaving the _classLoader field empty.
protected AAnnotatedElementEx(java.lang.ClassLoader cl)
          Constructor setting the _classLoader field.
 
Method Summary
protected  void findMethodAnnotationsAttributeInfo(java.lang.reflect.Member member, java.lang.String name, java.lang.Class<?>[] types)
          Find the annotations attribute and assign it to the _ai field.
protected abstract  java.lang.reflect.AnnotatedElement getAnnotatedElement()
          Return the annotated element.
 java.lang.annotation.Annotation[] getAnnotations()
          Return an array of all annotations attached to the element.
<A extends java.lang.annotation.Annotation>
java.util.List<A>
getAnnotations(java.lang.Class<A> c)
          Return an array of the annotations attached to the element that are subclasses of the specified class.
<A extends java.lang.annotation.Annotation>
java.util.List<A>
getAnnotations(ClassEx<A> c)
          Return an array of the annotations attached to the element that are subclasses of the specified class.
 java.lang.ClassLoader getClassLoader()
          Returns the class loader used.
 java.lang.annotation.Annotation[] getDeclaredAnnotations()
          Return an array of all annotations attached directly to the element.
<A extends java.lang.annotation.Annotation>
java.util.List<A>
getDeclaredAnnotations(java.lang.Class<A> c)
          Return an array of the annotations attached to the element that are subclasses of the specified class.
<A extends java.lang.annotation.Annotation>
java.util.List<A>
getDeclaredAnnotations(ClassEx<A> c)
          Return an array of the annotations attached to the element that are subclasses of the specified class.
protected  RuntimeVisibleLocalVariableAnnotationsAttributeInfo getLocalVarAnnotationsAttributeInfo(java.lang.reflect.Member member, java.lang.String name, java.lang.Class<?>[] types)
          Return the local variable annotations attribute.
protected  RuntimeVisibleParameterAnnotationsAttributeInfo getParameterAnnotationsAttributeInfo(java.lang.reflect.Member member, java.lang.String name, java.lang.Class<?>[] types)
          Return the parameter annotations attribute.
 boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> c)
          Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false.
 boolean isAnnotationPresent(ClassEx<? extends java.lang.annotation.Annotation> c)
          Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false.
 boolean isAvailable()
          Returns true if the class file was found and additional information is available beyond what Java's Class class might return.
 boolean isDeclaredAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> c)
          Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false.
 boolean isDeclaredAnnotationPresent(ClassEx<? extends java.lang.annotation.Annotation> c)
          Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false.
protected  void setClassFileNotFound(boolean b)
          Set the state of the _classFileNotFound flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ai

protected RuntimeVisibleAnnotationsAttributeInfo[] _ai
Annotations attribute.


_classFileNotFound

protected boolean _classFileNotFound
True if the class file was not found and only the information given by Java's Class class is available.


_classLoader

protected java.lang.ClassLoader _classLoader
Class loader to use, or null to use the bootstrap class loader.


_classPath

protected static java.util.ArrayList<java.lang.String> _classPath
List of class path entries.

Constructor Detail

AAnnotatedElementEx

protected AAnnotatedElementEx()
Constructor leaving the _classLoader field empty.


AAnnotatedElementEx

protected AAnnotatedElementEx(java.lang.ClassLoader cl)
Constructor setting the _classLoader field.

Parameters:
cl - class loader
Method Detail

getClassLoader

public java.lang.ClassLoader getClassLoader()
Returns the class loader used.

Returns:
class loader or null if the bootstrap class loader is used.

isAvailable

public boolean isAvailable()
Returns true if the class file was found and additional information is available beyond what Java's Class class might return.

Specified by:
isAvailable in interface AnnotatedElementEx
Returns:
true if class file was found.

setClassFileNotFound

protected void setClassFileNotFound(boolean b)
Set the state of the _classFileNotFound flag.

Parameters:
b - new state of the _classFileNotFound flag.

isAnnotationPresent

public boolean isAnnotationPresent(ClassEx<? extends java.lang.annotation.Annotation> c)
Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

Specified by:
isAnnotationPresent in interface AnnotatedElementEx
Parameters:
c - class
Returns:
true if present

isAnnotationPresent

public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> c)
Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

Specified by:
isAnnotationPresent in interface AnnotatedElementEx
Parameters:
c - class
Returns:
true if present

getAnnotations

public <A extends java.lang.annotation.Annotation> java.util.List<A> getAnnotations(ClassEx<A> c)
Return an array of the annotations attached to the element that are subclasses of the specified class.

Specified by:
getAnnotations in interface AnnotatedElementEx
Parameters:
c - class
Returns:
array of annotations

getAnnotations

public <A extends java.lang.annotation.Annotation> java.util.List<A> getAnnotations(java.lang.Class<A> c)
Return an array of the annotations attached to the element that are subclasses of the specified class.

Specified by:
getAnnotations in interface AnnotatedElementEx
Parameters:
c - class
Returns:
array of annotations

getAnnotations

public java.lang.annotation.Annotation[] getAnnotations()
Return an array of all annotations attached to the element.

Specified by:
getAnnotations in interface AnnotatedElementEx
Returns:
array of annotations

isDeclaredAnnotationPresent

public boolean isDeclaredAnnotationPresent(ClassEx<? extends java.lang.annotation.Annotation> c)
Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false. This method is designed primarily for convenient access to marker annotations. Contrary to isAnnotationPresent, this does not consider annotations inherited from superclasses.

Specified by:
isDeclaredAnnotationPresent in interface AnnotatedElementEx
Parameters:
c - class
Returns:
true if present

isDeclaredAnnotationPresent

public boolean isDeclaredAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> c)
Returns true if an annotation for the specified type or one of its subtypes is present on this element, else false. This method is designed primarily for convenient access to marker annotations. Contrary to isAnnotationPresent, this does not consider annotations inherited from superclasses.

Specified by:
isDeclaredAnnotationPresent in interface AnnotatedElementEx
Parameters:
c - class
Returns:
true if present

getDeclaredAnnotations

public <A extends java.lang.annotation.Annotation> java.util.List<A> getDeclaredAnnotations(ClassEx<A> c)
Return an array of the annotations attached to the element that are subclasses of the specified class. Contrary to getAnnotations, this does not consider annotations inherited from superclasses.

Specified by:
getDeclaredAnnotations in interface AnnotatedElementEx
Parameters:
c - class
Returns:
array of annotations

getDeclaredAnnotations

public <A extends java.lang.annotation.Annotation> java.util.List<A> getDeclaredAnnotations(java.lang.Class<A> c)
Return an array of the annotations attached to the element that are subclasses of the specified class. Contrary to isAnnotationPresent, this does not consider annotations inherited from superclasses.

Specified by:
getDeclaredAnnotations in interface AnnotatedElementEx
Parameters:
c - class
Returns:
array of annotations

getDeclaredAnnotations

public java.lang.annotation.Annotation[] getDeclaredAnnotations()
Return an array of all annotations attached directly to the element. Contrary to getAnnotations(), this does not consider annotations inherited from superclasses.

Specified by:
getDeclaredAnnotations in interface AnnotatedElementEx
Returns:
array of annotations

getAnnotatedElement

protected abstract java.lang.reflect.AnnotatedElement getAnnotatedElement()
Return the annotated element.

Returns:
annotated element

findMethodAnnotationsAttributeInfo

protected void findMethodAnnotationsAttributeInfo(java.lang.reflect.Member member,
                                                  java.lang.String name,
                                                  java.lang.Class<?>[] types)
Find the annotations attribute and assign it to the _ai field.

Parameters:
member - member whose annotations attribute should be found
name - member name
types - parameter types

getParameterAnnotationsAttributeInfo

protected RuntimeVisibleParameterAnnotationsAttributeInfo getParameterAnnotationsAttributeInfo(java.lang.reflect.Member member,
                                                                                               java.lang.String name,
                                                                                               java.lang.Class<?>[] types)
Return the parameter annotations attribute.

Parameters:
member - member whose parameter annotations attribute should be found
name - member name
types - parameter types
Returns:
parameter annotations attribute

getLocalVarAnnotationsAttributeInfo

protected RuntimeVisibleLocalVariableAnnotationsAttributeInfo getLocalVarAnnotationsAttributeInfo(java.lang.reflect.Member member,
                                                                                                  java.lang.String name,
                                                                                                  java.lang.Class<?>[] types)
Return the local variable annotations attribute.

Parameters:
member - member whose parameter annotations attribute should be found
name - member name
types - parameter types
Returns:
parameter annotations attribute