org.apache.cayenne.gen
Class ClassGenerator

java.lang.Object
  extended by org.apache.cayenne.gen.ClassGenerator

public class ClassGenerator
extends Object

Class generation engine for ObjEntities based on Velocity templates . Instance of ClassGenerationInfo is available inside Velocity template under the key "classGen".

Author:
Andrus Adamchik

Field Summary
protected  ClassGenerationInfo classGenerationInfo
           
protected  org.apache.velocity.Template classTemplate
           
protected  org.apache.velocity.context.Context velCtxt
           
static String VERSION_1_1
           
static String VERSION_1_2
           
protected  String versionString
           
 
Constructor Summary
ClassGenerator(String template, String versionString)
          Creates a new ClassGenerationInfo that uses a specified Velocity template.
ClassGenerator(String template, String versionString, foundrylogic.vpp.VPPConfig vppConfig)
          Creates a new ClassGenerationInfo that uses a specified Velocity template.
 
Method Summary
 void generateClass(Writer out, DataMap dataMap, ObjEntity entity, String fqnBaseClass, String fqnSuperClass, String fqnSubClass)
          Generates Java code for the ObjEntity.
 void generateClass(Writer out, ObjEntity entity)
          Generates Java code for the ObjEntity.
 ClassGenerationInfo getClassGenerationInfo()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_1_1

public static final String VERSION_1_1
See Also:
Constant Field Values

VERSION_1_2

public static final String VERSION_1_2
See Also:
Constant Field Values

versionString

protected String versionString

classTemplate

protected org.apache.velocity.Template classTemplate

velCtxt

protected org.apache.velocity.context.Context velCtxt

classGenerationInfo

protected ClassGenerationInfo classGenerationInfo
Constructor Detail

ClassGenerator

public ClassGenerator(String template,
                      String versionString)
               throws Exception
Creates a new ClassGenerationInfo that uses a specified Velocity template.

Parameters:
template - to use
versionString - of cgen
Throws:
Exception
Since:
1.2

ClassGenerator

public ClassGenerator(String template,
                      String versionString,
                      foundrylogic.vpp.VPPConfig vppConfig)
               throws Exception
Creates a new ClassGenerationInfo that uses a specified Velocity template.

Parameters:
template - to use
versionString - of cgen
vppConfig - for configuring VelocityEngine and VelocityContext
Throws:
Exception
Since:
1.2
Method Detail

generateClass

public void generateClass(Writer out,
                          ObjEntity entity)
                   throws Exception
Generates Java code for the ObjEntity. Output is written to the provided Writer.

Throws:
Exception

generateClass

public void generateClass(Writer out,
                          DataMap dataMap,
                          ObjEntity entity,
                          String fqnBaseClass,
                          String fqnSuperClass,
                          String fqnSubClass)
                   throws Exception
Generates Java code for the ObjEntity. Output is written to the provided Writer.

Throws:
Exception

getClassGenerationInfo

public ClassGenerationInfo getClassGenerationInfo()
Returns:
Returns the classGenerationInfo in template.


Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.