net.sourceforge.fluxion.datapublisher.beangen
Class BeanConfig

java.lang.Object
  extended by net.sourceforge.fluxion.datapublisher.beangen.BeanConfig

public class BeanConfig
extends java.lang.Object

A convenience class to make autogeneration of the database bean model easier. Rather than generating all beans by writing all the code explicitly by hand, one can specifiy various properties on this class and generate the beans using the BeanWriter class, passing a set of BeanConfig objects. Some code will still need to be hand specified, as the resulting beans must contain database query logic. The BeanConfig layer should considerably simplify the process, though.

Version:
0.2
Author:
Tony Burdett
See Also:
BeanConfig

Constructor Summary
BeanConfig()
           
 
Method Summary
 void addGetter(java.lang.String methodName, java.lang.String returnType)
          Method name should exclude the "get" part.
 void addGetterAndSetter(java.lang.String typeName)
          Method name should exclude the get/set parts.
 void addMethod(java.lang.String methodName, java.lang.String returnType)
           
 void addMethodAnnotation(java.lang.String methodName, java.lang.String annotationString)
          Add an annotation to a given method.
 void addSetter(java.lang.String methodName)
          Method name should exclude the set part.
 java.lang.String getClassName()
           
 java.lang.Class getEntityAnn()
           
 java.lang.Class getMetaAnn()
           
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMethodAnnotations()
           
 java.util.Map<java.lang.String,java.lang.String> getMethods()
           
 java.lang.String getSchemaNameAnn()
           
 java.lang.String getTableNameAnn()
           
 void removeMethodAnnotation(java.lang.String methodName, java.lang.String annotationString)
          Remove an annotation from a given method.
 void setClassName(java.lang.String className)
          Set the short bean name.
 void setEntityAnn(java.lang.Class entityAnn)
           
 void setMetaAnn(java.lang.Class value)
          Set the name of the structure being retrieved.
 void setMethodAnnotations(java.util.Map<java.lang.String,java.util.List<java.lang.String>> methodAnns)
          Add an annotation to a given method.
 void setMethods(java.util.Map<java.lang.String,java.lang.String> methodNames)
          Set the map of methods (which is actually a map of String methodName -> String returnType) for this bean.
 void setSchemaNameAnn(java.lang.String schemaNameAnn)
           
 void setTableNameAnn(java.lang.String tableNameAnn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanConfig

public BeanConfig()
Method Detail

getEntityAnn

public java.lang.Class getEntityAnn()

setEntityAnn

public void setEntityAnn(java.lang.Class entityAnn)

getSchemaNameAnn

public java.lang.String getSchemaNameAnn()

setSchemaNameAnn

public void setSchemaNameAnn(java.lang.String schemaNameAnn)

getTableNameAnn

public java.lang.String getTableNameAnn()

setTableNameAnn

public void setTableNameAnn(java.lang.String tableNameAnn)

getMetaAnn

public java.lang.Class getMetaAnn()

setMetaAnn

public void setMetaAnn(java.lang.Class value)
Set the name of the structure being retrieved. This will be used to determine the appropriate bean metaAnn. So, for example in an SQL database, if creating a bean that maps to an OWL class and represents a table, the MetaAnn class will be net.sourceforge.fluxion.datapublisher.sql.meta.TableAnn (generated by the owl2constants-plugin).

Parameters:
value - the annotation class to use to annotate this bean

getClassName

public java.lang.String getClassName()

setClassName

public void setClassName(java.lang.String className)
Set the short bean name. The BeanConfig object handles capitalisation of the first character and the addition of the "Bean" to the end of the class name, so the shortened name of the bean (e.g. the table name itself) should be supplied.

Parameters:
className - the name of this bean class

getMethods

public java.util.Map<java.lang.String,java.lang.String> getMethods()

setMethods

public void setMethods(java.util.Map<java.lang.String,java.lang.String> methodNames)
Set the map of methods (which is actually a map of String methodName -> String returnType) for this bean. The BeanWriter handles the correct annotation of getters and setters, but both should be set if required. Setter methods should obviously have a void return type.

Parameters:
methodNames - the set of all methods to use

addMethod

public void addMethod(java.lang.String methodName,
                      java.lang.String returnType)

addGetter

public void addGetter(java.lang.String methodName,
                      java.lang.String returnType)
Method name should exclude the "get" part.

Parameters:
methodName - the name of the method to create
returnType - the return type for the method

addSetter

public void addSetter(java.lang.String methodName)
Method name should exclude the set part. The parameter needed for a set method is inferred from the paired get method when the bean is generated, so care should be taken to ensure that get/set method pairings exist for every field.

Parameters:
methodName - the name of the method to create

addGetterAndSetter

public void addGetterAndSetter(java.lang.String typeName)
Method name should exclude the get/set parts. The method name is assumed to be the same as the return type - so eg return type String produce getString and setString methods. If this is not true, use addGetter() or addSetter() instead

Parameters:
typeName - the "Type" to create getter and setter methods for - roughly corresponds to the name of the field that will be generated

addMethodAnnotation

public void addMethodAnnotation(java.lang.String methodName,
                                java.lang.String annotationString)
Add an annotation to a given method. The methodName parameter should match the name of the method on the bean being configured. The annotationString should be the string that will be attached to this method to describe the annotations - for example, "@UniqueIdAnn" to tag a method as being a key for this bean.

Parameters:
methodName - the name of the method
annotationString - the string describing the annotation to set

removeMethodAnnotation

public void removeMethodAnnotation(java.lang.String methodName,
                                   java.lang.String annotationString)
Remove an annotation from a given method. The methodName parameter should match the name of the method on the bean being configured. The annotationString should be the string that will be attached to this method to describe the annotations - for example, "@UniqueIdAnn" to tag a method as being a key for this bean.

Parameters:
methodName - the name of the method
annotationString - the string describing the annotation to set

setMethodAnnotations

public void setMethodAnnotations(java.util.Map<java.lang.String,java.util.List<java.lang.String>> methodAnns)
Add an annotation to a given method. The methodName parameter should match the name of the method on the bean being configured. The annotationString should be the string that will be attached to this method to describe the annotations - for example, "@UniqueIdAnn" to tag a method as being a key for this bean.

Parameters:
methodAnns - the map of annotations to method for the bean being configured

getMethodAnnotations

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMethodAnnotations()
Returns:
a map of method annotations indexed by method name


Copyright © 2010. All Rights Reserved.