biz.hammurapi.codegen
Class ClassGeneratorBase

java.lang.Object
  extended by biz.hammurapi.codegen.ClassGeneratorBase
Direct Known Subclasses:
Class, Interface

public class ClassGeneratorBase
extends java.lang.Object

Version:
$Revision: 1.9 $
Author:
Pavel Vlasov

Nested Class Summary
protected  class ClassGeneratorBase.FieldDescriptor
           
 
Field Summary
protected  org.apache.bcel.generic.ClassGen cg
           
protected  GenerationListener listener
           
 
Constructor Summary
ClassGeneratorBase()
           
 
Method Summary
 void addField(java.lang.String declaration, java.lang.String description, java.util.Properties attributes)
           
 void addStaticInitializer(org.apache.bcel.generic.InstructionList instructionList, java.util.Collection exceptionHandlers, java.lang.String description)
           
protected  boolean checkMethod(java.lang.Object signature, java.lang.String returnType, java.util.Collection throwsList)
           
 org.apache.bcel.generic.InstructionList cloneInstructions(java.lang.Class clazz, java.lang.String signature)
          Copies instructions of existing method.
static java.lang.String concat(java.lang.String packageName, java.lang.String className)
           
 org.apache.bcel.generic.FieldInstruction createGetField(java.lang.String fieldName)
          This method shall be used only with fields added through addField()
 org.apache.bcel.generic.InvokeInstruction createInvoke(java.lang.String signature, java.util.Collection parameters, short type)
          Creates invoke instruction for the method in the current class.
 org.apache.bcel.generic.InvokeInstruction createInvoke(java.lang.String className, java.lang.String signature, java.util.Collection parameters, short type)
          Creates invoke instruction for the method in the current class.
 org.apache.bcel.generic.FieldInstruction createPutField(java.lang.String fieldName)
          This method shall be used only with fields added through addField()
protected static antlr.collections.AST field(java.lang.String definition)
           
 org.apache.bcel.generic.ClassGen getClassGen()
           
 org.apache.bcel.generic.InstructionFactory getInstructionFactory()
           
 org.apache.bcel.classfile.JavaClass getJavaClass()
           
static org.apache.bcel.classfile.Method getMethod(java.lang.Class clazz, java.lang.String signature)
           
 boolean hasField(java.lang.String name)
           
protected static antlr.collections.AST invocation(java.lang.String definition)
           
static org.apache.bcel.generic.Type java2BcelType(java.lang.String type)
           
static short modifiers(java.util.Collection modifiers)
           
static void printMethod(java.lang.Class clazz, java.lang.String signature)
           
static void printMethod(org.apache.bcel.classfile.Method method)
           
 void save(java.io.File dir)
           
protected static void showField(java.lang.String field)
           
protected static void showInvocation(java.lang.String invocation)
           
protected static void showTypeDefinition(java.lang.String typeDefinition)
           
protected static java.lang.String toString(antlr.collections.AST ast)
           
protected static antlr.collections.AST typeDefinition(java.lang.String definition)
           
static java.util.Collection verify(java.util.Collection javaClasses, java.lang.ClassLoader classLoader)
          Verifies collection of classes and returns colleciton of error messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

protected GenerationListener listener

cg

protected org.apache.bcel.generic.ClassGen cg
Constructor Detail

ClassGeneratorBase

public ClassGeneratorBase()
Method Detail

checkMethod

protected boolean checkMethod(java.lang.Object signature,
                              java.lang.String returnType,
                              java.util.Collection throwsList)
                       throws GenerationException
Parameters:
signature - Method signature
rtthc - Method return type and throws
Returns:
true - method shall be added
Throws:
GenerationException - If method exists, but return type or throws are different

modifiers

public static short modifiers(java.util.Collection modifiers)
                       throws GenerationException
Throws:
GenerationException

getJavaClass

public org.apache.bcel.classfile.JavaClass getJavaClass()
Returns:
Throws:
GenerationException

verify

public static java.util.Collection verify(java.util.Collection javaClasses,
                                          java.lang.ClassLoader classLoader)
