jcaas.util
Class AnnotationUtil

java.lang.Object
  extended by jcaas.util.AnnotationUtil

public class AnnotationUtil
extends java.lang.Object

This class provides a set of utility methods for annotating a class file.


Constructor Summary
AnnotationUtil()
           
 
Method Summary
static org.apache.bcel.classfile.JavaClass produceAnnotatedJavaClass(AnnotationScript script, org.apache.bcel.classfile.JavaClass jclass)
          Given an AnnotationScript object and a JavaClass object, creates a new JavaClass object representing the AnnotationsScript object's annotation of that class.
static org.apache.bcel.classfile.JavaClass produceAnnotatedJavaClass(java.io.File scriptFile, org.apache.bcel.classfile.JavaClass jclass)
          Given a File object pointing to an annotation script and a JavaClass object representing a java class to annotate, gives a JavaClass such that the annotations of the script are applied to it.
static void writeAnnotationOfClassFile(AnnotationScript script, java.io.File in, java.io.File out)
          Given an AnnotationScript instance, and two File, in and out, reads the class file from in, runs the AnnotationScript on all InstructionLists in the class and then writes the annotated version to the out file.
static void writeAnnotationOfClassFile(java.io.File scriptFile, java.io.File in, java.io.File out)
          Given three File objects representing a annotation script file, class file to read, and a class file to write to, builds an AnnotationScript instance, runs it on the given class, and writes its annotated version.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationUtil

public AnnotationUtil()
Method Detail

produceAnnotatedJavaClass

public static org.apache.bcel.classfile.JavaClass produceAnnotatedJavaClass(AnnotationScript script,
                                                                            org.apache.bcel.classfile.JavaClass jclass)
                                                                     throws java.lang.Exception
Given an AnnotationScript object and a JavaClass object, creates a new JavaClass object representing the AnnotationsScript object's annotation of that class.

Parameters:
script - the annotation script.
jclass - the class to annotated.
Returns:
the given class annotated.
Throws:
java.lang.Exception

produceAnnotatedJavaClass

public static org.apache.bcel.classfile.JavaClass produceAnnotatedJavaClass(java.io.File scriptFile,
                                                                            org.apache.bcel.classfile.JavaClass jclass)
                                                                     throws java.lang.Exception
Given a File object pointing to an annotation script and a JavaClass object representing a java class to annotate, gives a JavaClass such that the annotations of the script are applied to it.

Parameters:
scriptFile - the annotation script.
jclass - the class to annotate.
Returns:
a JavaClass that is annotated.
Throws:
java.lang.Exception

writeAnnotationOfClassFile

public static void writeAnnotationOfClassFile(AnnotationScript script,
                                              java.io.File in,
                                              java.io.File out)
                                       throws java.lang.Exception
Given an AnnotationScript instance, and two File, in and out, reads the class file from in, runs the AnnotationScript on all InstructionLists in the class and then writes the annotated version to the out file.

Parameters:
script - an AnnotationScript to run on the class.
in - the file to read the class from.
out - the file to write the class to.
Throws:
java.lang.Exception - thrown when their is parsing or I/O error.

writeAnnotationOfClassFile

public static void writeAnnotationOfClassFile(java.io.File scriptFile,
                                              java.io.File in,
                                              java.io.File out)
                                       throws java.lang.Exception
Given three File objects representing a annotation script file, class file to read, and a class file to write to, builds an AnnotationScript instance, runs it on the given class, and writes its annotated version.

Parameters:
scriptFile - a File object pointing to a valid annotation script.
in - a File object pointing to a valid class file.
out - a File object pointing to a file to which the annotated class will be written.
Throws:
java.lang.Exception - thrown in the case of an I/O exception or parsing exception.