classUtils.javassist.sample.vector
Class VectorAssistant

java.lang.Object
  extended by classUtils.javassist.sample.vector.VectorAssistant
All Implemented Interfaces:
Assistant

public class VectorAssistant
extends java.lang.Object
implements Assistant

This is a Javassist program which produce a new class representing vectors of a given type. For example,

requests the Javassist preprocessor to substitute the following lines for the original import declaration:

The Javassist preprocessor calls VectorAssistant.assist() and produces class intVector equivalent to:

VectorAssistant.assist() uses sample.vector.Sample and sample.vector.Sample2 as a template to produce the methods add() and affineTransform().


Field Summary
 java.lang.String packageName
           
 
Constructor Summary
VectorAssistant()
           
 
Method Summary
 CompileTimeClass[] assist(ClassPool pool, java.lang.String vec, java.lang.String[] args)
          Calls makeSubclass() and produces a new vector class.
 CompileTimeClass makeSubclass(ClassPool pool, CompileTimeClass type)
          Produces a new vector class.
 CompileTimeClass makeSubclass2(ClassPool pool, CompileTimeClass type)
          Produces a new vector class.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

packageName

public final java.lang.String packageName
See Also:
Constant Field Values
Constructor Detail

VectorAssistant

public VectorAssistant()
Method Detail

assist

public CompileTimeClass[] assist(ClassPool pool,
                                 java.lang.String vec,
                                 java.lang.String[] args)
                          throws CannotCompileException
Calls makeSubclass() and produces a new vector class. This method is called by a javassist.preproc.Compiler.

Specified by:
assist in interface Assistant
Parameters:
pool - class pool
vec - the class imported by the declaration
args - the parameters specified by the annotation
Returns:
the classes imported in the java source program produced by the preprocessor.
Throws:
CannotCompileException
See Also:
Compiler

makeSubclass

public CompileTimeClass makeSubclass(ClassPool pool,
                                     CompileTimeClass type)
                              throws CannotCompileException,
                                     NotFoundException,
                                     java.io.IOException
Produces a new vector class. This method does not work if the element type is a primitive type.

Parameters:
type - the type of elements
Throws:
CannotCompileException
NotFoundException
java.io.IOException

makeSubclass2

public CompileTimeClass makeSubclass2(ClassPool pool,
                                      CompileTimeClass type)
                               throws CannotCompileException,
                                      NotFoundException,
                                      java.io.IOException
Produces a new vector class. This uses wrapped methods so that the element type can be a primitive type.

Parameters:
type - the type of elements
Throws:
CannotCompileException
NotFoundException
java.io.IOException