com.moesol.generator
Class ClassGeneratorVisitor

java.lang.Object
  extended by com.moesol.generator.ClassGeneratorVisitor
All Implemented Interfaces:
ReflectVisitor
Direct Known Subclasses:
JavaClassGeneratorVisitor, JniClassGeneratorVisitor, JniHeaderClassGeneratorVisitor, TestClassGeneratorVisitor

public abstract class ClassGeneratorVisitor
extends Object
implements ReflectVisitor


Field Summary
protected  Callable current_callable
           
 
Constructor Summary
ClassGeneratorVisitor(Writer out, TranslationContext ctx)
           
 
Method Summary
protected  Callable createCallable(Class a_class, Method method)
          Template method
protected  void extendConstructorProperties(Constructor ctor, Properties p)
          Template method
protected  void extendFieldProperties(Field field, Properties p)
          Template method
protected  void extendMethodProperties(Method method, Properties p)
          Template method
protected  String findConstructorTranslation(String prefix, String type, String suffix, Callable callable)
          Helper for derived classes.
protected  String findFieldTranslation(String prefix, String type, Field field)
          Helper for derived classes.
protected  String findMethodTranslation(String prefix, String type, String suffix, Callable callable)
          Helper for derived classes.
protected  String findMeTranslation(String prefix, String type, Callable callable)
          Helper for derived classes.
protected  String findParameterTranslation(String prefix, String type, Class parameter_type)
           
protected  String findPropInitTranslation(String prefix, String type, Callable callable)
           
protected abstract  String getFieldTemplateName(Field field)
          Template method
protected  String getJniName(Callable callable)
           
protected  String getJniOverload(Callable callable)
           
protected  String getJniReturnError(Callable callable)
           
protected  String getJniSelf(Callable callable)
          Helper for derived classes.
 String getPassAppend()
           
protected  String getPropertyName(Callable callable)
           
protected  String getSeparator(Callable callable)
           
protected abstract  String getTemplateName(Constructor ctor)
          Template method
protected abstract  String getTemplateName(Method method)
          Template method
 TranslationContext getTranslationContext()
           
protected  String getTransProperty(String key)
          Helper for derived classes.
protected  String queryMethodTranslation(String prefix, String type, String suffix, Callable callable)
          Helper for derived classes.
protected  String queryTranslation(String prefix, String type, String[] suffixes, String errName)
           
 void setPassAppend(String pass)
           
 void setPassNumber(int pass_number)
           
protected  boolean shouldGenerateConstructor(Constructor ctor)
          Template method
protected  boolean shouldGenerateField(Field field)
          Template method
