Download Sources

com.liguorien.flex.generator.handlers
Class Dom4jBuilderHandler

java.lang.Object
  extended by com.liguorien.flex.generator.handlers.AbstractGeneratorHandler<Dom4jBuilderHandler>
      extended by com.liguorien.flex.generator.handlers.Dom4jBuilderHandler
All Implemented Interfaces:
FlexGeneratorHandler

public class Dom4jBuilderHandler
extends AbstractGeneratorHandler<Dom4jBuilderHandler>

Generates code which will read and create dom4j element from Java entities.

Version:
0.2
Author:
Nicolas Désy

Constructor Summary
Dom4jBuilderHandler()
          Create a new instance of Dom4jBuilderHandler
Dom4jBuilderHandler(java.lang.String builderSuffix)
          Create a new instance of Dom4jBuilderHandler
 
Method Summary
protected  void appendClassSuffix(java.lang.StringBuilder buffer)
          Appends a suffix to name of the generated class.
protected  void appendExtension(java.lang.StringBuilder buffer)
          Appends the extension of the generated file.
 java.lang.String getBuilderSuffix()
          Return the suffix to be appended to the name of the generated class.
 java.lang.StringBuilder getClassName(java.lang.Class clazz)
          Get the name of the generated class.
 ClassType getClassType()
          Get the ClassType for this handler.
 ClassWriter getClassWriter()
          Get the ClassWriter of this handler.
 java.io.File getOutputDirectory()
          Return the output directory of this handler
protected  java.lang.String getRelativeFilePath(java.lang.Class clazz)
          Returns a file path relative to the output directory.
 void handleClassBegin(java.lang.Class<?> clazz)
          Invoked when the generator begin a new class.
 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.
 
Methods inherited from class com.liguorien.flex.generator.handlers.AbstractGeneratorHandler
addContextMethodWriter, addImport, addMethodWriter, addPropertyWriter, appendClassPrefix, clearImports, getAttributes, getContextMethodWriters, getCurrentClass, getElements, getGenerator, getImports, getMethodWriters, getPropertyWriters, getWriter, handleClassBegin, handleClassEnd, handleClassEnd, handleProperty, initWriter, resetImports, setGenerator, setWriter, writeDocumentation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dom4jBuilderHandler

public Dom4jBuilderHandler()
Create a new instance of Dom4jBuilderHandler


Dom4jBuilderHandler

public Dom4jBuilderHandler(java.lang.String builderSuffix)
Create a new instance of Dom4jBuilderHandler

Parameters:
builderSuffix - The suffix to be appended to the name of the generated classes.
Method Detail

getClassType

public ClassType getClassType()
Description copied from class: AbstractGeneratorHandler

Get the ClassType for this handler.

Specified by:
getClassType in interface FlexGeneratorHandler
Specified by:
getClassType in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Returns:
ClassType.SERVER_BUILDERS
See Also:
ClassType

getBuilderSuffix

public java.lang.String getBuilderSuffix()
Return the suffix to be appended to the name of the generated class.


getOutputDirectory

public java.io.File getOutputDirectory()
Description copied from class: AbstractGeneratorHandler

Return the output directory of this handler

Specified by:
getOutputDirectory in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Returns:
A File object which represent the root of output directory

handleClassBegin

public void handleClassBegin(java.lang.Class<?> clazz)
Description copied from interface: FlexGeneratorHandler
Invoked when the generator begin a new class.

Parameters:
clazz - The class which the generator is parsing.

appendClassSuffix

protected void appendClassSuffix(java.lang.StringBuilder buffer)
Description copied from class: AbstractGeneratorHandler

Appends a suffix to name of the generated class. The default behavior is to append (if not null) value of FlexGenerator.getClassSuffix().

Overrides:
appendClassSuffix in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Parameters:
buffer - The buffer which the suffix must be appended.

appendExtension

protected void appendExtension(java.lang.StringBuilder buffer)
Description copied from class: AbstractGeneratorHandler

Appends the extension of the generated file.

Specified by:
appendExtension in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Parameters:
buffer - The buffer which the extension must be appended.

getClassWriter

public ClassWriter getClassWriter()
Description copied from class: AbstractGeneratorHandler

Get the ClassWriter of this handler.

Specified by:
getClassWriter in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Returns:
The ClassWriter of this handler.
See Also:
ClassWriter

getClassName

public java.lang.StringBuilder getClassName(java.lang.Class clazz)
Description copied from class: AbstractGeneratorHandler

Get the name of the generated class. It's used by the MethodWriter who need a reference to the class.

Overrides:
getClassName in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Parameters:
clazz - An entity class
Returns:
A StringBuilder instance.

getRelativeFilePath

protected java.lang.String getRelativeFilePath(java.lang.Class clazz)
Description copied from class: AbstractGeneratorHandler

Returns a file path relative to the output directory.

Overrides:
getRelativeFilePath in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Parameters:
clazz - An entity class
Returns:
A filepath relative to the output directory.

writeClassName

public void writeClassName(java.io.Writer w,
                           java.lang.Class clazz,
                           java.lang.String classPrefix,
                           java.lang.String classSuffix)
                    throws java.io.IOException
Description copied from class: AbstractGeneratorHandler

Writes the name of the generated class. It's used by the MethodWriter who need a reference to the class.

Overrides:
writeClassName in class AbstractGeneratorHandler<Dom4jBuilderHandler>
Parameters:
w - The writer used to write the classname.
clazz - An entity class
classPrefix - The prefix of the classname (can be null)
classSuffix - The suffix of the classname (can be null)
Throws:
java.io.IOException - If an IO error occurs.

FlexGenerator

Copyright 2006 Nicolas Désy. All rights reserved.