org.apache.avalon.fortress.impl.factory
Class BCELCodeGenerator

java.lang.Object
  |
  +--org.apache.avalon.fortress.impl.factory.BCELCodeGenerator

public final class BCELCodeGenerator
extends Object

BCELCodeGenerator creates implementations for the Methods and Fields needed in creating a WrapperClass.

Author:
Constructor Summary
BCELCodeGenerator()
          Default constructor.
 
Method Summary
 org.apache.bcel.classfile.Method createDefaultConstructor()
          Create the wrapper class' default constructor:
 org.apache.bcel.classfile.Method[] createImplementation(org.apache.bcel.classfile.JavaClass interfaceToImplement)
          Creates an implementation for the supplied JavaClass instance representing an interface.
 org.apache.bcel.classfile.Method createMethodWrapper(org.apache.bcel.classfile.Method methodToWrap)
          Create a method declaration/definition of the form
 org.apache.bcel.classfile.Method createMethodWrapper(String methodName, org.apache.bcel.generic.Type returnType, org.apache.bcel.generic.Type[] parameterTypes, String[] exceptionNames)
          Create a method declaration/definition of the form
 org.apache.bcel.classfile.Method createWrappedClassAccessor()
          Create a field accessor for the wrapped class instance of the form
 org.apache.bcel.classfile.Field createWrappedClassField()
          Create a field declaration of the form
 void init(String wrapperClassName, String wrapperSuperclassName, org.apache.bcel.classfile.JavaClass classToWrap, org.apache.bcel.generic.ClassGen classGenerator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BCELCodeGenerator

public BCELCodeGenerator()
Default constructor.

Method Detail

init

public void init(String wrapperClassName,
                 String wrapperSuperclassName,
                 org.apache.bcel.classfile.JavaClass classToWrap,
                 org.apache.bcel.generic.ClassGen classGenerator)
          throws IllegalArgumentException
IllegalArgumentException

createWrappedClassField

public org.apache.bcel.classfile.Field createWrappedClassField()
                                                        throws IllegalStateException
Create a field declaration of the form
  
      private  WRAPPED_CLASS_FN;
  
 

Returns:
Field
Throws:
IllegalStateException - If this instance is not initialized.

createDefaultConstructor

public org.apache.bcel.classfile.Method createDefaultConstructor()
                                                          throws IllegalStateException
Create the wrapper class' default constructor:
  
      public ( classToWrap)
      {
          this. = classToWrap;
      }
  
 

Returns:
The created default constructor
Throws:
IllegalStateException - If this instance is not initialized.

createWrappedClassAccessor

public org.apache.bcel.classfile.Method createWrappedClassAccessor()
                                                            throws IllegalStateException
Create a field accessor for the wrapped class instance of the form
  
      public Object ()
      {
          return this.;
      }
  
 

Returns:
Method
Throws:
IllegalStateException

createMethodWrapper

public org.apache.bcel.classfile.Method createMethodWrapper(String methodName,
                                                            org.apache.bcel.generic.Type returnType,
                                                            org.apache.bcel.generic.Type[] parameterTypes,
                                                            String[] exceptionNames)
                                                     throws IllegalArgumentException,
                                                            IllegalStateException
Create a method declaration/definition of the form
  
      public  ()
          throws 
      {
          return this..();
      }
  
 

Parameters:
methodName - The name of the method to create
returnType - The return type of the method to create
parameterTypes - The array of parameter types of the method to create
exceptionNames - The array of the names of the exceptions the method to create might throw
Returns:
Method The Method object representing the created method
Throws:
IllegalArgumentException - If any of the parameters passed in is null.
IllegalStateException - If this instance is not initialized.

createMethodWrapper

public org.apache.bcel.classfile.Method createMethodWrapper(org.apache.bcel.classfile.Method methodToWrap)
                                                     throws IllegalArgumentException,
                                                            IllegalStateException
Create a method declaration/definition of the form
  
      public  ()
          throws 
      {
          return this..();
      }
  
 

Parameters:
methodToWrap - The Method to create a wrapper for.
Returns:
Method The wrapper method.
Throws:
IllegalArgumentException - If methodToWrao is null.
IllegalStateException - If this instance is not initialized.

createImplementation

public org.apache.bcel.classfile.Method[] createImplementation(org.apache.bcel.classfile.JavaClass interfaceToImplement)
                                                        throws Exception
Creates an implementation for the supplied JavaClass instance representing an interface.

Parameters:
interfaceToImplement - The interface we want to create an implementation for
Returns:
Method[] An array of Method instances representing the interface implementation.
Throws:
IllegalArgumentException - If interfaceToImplement is null or does not represent an interface
IllegalStateException - If this instance has not been initialized
Exception


Copyright © 2000-2002 Apache Avalon Project. All Rights Reserved.