Verifies collection of classes and returns colleciton of error messages.


getClassGen

public org.apache.bcel.generic.ClassGen getClassGen()

getInstructionFactory

public org.apache.bcel.generic.InstructionFactory getInstructionFactory()

save

public void save(java.io.File dir)
          throws java.io.IOException
Throws:
java.io.IOException

cloneInstructions

public org.apache.bcel.generic.InstructionList cloneInstructions(java.lang.Class clazz,
                                                                 java.lang.String signature)
                                                          throws java.lang.ClassNotFoundException,
                                                                 java.lang.NoSuchMethodException
Copies instructions of existing method.

Parameters:
clazz -
signature - E.g. setName(java.lang.String)
Returns:
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException

getMethod

public static org.apache.bcel.classfile.Method getMethod(java.lang.Class clazz,
                                                         java.lang.String signature)
                                                  throws java.lang.ClassNotFoundException,
                                                         java.lang.NoSuchMethodException
Parameters:
clazz -
signature -
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException

printMethod

public static void printMethod(java.lang.Class clazz,
                               java.lang.String signature)
                        throws java.lang.ClassNotFoundException,
                               java.lang.NoSuchMethodException
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchMethodException

concat

public static java.lang.String concat(java.lang.String packageName,
                                      java.lang.String className)

printMethod

public static void printMethod(org.apache.bcel.classfile.Method method)
Parameters:
methods -
i -

createInvoke

public org.apache.bcel.generic.InvokeInstruction createInvoke(java.lang.String signature,
                                                              java.util.Collection parameters,
                                                              short type)
                                                       throws GenerationException
Creates invoke instruction for the method in the current class.

Parameters:
signature -
type -
Returns:
Throws:
GenerationException

createInvoke

public org.apache.bcel.generic.InvokeInstruction createInvoke(java.lang.String className,
                                                              java.lang.String signature,
                                                              java.util.Collection parameters,
                                                              short type)
                                                       throws GenerationException
Creates invoke instruction for the method in the current class.

Parameters:
signature - E.g. int getA()
type -
Returns:
Throws:
GenerationException

java2BcelType

public static org.apache.bcel.generic.Type java2BcelType(java.lang.String type)
Parameters:
type -
Returns:

typeDefinition

protected static antlr.collections.AST typeDefinition(java.lang.String definition)
                                               throws GenerationException
Throws:
GenerationException

showTypeDefinition

protected static void showTypeDefinition(java.lang.String typeDefinition)
                                  throws GenerationException
Throws:
GenerationException

addField

public void addField(java.lang.String declaration,
                     java.lang.String description,
                     java.util.Properties attributes)
              throws GenerationException
Throws:
GenerationException

hasField

public boolean hasField(java.lang.String name)

field

protected static antlr.collections.AST field(java.lang.String definition)
                                      throws GenerationException
Throws:
GenerationException

showField

protected static void showField(java.lang.String field)
                         throws GenerationException
Throws:
GenerationException

invocation

protected static antlr.collections.AST invocation(java.lang.String definition)
                                           throws GenerationException
Throws:
GenerationException

showInvocation

protected static void showInvocation(java.lang.String invocation)
                              throws GenerationException
Throws:
GenerationException

toString

protected static java.lang.String toString(antlr.collections.AST ast)

addStaticInitializer

public void addStaticInitializer(org.apache.bcel.generic.InstructionList instructionList,
                                 java.util.Collection exceptionHandlers,
                                 java.lang.String description)
                          throws GenerationException
Throws:
GenerationException

createGetField

public org.apache.bcel.generic.FieldInstruction createGetField(java.lang.String fieldName)
This method shall be used only with fields added through addField()

Parameters:
fieldName -
Returns:

createPutField

public org.apache.bcel.generic.FieldInstruction createPutField(java.lang.String fieldName)
This method shall be used only with fields added through addField()

Parameters:
fieldName -
Returns:


Copyright © 2003 Hammurapi Group. All Rights Reserved.