org.codehaus.backport175.compiler.bytecode
Class AnnotationEnhancer

java.lang.Object
  extended by org.codehaus.backport175.compiler.bytecode.AnnotationEnhancer

public class AnnotationEnhancer
extends java.lang.Object

Enhances the target class with the JavaDoc annotations by putting them in the class bytecode as Java 5 java.lang.reader.RetentionPolicy.RUNTIME annotations.

Author:
Jonas Bonér, Alexandre Vasseur

Constructor Summary
AnnotationEnhancer(MessageHandler messageHandler)
          Constructor
 
Method Summary
 java.lang.String getClassFileName()
           
 java.lang.ClassLoader getClassLoader()
           
 java.lang.String getClassName()
           
static java.lang.String getDescForQDoxType(com.thoughtworks.qdox.model.Type type)
          Returns the VM desc for a QDox Type.
static java.lang.String getFieldDesc(JavaField field)
          Returns the VM desc for a QDox field.
static java.lang.String getMethodDesc(JavaMethod method)
          Returns the VM desc for a QDox method.
 boolean initialize(java.lang.String className, java.lang.ClassLoader loader)
          Initializes the enhancer.
 boolean initialize(java.lang.String className, java.net.URL[] classPath)
          Initializes the enhancer.
 void insertClassAnnotation(RawAnnotation annotation)
          Inserts an annotation on class level.
 void insertConstructorAnnotation(JavaMethod constructor, RawAnnotation annotation)
          Inserts an annotation on constructor level.
 void insertFieldAnnotation(JavaField field, RawAnnotation annotation)
          Inserts an annotation on field level.
 void insertMethodAnnotation(JavaMethod method, RawAnnotation annotation)
          Inserts an annotation on method level.
 void write(java.lang.String destDir)
          Writes the enhanced class to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationEnhancer

public AnnotationEnhancer(MessageHandler messageHandler)
Constructor

Parameters:
messageHandler -
Method Detail

initialize

public boolean initialize(java.lang.String className,
                          java.net.URL[] classPath)
Initializes the enhancer. Must always be called before use.

Parameters:
className - the class name
classPath - the class path
Returns:
true if the class was succefully loaded, false otherwise

initialize

public boolean initialize(java.lang.String className,
                          java.lang.ClassLoader loader)
Initializes the enhancer. Must always be called before use.

Parameters:
className - the class name
loader -
Returns:
true if the class was succefully loaded, false otherwise

insertClassAnnotation

public void insertClassAnnotation(RawAnnotation annotation)
Inserts an annotation on class level.

Parameters:
annotation - the annotation

insertFieldAnnotation

public void insertFieldAnnotation(JavaField field,
                                  RawAnnotation annotation)
Inserts an annotation on field level.

Parameters:
field - the QDox java field
annotation - the annotation

insertMethodAnnotation

public void insertMethodAnnotation(JavaMethod method,
                                   RawAnnotation annotation)
Inserts an annotation on method level.

Parameters:
method - the QDox java method
annotation - the annotation

insertConstructorAnnotation

public void insertConstructorAnnotation(JavaMethod constructor,
                                        RawAnnotation annotation)
Inserts an annotation on constructor level.

Parameters:
constructor - the QDox java method
annotation - the annotation

write

public void write(java.lang.String destDir)
Writes the enhanced class to file.

Parameters:
destDir - the destination directory

getFieldDesc

public static java.lang.String getFieldDesc(JavaField field)
Returns the VM desc for a QDox field.

Parameters:
field - the QDox field
Returns:
the desc

getMethodDesc

public static java.lang.String getMethodDesc(JavaMethod method)
Returns the VM desc for a QDox method.

Parameters:
method - the QDox method
Returns:
the desc

getDescForQDoxType

public static java.lang.String getDescForQDoxType(com.thoughtworks.qdox.model.Type type)
Returns the VM desc for a QDox Type.

Parameters:
type - the qdox type
Returns:
the desc

getClassName

public java.lang.String getClassName()

getClassFileName

public java.lang.String getClassFileName()

getClassLoader

public java.lang.ClassLoader getClassLoader()