protected  boolean shouldGenerateMethod(Method method)
          Template method
 void visit(Class a_class)
          override to change visit strategy
 void visitConstructor(Class c, Constructor ctor)
           
 void visitField(Class c, Field field)
           
 void visitMethod(Class a_class, Method method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current_callable

protected Callable current_callable
Constructor Detail

ClassGeneratorVisitor

public ClassGeneratorVisitor(Writer out,
                             TranslationContext ctx)
Method Detail

visit

public void visit(Class a_class)
           throws ApplyException
override to change visit strategy

Throws:
ApplyException

setPassNumber

public void setPassNumber(int pass_number)

setPassAppend

public void setPassAppend(String pass)

getPassAppend

public String getPassAppend()

createCallable

protected Callable createCallable(Class a_class,
                                  Method method)
                           throws ApplyException
Template method

Throws:
ApplyException

shouldGenerateField

protected boolean shouldGenerateField(Field field)
Template method


extendFieldProperties

protected void extendFieldProperties(Field field,
                                     Properties p)
                              throws ApplyException
Template method

Throws:
ApplyException

getFieldTemplateName

protected abstract String getFieldTemplateName(Field field)
                                        throws ApplyException
Template method

Throws:
ApplyException

shouldGenerateMethod

protected boolean shouldGenerateMethod(Method method)
                                throws ApplyException
Template method

Throws:
ApplyException

extendMethodProperties

protected void extendMethodProperties(Method method,
                                      Properties p)
                               throws ApplyException
Template method

Throws:
ApplyException

getTemplateName

protected abstract String getTemplateName(Method method)
                                   throws ApplyException
Template method

Throws:
ApplyException

shouldGenerateConstructor

protected boolean shouldGenerateConstructor(Constructor ctor)
                                     throws ApplyException
Template method

Throws:
ApplyException

extendConstructorProperties

protected void extendConstructorProperties(Constructor ctor,
                                           Properties p)
                                    throws ApplyException
Template method

Throws:
ApplyException

getTemplateName

protected abstract String getTemplateName(Constructor ctor)
                                   throws ApplyException
Template method

Throws:
ApplyException

getTranslationContext

public TranslationContext getTranslationContext()

visitField

public void visitField(Class c,
                       Field field)
                throws ApplyException
Specified by:
visitField in interface ReflectVisitor
Throws:
ApplyException

visitMethod

public void visitMethod(Class a_class,
                        Method method)
                 throws ApplyException
Specified by:
visitMethod in interface ReflectVisitor
Throws:
ApplyException

visitConstructor

public void visitConstructor(Class c,
                             Constructor ctor)
                      throws ApplyException
Specified by:
visitConstructor in interface ReflectVisitor
Throws:
ApplyException

getPropertyName

protected String getPropertyName(Callable callable)
Returns:
the property name if the method starts with get/set/is

getSeparator

protected String getSeparator(Callable callable)
Returns:
"," if there are at least one parameter, otherwise return ""

findFieldTranslation

protected String findFieldTranslation(String prefix,
                                      String type,
                                      Field field)
                               throws ApplyException
Helper for derived classes.

Throws:
ApplyException

findMeTranslation

protected String findMeTranslation(String prefix,
                                   String type,
                                   Callable callable)
                            throws ApplyException
Helper for derived classes.

Throws:
ApplyException

findMethodTranslation

protected String findMethodTranslation(String prefix,
                                       String type,
                                       String suffix,
                                       Callable callable)
                                throws ApplyException
Helper for derived classes.

Throws:
ApplyException

queryMethodTranslation

protected String queryMethodTranslation(String prefix,
                                        String type,
                                        String suffix,
                                        Callable callable)
                                 throws ApplyException
Helper for derived classes.

Throws:
ApplyException

findConstructorTranslation

protected String findConstructorTranslation(String prefix,
                                            String type,
                                            String suffix,
                                            Callable callable)
                                     throws ApplyException
Helper for derived classes.

Parameters:
prefix -
type -
suffix -
callable -
Returns:
the translation found.
Throws:
ApplyException

findParameterTranslation

protected String findParameterTranslation(String prefix,
                                          String type,
                                          Class parameter_type)
                                   throws ApplyException
Throws:
ApplyException

findPropInitTranslation

protected String findPropInitTranslation(String prefix,
                                         String type,
                                         Callable callable)
                                  throws ApplyException
Returns:
the property init string if the method starts with get/set/is
Throws:
ApplyException

queryTranslation

protected String queryTranslation(String prefix,
                                  String type,
                                  String[] suffixes,
                                  String errName)
                           throws ApplyException
Throws:
ApplyException

getTransProperty

protected String getTransProperty(String key)
                           throws ApplyException
Helper for derived classes.

Throws:
ApplyException

getJniSelf

protected String getJniSelf(Callable callable)
                     throws ApplyException
Helper for derived classes.

Throws:
ApplyException

getJniReturnError

protected String getJniReturnError(Callable callable)

getJniName

protected String getJniName(Callable callable)
                     throws ApplyException
Throws:
ApplyException

getJniOverload

protected String getJniOverload(Callable callable)
                         throws ApplyException
Throws:
ApplyException


Copyright © 2004 Moebius Solutions, Inc. All Rights Reserved.