Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## xcodegen.generator
Class AbstractCodeGenerator

    java.lang.Object
      |
      +--xcodegen.generator.AbstractCodeGenerator

All Implemented Interfaces:
  CodeGenerator

Direct Known Subclasses:
  AbstractBeanCodeGenerator, AbstractSQLCodeGenerator

public abstract class AbstractCodeGenerator
extends java.lang.Object
implements CodeGenerator

Abstract implementation of `CodeGenerator`

Version:
  $Revision: 1.3 $
Author:
  Herve Tchepannou

Field Summary

Fields inherited from interface xcodegen.generator.CodeGenerator
`CONFIG_CLASS_OUTPUT_DIR, CONFIG_CLASS_PREFIX, CONFIG_CLASS_SUFFIX, CONFIG_DATABASE, CONFIG_DATABASE_OUTPUT_DIR, CONFIG_DATABASE_OUTPUT_FILE, CONFIG_DATABASE_STRING_SIZE, CONFIG_LANGUAGE, CONFIG_PACKAGE_SUFFIX, VERSION`

Constructor Summary
`AbstractCodeGenerator(java.lang.String name)` Constructor

Method Summary
`protected abstract void` | `generate(XClass clazz, org.apache.velocity.VelocityContext context, org.apache.velocity.Template template)` Generate the code of a class
`void` | `generate(XPackage[] packages)` Generate to code of a set of packages
`protected abstract void` | `generate(XPackage pkg, org.apache.velocity.VelocityContext context, org.apache.velocity.Template template)` Generate the code of a package
`java.lang.String` | `getConfigProperty(java.lang.String name, java.lang.String defaultValue)` Return a configuration property of the code generator
`org.apache.log4j.Logger` | `getLogger()` Return the Logger
`java.lang.String` | `getName()` Return the name of the CodeGenerator
`org.apache.velocity.VelocityContext` | `getVelocityContext()` Return the VelocityContext used for generating the code
`org.apache.velocity.Template` | `getVelocityTemplate()` Return the Velocity template
`abstract java.lang.String` | `getVelocityTemplatePath()` Return the path the the template
`void` | `init(java.util.Properties config)` Initialize the code generator
`protected java.util.Properties` | `loadResourceAsProperties(java.lang.String path)` Create a java.util.Properties from a resource stream

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractCodeGenerator

    public AbstractCodeGenerator(java.lang.String name)

  Constructor

Method Detail

### getLogger

    public org.apache.log4j.Logger getLogger()

  Return the Logger

  Returns:
    logger of the code generator

### getName

    public java.lang.String getName()

  Return the name of the CodeGenerator

  Returns:
    Name of the code generator

### getVelocityContext

    public org.apache.velocity.VelocityContext getVelocityContext()

  Return the VelocityContext used for generating the code

  Returns:
    VelocityContext

### getVelocityTemplatePath

    public abstract java.lang.String getVelocityTemplatePath()

  Return the path the the template

  Returns:
    path of the template

### getVelocityTemplate

    public org.apache.velocity.Template getVelocityTemplate()
                                                     throws XCodeGenException

  Return the Velocity template

  Returns:
    Velocity template
  Throws:
    `XCodeGenException` - if the template not found

### generate

    protected abstract void generate(XPackage pkg,
                                     org.apache.velocity.VelocityContext context,
                                     org.apache.velocity.Template template)
                              throws XCodeGenException,
                                     java.io.IOException

  Generate the code of a package

  Parameters:
    `pkg` - Package to generate
    `context` - Velocity context
    `template` - Template used for generating the code
  Throws:
    `XCodeGenException` - If any error occurs during the code generation
    `java.io.IOException`

### generate

    protected abstract void generate(XClass clazz,
                                     org.apache.velocity.VelocityContext context,
                                     org.apache.velocity.Template template)
                              throws XCodeGenException,
                                     java.io.IOException

  Generate the code of a class

  Parameters:
    `clazz` - Class to generate
    `context` - Velocity context
    `template` - Template used for generating the code
  Throws:
    `XCodeGenException` - If any error occurs during the code generation
    `java.io.IOException`

### loadResourceAsProperties

    protected java.util.Properties loadResourceAsProperties(java.lang.String path)
                                                     throws XCodeGenException

  Create a java.util.Properties from a resource stream

  Parameters:
    `path` - path of the resource
  Returns:
    java.util.Properties created
  Throws:
    `XCodeGenException` - if the resource not loaded

### generate

    public void generate(XPackage[] packages)
                  throws XCodeGenException,
                         java.io.IOException

  Description copied from interface: `CodeGenerator`
  Generate to code of a set of packages

  Specified by:
    `generate` in interface `CodeGenerator`
  Throws:
    `java.io.IOException` - if any IO error
    `XCodeGenException`

### getConfigProperty

    public java.lang.String getConfigProperty(java.lang.String name,
                                              java.lang.String defaultValue)

  Description copied from interface: `CodeGenerator`
  Return a configuration property of the code generator

  Specified by:
    `getConfigProperty` in interface `CodeGenerator`
  Parameters:
    `name` - Name of the property requested
    `defaultValue` - default value
  Returns:
    Value of the property

### init

    public void init(java.util.Properties config)
              throws XCodeGenException

  Description copied from interface: `CodeGenerator`
  Initialize the code generator

  Specified by:
    `init` in interface `CodeGenerator`
  Parameters:
    `config` - Configuration of the code generator
  Throws:
    `XCodeGenException` - if any error occurs during the initialization

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD