|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.ist.fenixframework.dml.CodeGenerator
public abstract class CodeGenerator
Top-level class of all DML code generators.
Nested Class Summary | |
---|---|
protected static class |
CodeGenerator.PrimitiveToWrapperEntry
|
Field Summary | |
---|---|
static String |
ABSTRACT_BACKEND_ID_CLASS
|
static String |
BACKEND_PACKAGE
|
static String |
COLLECTION_CLASS_NAME_KEY
|
static String |
CURRENT_BACKEND_ID_CLASS
|
static String |
CURRENT_BACKEND_ID_FULL_CLASS
|
protected static CodeGenerator.PrimitiveToWrapperEntry[] |
primitiveToWrapperTypes
|
Constructor Summary | |
---|---|
CodeGenerator(CompilerArgs compArgs,
DomainModel domainModel)
|
Method Summary | |
---|---|
static String |
capitalize(String str)
|
protected void |
closeBlock(PrintWriter out)
|
protected void |
closeBlock(PrintWriter out,
boolean withNewLine)
|
protected void |
comment(PrintWriter out,
String msg)
|
protected void |
endMethodBody(PrintWriter out)
|
protected CodeGenerator.PrimitiveToWrapperEntry |
findWrapperEntry(String type)
|
protected void |
generateBackEndId()
Generate the class that identifies the backend to which this code generator creates the code. |
protected void |
generateBackEndIdClassBody(PrintWriter out)
|
protected void |
generateBaseClass(DomainClass domClass,
PrintWriter out)
|
protected void |
generateBaseClassBody(DomainClass domClass,
PrintWriter out)
|
protected void |
generateBaseClassConstructorsBody(DomainClass domClass,
PrintWriter out)
|
protected void |
generateClasses(Iterator<DomainClass> classesIter)
|
void |
generateCode()
Generate the backend-specific code for the domain model. |
protected void |
generateCurrentBackEndIdClass(String className,
PrintWriter out)
|
protected void |
generateDefaultRelationListeners(Role role,
PrintWriter out)
|
protected void |
generateFilePreamble(String subPackageName,
PrintWriter out)
|
protected void |
generateGetter(String visibility,
String getterName,
String slotName,
String typeName,
PrintWriter out)
|
protected void |
generateGetterBody(String slotName,
String typeName,
PrintWriter out)
|
protected void |
generateInitInstance(DomainClass domClass,
PrintWriter out)
The purpose of the initInstance method is to have the code needed to correctly initialize a domain object instance. |
protected void |
generateInitInstanceInitializer(DomainClass domClass,
PrintWriter out)
|
protected void |
generateInitInstanceMethod(DomainClass domClass,
PrintWriter out)
|
protected void |
generateInitInstanceMethodBody(DomainClass domClass,
PrintWriter out)
|
protected void |
generateInitInstanceNoArg(DomainClass domClass,
PrintWriter out)
|
protected void |
generateInitRoleSlot(Role role,
PrintWriter out)
|
protected void |
generateIteratorMethod(Role role,
PrintWriter out)
|
protected void |
generateIteratorMethod(Role role,
PrintWriter out,
String slotAccessExpression)
|
protected void |
generateOneClass(DomainClass domClass)
|
protected void |
generatePackageDecl(String subPackageName,
PrintWriter out)
|
protected void |
generatePublicClass(DomainClass domClass,
PrintWriter out)
|
protected void |
generatePublicClassConstructors(String className,
PrintWriter out)
|
protected void |
generatePublicFilePreamble(String subPackageName,
PrintWriter out)
|
protected void |
generateRelationAddMethodCall(Role role,
String otherArg,
String indexParam,
PrintWriter out)
|
protected void |
generateRelationGetter(String getterName,
Role role,
PrintWriter out)
|
protected void |
generateRelationGetter(String getterName,
Role role,
String paramListType,
PrintWriter out)
|
protected void |
generateRelationGetter(String getterName,
String valueToReturn,
Role role,
String typeName,
PrintWriter out)
|
protected void |
generateRelationRemoveMethodCall(Role role,
String otherArg,
PrintWriter out)
|
protected void |
generateRoleGetter(String slotName,
String typeName,
PrintWriter out)
Deprecated. Replaced by generateRoleSlotMethodsMultOneGetter(Role, PrintWriter) |
protected void |
generateRoleMethodGetInverseRole(Role role,
Role otherRole,
PrintWriter out)
|
protected void |
generateRoleSlot(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethods(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultOne(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultOneGetter(String slotName,
String typeName,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultOneHas(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultOneRemove(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultOneSetter(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultStar(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultStarCount(Role role,
PrintWriter out,
String methodModifiers,
String capitalizedSlotName,
String slotAccessExpression)
|
protected void |
generateRoleSlotMethodsMultStarGettersAndIterators(Role role,
PrintWriter out)
|
protected void |
generateRoleSlotMethodsMultStarHasAnyChild(Role role,
PrintWriter out,
String methodModifiers,
String capitalizedSlotName,
String slotAccessExpression)
|
protected void |
generateRoleSlotMethodsMultStarHasChild(Role role,
PrintWriter out,
String methodModifiers,
String capitalizedSlotName,
String slotAccessExpression,
String typeName,
String slotName,
boolean isIndexed,
String indexGetterCall)
|
protected void |
generateRoleSlotMethodsMultStarSet(Role role,
PrintWriter out,
String methodModifiers,
String capitalizedSlotName,
String slotAccessExpression,
String slotName,
String typeName)
|
protected void |
generateRoleSlots(Iterator roleSlotsIter,
PrintWriter out)
|
protected void |
generateRoleSlotsMethods(Iterator roleSlotsIter,
PrintWriter out)
|
protected void |
generateSetter(DomainClass domainClass,
String visibility,
String setterName,
Slot slot,
PrintWriter out)
|
protected void |
generateSetterBody(DomainClass domainClass,
String setterName,
Slot slot,
PrintWriter out)
|
protected void |
generateSlot(Slot slot,
PrintWriter out)
|
protected void |
generateSlotAccessors(DomainClass domainClass,
Slot slot,
PrintWriter out)
|
protected void |
generateSlotDeclaration(PrintWriter out,
String type,
String name)
|
protected void |
generateSlotGetter(String slotName,
String typeName,
PrintWriter out)
|
protected void |
generateSlots(Iterator slotsIter,
PrintWriter out)
|
protected void |
generateSlotsAccessors(DomainClass domainClass,
PrintWriter out)
|
protected void |
generateSlotSetter(DomainClass domainClass,
Slot slot,
PrintWriter out)
|
protected void |
generateStaticRelationSlots(Role role,
PrintWriter out)
|
protected void |
generateStaticRoleSlots(Role role,
PrintWriter out)
|
protected void |
generateStaticRoleSlotsMultOne(Role role,
Role otherRole,
PrintWriter out)
|
protected void |
generateStaticRoleSlotsMultStar(Role role,
Role otherRole,
PrintWriter out)
|
protected void |
generateStaticSlots(DomainClass domClass,
PrintWriter out)
|
protected String |
getAdderMethodName(Role role)
|
protected abstract Class<? extends ContextFactory> |
getAtomicContextFactoryClass()
Get the class that implements the ContextFactory for AtomicContexts |
protected abstract String |
getBackEndName()
Get the name of the backend for which this class generates code. |
protected File |
getBaseDirectoryFor(String packageName)
|
protected String |
getCollectionTypeFor(Role role)
|
protected String |
getConcreteSetTypeDeclarationFor(Role role)
|
protected String |
getDefaultCollectionFor(String type)
|
protected abstract String |
getDefaultConfigClassName()
Get the name of the default configuration class of the backend for which this class generates code. |
protected File |
getDirectoryFor(String packageName)
|
protected String |
getDirectRelationType()
|
protected String |
getDomainClassRoot()
|
DomainModel |
getDomainModel()
|
protected String |
getEntityFullName(DomainEntity domEntity)
|
protected String |
getMethodModifiers()
|
protected String |
getNewRoleStarSlotExpression(Role role)
|
String |
getPackageName()
|
protected String |
getPackagePrefix(String packageName)
|
protected String |
getReferenceType(String type)
|
protected String |
getRelationAwareBaseTypeFor(Role role)
|
protected String |
getRelationAwareTypeFor(Role role)
|
protected String |
getRelationSlotNameFor(Role role)
|
protected String |
getRemoverMethodName(Role role)
|
protected String |
getRoleArgs(Role role)
|
protected String |
getRoleBaseType(Role role)
|
protected String |
getRoleHandlerName(Role role,
boolean otherClass)
|
protected String |
getRoleManyBaseType()
|
protected String |
getRoleOneBaseType()
|
protected String |
getRoleType(Role role)
|
protected String |
getSetTypeDeclarationFor(Role role)
|
protected String |
getSlotExpression(String slotName)
|
protected String |
getTypeFullName(DomainEntity domEntity)
|
protected String |
makeArg(String type,
String arg)
|
static String |
makeGenericType(String baseType,
String... argTypes)
|
protected void |
newBlock(PrintWriter out)
|
protected void |
newline(PrintWriter out)
|
protected void |
onNewline(PrintWriter out)
|
protected void |
print(PrintWriter out,
String text)
|
protected void |
printFinalMethod(PrintWriter out,
String mods,
String type,
String name,
String... args)
|
protected void |
println(PrintWriter out,
String text)
|
protected void |
printMethod(PrintWriter out,
String mods,
String type,
String name,
String... args)
|
protected void |
printWords(PrintWriter out,
String... words)
|
void |
setCollectionToUse(String newCollectionName)
|
protected void |
startMethodBody(PrintWriter out)
|
protected void |
writeToFile(File file,
pt.ist.fenixframework.dml.CodeGenerator.WriteProcedure proc)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String BACKEND_PACKAGE
public static final String ABSTRACT_BACKEND_ID_CLASS
public static final String CURRENT_BACKEND_ID_CLASS
public static final String CURRENT_BACKEND_ID_FULL_CLASS
public static final String COLLECTION_CLASS_NAME_KEY
protected static CodeGenerator.PrimitiveToWrapperEntry[] primitiveToWrapperTypes
Constructor Detail |
---|
public CodeGenerator(CompilerArgs compArgs, DomainModel domainModel)
Method Detail |
---|
public void setCollectionToUse(String newCollectionName)
public DomainModel getDomainModel()
public String getPackageName()
protected File getDirectoryFor(String packageName)
protected File getBaseDirectoryFor(String packageName)
protected String getPackagePrefix(String packageName)
protected String getEntityFullName(DomainEntity domEntity)
protected String getTypeFullName(DomainEntity domEntity)
protected String getDomainClassRoot()
public void generateCode()
protected void generateBackEndId()
CurrentBackEndId
and extend the BackEndId
class.
protected void writeToFile(File file, pt.ist.fenixframework.dml.CodeGenerator.WriteProcedure proc)
protected void generateClasses(Iterator<DomainClass> classesIter)
protected void generateOneClass(DomainClass domClass)
protected void generateFilePreamble(String subPackageName, PrintWriter out)
protected void generatePublicFilePreamble(String subPackageName, PrintWriter out)
protected void generatePackageDecl(String subPackageName, PrintWriter out)
protected void generatePublicClass(DomainClass domClass, PrintWriter out)
protected void generatePublicClassConstructors(String className, PrintWriter out)
protected void generateCurrentBackEndIdClass(String className, PrintWriter out)
protected void generateBackEndIdClassBody(PrintWriter out)
protected void generateBaseClass(DomainClass domClass, PrintWriter out)
protected void generateBaseClassBody(DomainClass domClass, PrintWriter out)
protected void generateBaseClassConstructorsBody(DomainClass domClass, PrintWriter out)
protected void generateSlots(Iterator slotsIter, PrintWriter out)
protected void generateSlot(Slot slot, PrintWriter out)
protected void generateSlotDeclaration(PrintWriter out, String type, String name)
protected CodeGenerator.PrimitiveToWrapperEntry findWrapperEntry(String type)
protected String getReferenceType(String type)
protected void generateStaticSlots(DomainClass domClass, PrintWriter out)
protected void generateStaticRoleSlots(Role role, PrintWriter out)
protected void generateStaticRoleSlotsMultOne(Role role, Role otherRole, PrintWriter out)
protected void generateStaticRoleSlotsMultStar(Role role, Role otherRole, PrintWriter out)
protected void generateRoleMethodGetInverseRole(Role role, Role otherRole, PrintWriter out)
protected String getRoleHandlerName(Role role, boolean otherClass)
protected String getDirectRelationType()
protected void generateStaticRelationSlots(Role role, PrintWriter out)
protected void generateDefaultRelationListeners(Role role, PrintWriter out)
protected String getRoleType(Role role)
protected String getRoleBaseType(Role role)
protected String getRoleArgs(Role role)
protected String getRoleOneBaseType()
protected String getRoleManyBaseType()
protected void generateRoleSlots(Iterator roleSlotsIter, PrintWriter out)
protected String getCollectionTypeFor(Role role)
protected String getRelationAwareTypeFor(Role role)
protected String getRelationAwareBaseTypeFor(Role role)
protected void generateRoleSlot(Role role, PrintWriter out)
protected String getDefaultCollectionFor(String type)
protected String getNewRoleStarSlotExpression(Role role)
protected String getRelationSlotNameFor(Role role)
protected void generateInitInstance(DomainClass domClass, PrintWriter out)
In the first case the parameter 'allocateOnly' is false. Tipically, we need to fully initialize the slots, e.g. create new lists, etc. In the second case, the instance's attributes will be populated, so we should not create them anew.
This method is responsible for: generating the initInstance(boolean)
method;
generate the call to this method as an instance initializer with the parameter
allocateInstance = false
.
protected void generateInitInstanceNoArg(DomainClass domClass, PrintWriter out)
protected void generateInitInstanceMethod(DomainClass domClass, PrintWriter out)
protected void generateInitInstanceMethodBody(DomainClass domClass, PrintWriter out)
protected void generateInitInstanceInitializer(DomainClass domClass, PrintWriter out)
protected void generateInitRoleSlot(Role role, PrintWriter out)
protected void generateSlotsAccessors(DomainClass domainClass, PrintWriter out)
protected void generateSlotAccessors(DomainClass domainClass, Slot slot, PrintWriter out)
protected String getSlotExpression(String slotName)
protected void generateSlotGetter(String slotName, String typeName, PrintWriter out)
protected void generateGetter(String visibility, String getterName, String slotName, String typeName, PrintWriter out)
protected void generateGetterBody(String slotName, String typeName, PrintWriter out)
protected void generateSlotSetter(DomainClass domainClass, Slot slot, PrintWriter out)
protected void generateSetter(DomainClass domainClass, String visibility, String setterName, Slot slot, PrintWriter out)
@Deprecated protected void generateRoleGetter(String slotName, String typeName, PrintWriter out)
generateRoleSlotMethodsMultOneGetter(Role, PrintWriter)
protected void generateSetterBody(DomainClass domainClass, String setterName, Slot slot, PrintWriter out)
protected void generateRoleSlotsMethods(Iterator roleSlotsIter, PrintWriter out)
protected void generateRoleSlotMethods(Role role, PrintWriter out)
protected String getSetTypeDeclarationFor(Role role)
protected String getConcreteSetTypeDeclarationFor(Role role)
protected void generateRoleSlotMethodsMultOne(Role role, PrintWriter out)
protected void generateRoleSlotMethodsMultOneGetter(String slotName, String typeName, PrintWriter out)
protected void generateRoleSlotMethodsMultOneSetter(Role role, PrintWriter out)
protected void generateRoleSlotMethodsMultOneHas(Role role, PrintWriter out)
protected void generateRoleSlotMethodsMultOneRemove(Role role, PrintWriter out)
protected void generateRelationAddMethodCall(Role role, String otherArg, String indexParam, PrintWriter out)
protected void generateRelationRemoveMethodCall(Role role, String otherArg, PrintWriter out)
protected String getAdderMethodName(Role role)
protected String getRemoverMethodName(Role role)
protected String getMethodModifiers()
protected void generateRoleSlotMethodsMultStar(Role role, PrintWriter out)
protected void generateRoleSlotMethodsMultStarGettersAndIterators(Role role, PrintWriter out)
protected void generateIteratorMethod(Role role, PrintWriter out)
protected void generateIteratorMethod(Role role, PrintWriter out, String slotAccessExpression)
protected void generateRelationGetter(String getterName, Role role, PrintWriter out)
protected void generateRelationGetter(String getterName, Role role, String paramListType, PrintWriter out)
protected void generateRelationGetter(String getterName, String valueToReturn, Role role, String typeName, PrintWriter out)
protected void generateRoleSlotMethodsMultStarCount(Role role, PrintWriter out, String methodModifiers, String capitalizedSlotName, String slotAccessExpression)
protected void generateRoleSlotMethodsMultStarHasAnyChild(Role role, PrintWriter out, String methodModifiers, String capitalizedSlotName, String slotAccessExpression)
protected void generateRoleSlotMethodsMultStarHasChild(Role role, PrintWriter out, String methodModifiers, String capitalizedSlotName, String slotAccessExpression, String typeName, String slotName, boolean isIndexed, String indexGetterCall)
protected void generateRoleSlotMethodsMultStarSet(Role role, PrintWriter out, String methodModifiers, String capitalizedSlotName, String slotAccessExpression, String slotName, String typeName)
public static String makeGenericType(String baseType, String... argTypes)
protected void printMethod(PrintWriter out, String mods, String type, String name, String... args)
protected void printFinalMethod(PrintWriter out, String mods, String type, String name, String... args)
protected void startMethodBody(PrintWriter out)
protected void endMethodBody(PrintWriter out)
protected String makeArg(String type, String arg)
protected void printWords(PrintWriter out, String... words)
protected void print(PrintWriter out, String text)
protected void println(PrintWriter out, String text)
protected void newBlock(PrintWriter out)
protected void closeBlock(PrintWriter out)
protected void closeBlock(PrintWriter out, boolean withNewLine)
protected void comment(PrintWriter out, String msg)
protected void onNewline(PrintWriter out)
public static String capitalize(String str)
protected void newline(PrintWriter out)
protected abstract String getBackEndName()
generateBackEndId()
.
protected abstract String getDefaultConfigClassName()
generateBackEndId()
.
protected abstract Class<? extends ContextFactory> getAtomicContextFactoryClass()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |