|
Download Sources | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.liguorien.flex.generator.handlers.AbstractGeneratorHandler<T>
public abstract class AbstractGeneratorHandler<T extends FlexGeneratorHandler>
Basic implementation of FlexGeneratorHandler. The basic use of
this class is to extends it to create a new type of generated code.
The behavior of this handler can easily be customized. It provides a List
of MethodWriter, whichs contains a writer for each generated methods.
| Constructor Summary | |
|---|---|
AbstractGeneratorHandler()
Creates a new instance of AbstractGeneratorHandler |
|
| Method Summary | |
|---|---|
void |
addContextMethodWriter(MethodWriter<T> writer)
Add a new MethodWriter for the current class only. |
void |
addImport(java.lang.String str)
Add a import statement for the current class. |
void |
addMethodWriter(MethodWriter<T> writer)
Add a MethodWriter to this handler. |
void |
addPropertyWriter(PropertyWriter<T> writer)
Add a PropertyWriter to this handler. |
protected void |
appendClassPrefix(java.lang.StringBuilder buffer)
Appends a prefix to name of the generated class. |
protected void |
appendClassSuffix(java.lang.StringBuilder buffer)
Appends a suffix to name of the generated class. |
protected abstract void |
appendExtension(java.lang.StringBuilder buffer)
Appends the extension of the generated file. |
void |
clearImports()
Clear the import statements |
java.util.List<java.beans.PropertyDescriptor> |
getAttributes()
Returns a List of PropertyDescriptor which will be XML attributes. |
java.lang.StringBuilder |
getClassName(java.lang.Class clazz)
Get the name of the generated class. |
abstract ClassType |
getClassType()
Get the ClassType for this handler. |
abstract ClassWriter |
getClassWriter()
Get the ClassWriter of this handler. |
java.util.Set<MethodWriter<T>> |
getContextMethodWriters()
Returns the method writers which are been added for the current class |
java.lang.Class<?> |
getCurrentClass()
Return the current Entity class. |
java.util.List<java.beans.PropertyDescriptor> |
getElements()
Returns a List of PropertyDescriptor which will be XML elements. |
FlexGenerator |
getGenerator()
Getter for property generator. |
java.util.Set<java.lang.String> |
getImports()
Returns a Set which contains the import statement for the current class |
java.util.List<MethodWriter<T>> |
getMethodWriters()
Returns the method writers of this handler. |
abstract java.io.File |
getOutputDirectory()
Return the output directory of this handler |
java.util.List<PropertyWriter<T>> |
getPropertyWriters()
Returns the default property writers of this handler. |
protected java.lang.String |
getRelativeFilePath(java.lang.Class clazz)
Returns a file path relative to the output directory. |
java.io.Writer |
getWriter()
Getter for property writer. |
protected void |
handleClassBegin(java.lang.Class<?> clazz,
ClassWriter cw,
java.lang.String className,
java.lang.String subClass,
java.util.Set<java.lang.String> interfaces)
Basic implementation of FlexGeneratorHandler.handleClassBegin(java.lang.Class>) but with a different
signature. |
void |
handleClassEnd(java.lang.Class<?> clazz)
Basic implementation of FlexGeneratorHandler.handleClassEnd(java.lang.Class>) |
protected void |
handleClassEnd(java.lang.Class<?> clazz,
ClassWriter cw)
This is where the class is actually generated. |
void |
handleProperty(java.beans.PropertyDescriptor property)
Basic implementation of FlexGeneratorHandler.handleProperty(java.beans.PropertyDescriptor) |
protected void |
initWriter(java.lang.Class<?> clazz)
Init writer used to output the generated classes. |
void |
resetImports()
Clear and reset the import statements. |
void |
setGenerator(FlexGenerator generator)
Setter for property generator. |
void |
setWriter(java.io.Writer writer)
Setter for property writer. |
void |
writeClassName(java.io.Writer w,
java.lang.Class clazz,
java.lang.String classPrefix,
java.lang.String classSuffix)
Writes the name of the generated class. |
protected void |
writeDocumentation(java.io.Writer w)
Write the document for the current generated class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.liguorien.flex.generator.handlers.FlexGeneratorHandler |
|---|
handleClassBegin |
| Constructor Detail |
|---|
public AbstractGeneratorHandler()
| Method Detail |
|---|
public void addImport(java.lang.String str)
str - The fully qualified name of the classpublic java.util.Set<java.lang.String> getImports()
Returns a Set which contains the import statement for the current class
public void clearImports()
Clear the import statements
public void resetImports()
Clear and reset the import statements. Subclass can override to add default import. It will called between each class.
public abstract ClassWriter getClassWriter()
Get the ClassWriter of this handler.
ClassWriter of this handler.ClassWriterpublic abstract ClassType getClassType()
Get the ClassType for this handler.
getClassType in interface FlexGeneratorHandlerClassType of this handler.ClassType
protected void handleClassBegin(java.lang.Class<?> clazz,
ClassWriter cw,
java.lang.String className,
java.lang.String subClass,
java.util.Set<java.lang.String> interfaces)
Basic implementation of
FlexGeneratorHandler.handleClassBegin(java.lang.Class>) but with a different
signature. Should be called by subclass in their own implementation of
FlexGeneratorHandler.handleClassBegin(java.lang.Class>).
clazz - The current classcw - The current ClassWriterclassName - The name of the generated classsubClass - The subclass of the generated (can be null)interfaces - A Set of interface which are implemented
by the generated classFlexGeneratorHandler.handleClassBegin(java.lang.Class>)public void handleProperty(java.beans.PropertyDescriptor property)
Basic implementation of
FlexGeneratorHandler.handleProperty(java.beans.PropertyDescriptor)
This implementation check if the property will an attribute or an
element in the generated XML. The property descripator can later be
accessed by getAttributes() and getElements().
handleProperty in interface FlexGeneratorHandlerproperty - The property descriptor to handleprotected void writeDocumentation(java.io.Writer w)
Write the document for the current generated class.
The default behavior is to invoke
FlexGenerator.writeDocumentation(java.io.Writer, java.lang.Class>, int, java.lang.Object...).
Can be overrided to change the behavior.
w - The writer used to write the documentation.public void handleClassEnd(java.lang.Class<?> clazz)
Basic implementation of
FlexGeneratorHandler.handleClassEnd(java.lang.Class>)
The default behavior is to invoke
handleClassEnd(Class clazz, ClassWriter cw) using
getClassWriter() as the ClassWriter.
handleClassEnd in interface FlexGeneratorHandlerclazz - The current class
protected void handleClassEnd(java.lang.Class<?> clazz,
ClassWriter cw)
This is where the class is actually generated.
clazz - The current classcw - The ClassWriter used to generated the class.public void addMethodWriter(MethodWriter<T> writer)
Add a MethodWriter to this handler.
writer - A MethodWriter instance.public void addContextMethodWriter(MethodWriter<T> writer)
Add a new MethodWriter for the current class only.
writer - A MethodWriter instance.public void addPropertyWriter(PropertyWriter<T> writer)
Add a PropertyWriter to this handler.
writer - A PropertyWriter instance.public java.util.List<MethodWriter<T>> getMethodWriters()
Returns the method writers of this handler.
PropertyWriter instances.public java.util.Set<MethodWriter<T>> getContextMethodWriters()
Returns the method writers which are been added for the current class
MethodWriter instances.public java.util.List<PropertyWriter<T>> getPropertyWriters()
Returns the default property writers of this handler.
PropertyWriter instances.public java.util.List<java.beans.PropertyDescriptor> getAttributes()
Returns a List of PropertyDescriptor which will be XML attributes.
public java.util.List<java.beans.PropertyDescriptor> getElements()
Returns a List of PropertyDescriptor which will be XML elements.
public abstract java.io.File getOutputDirectory()
Return the output directory of this handler
protected void appendClassPrefix(java.lang.StringBuilder buffer)
Appends a prefix to name of the generated class. The default behavior
is to append (if not null) value of FlexGenerator.getClassPrefix().
buffer - The buffer which the prefix must be appended.protected void appendClassSuffix(java.lang.StringBuilder buffer)
Appends a suffix to name of the generated class. The default behavior
is to append (if not null) value of FlexGenerator.getClassSuffix().
buffer - The buffer which the suffix must be appended.protected abstract void appendExtension(java.lang.StringBuilder buffer)
Appends the extension of the generated file.
buffer - The buffer which the extension must be appended.public java.lang.Class<?> getCurrentClass()
Return the current Entity class.
getCurrentClass in interface FlexGeneratorHandler
public void writeClassName(java.io.Writer w,
java.lang.Class clazz,
java.lang.String classPrefix,
java.lang.String classSuffix)
throws java.io.IOException
Writes the name of the generated class. It's used by the
MethodWriter who need a reference to the class.
w - The writer used to write the classname.clazz - An entity classclassPrefix - The prefix of the classname (can be null)classSuffix - The suffix of the classname (can be null)
java.io.IOException - If an IO error occurs.public java.lang.StringBuilder getClassName(java.lang.Class clazz)
Get the name of the generated class. It's used by the
MethodWriter who need a reference to the class.
clazz - An entity class
protected java.lang.String getRelativeFilePath(java.lang.Class clazz)
Returns a file path relative to the output directory.
clazz - An entity class
protected void initWriter(java.lang.Class<?> clazz)
Init writer used to output the generated classes.
clazz - The current entity class.public java.io.Writer getWriter()
public void setWriter(java.io.Writer writer)
writer - New value of property writer.public FlexGenerator getGenerator()
public void setGenerator(FlexGenerator generator)
setGenerator in interface FlexGeneratorHandlergenerator - New value of property generator.
|
FlexGenerator | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||