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

## org.apache.cayenne.gen
Class MapClassGenerator

    java.lang.Object
      org.apache.cayenne.gen.MapClassGenerator

Direct Known Subclasses:
  DefaultClassGenerator

    public abstract class MapClassGenerator

extends Object

Generates Java source code for ObjEntities in the DataMap. This class is abstract and does not deal with filesystem issues directly. Concrete subclasses should provide ways to store generated files by implementing `openWriter(ObjEntity, String, String)` and `closeWriter(Writer)`methods.

Author:
  Andrus Adamchik

Field Summary
`protected boolean` | `client`
`static String` | `CLIENT_SUBCLASS_TEMPLATE_1_2`
`static String` | `CLIENT_SUPERCLASS_TEMPLATE_1_2`
`protected DataMap` | `dataMap`
`protected static String` | `DEFAULT_VERSION`
`protected String` | `mode`
`protected static String` | `MODE_DATAMAP`
`protected static String` | `MODE_ENTITY`
`protected List` | `objEntities`
`static String` | `SINGLE_CLASS_TEMPLATE`
`static String` | `SINGLE_CLASS_TEMPLATE_1_1`
`static String` | `SINGLE_CLASS_TEMPLATE_1_2`
`static String` | `SUBCLASS_TEMPLATE`
`static String` | `SUBCLASS_TEMPLATE_1_1`
`static String` | `SUBCLASS_TEMPLATE_1_2`
`static String` | `SUPERCLASS_PREFIX`
`static String` | `SUPERCLASS_TEMPLATE`
`static String` | `SUPERCLASS_TEMPLATE_1_1`
`static String` | `SUPERCLASS_TEMPLATE_1_2`
`protected String` | `superPkg`
`protected static String` | `VERSION_1_1`
`protected static String` | `VERSION_1_2`
`protected String` | `versionString`
`protected foundrylogic.vpp.VPPConfig` | `vppConfig`

Constructor Summary
`MapClassGenerator()`
`MapClassGenerator(DataMap dataMap)`
`MapClassGenerator(DataMap dataMap, List objEntities)` Creates a new MapClassGenerator.

Method Summary
`abstract void` | `closeWriter(Writer out)` Closes writer after class code has been successfully written by ClassGenerationInfo.
`protected String` | `defaultSingleClassTemplate()`
`protected String` | `defaultSubclassTemplate()`
`protected String` | `defaultSuperclassTemplate()`
`void` | `generateClassPairs()` Runs class generation.
`void` | `generateClassPairs(String classTemplate, String superTemplate, String superPrefix)` Runs class generation.
`void` | `generateSingleClasses()` Runs class generation.
`void` | `generateSingleClasses(String classTemplate, String superPrefix)` Runs class generation.
`DataMap` | `getDataMap()`
`List` | `getObjEntities()`
`String` | `getSuperPkg()` Returns "superPkg" property value - a name of a superclass package that should be used for all generated superclasses.
`String` | `getVersionString()`
`foundrylogic.vpp.VPPConfig` | `getVppConfig()`
`protected void` | `initClassGenerator_1_1(ClassGenerationInfo gen, ObjEntity entity, boolean superclass)` Initializes ClassGenerationInfo with class name and package of a generated class.
`boolean` | `isClient()` Returns whether a default client object template will be used.
`abstract Writer` | `openWriter(ObjEntity entity, String pkgName, String className)` Creates a Writer to output source code for a given ObjEntity and Java class.
`void` | `setClient(boolean client)` Sets whether a default client object template should be used.
`void` | `setDataMap(DataMap dataMap)`
`void` | `setMode(String mode)`
`void` | `setObjEntities(List objEntities)` Initializes internal ObjEntities list.
`void` | `setSuperPkg(String superPkg)` Sets "superPkg" property value.
`void` | `setVersionString(String versionString)`
`void` | `setVppConfig(foundrylogic.vpp.VPPConfig vppConfig)`

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

Field Detail

### SINGLE_CLASS_TEMPLATE_1_1

    public static final String SINGLE_CLASS_TEMPLATE_1_1

See Also:
  Constant Field Values

### SUBCLASS_TEMPLATE_1_1

    public static final String SUBCLASS_TEMPLATE_1_1

See Also:
  Constant Field Values

### SUPERCLASS_TEMPLATE_1_1

    public static final String SUPERCLASS_TEMPLATE_1_1

See Also:
  Constant Field Values

### SINGLE_CLASS_TEMPLATE_1_2

    public static final String SINGLE_CLASS_TEMPLATE_1_2

See Also:
  Constant Field Values

### SUBCLASS_TEMPLATE_1_2

    public static final String SUBCLASS_TEMPLATE_1_2

See Also:
  Constant Field Values

### SUPERCLASS_TEMPLATE_1_2

    public static final String SUPERCLASS_TEMPLATE_1_2

See Also:
  Constant Field Values

### CLIENT_SUBCLASS_TEMPLATE_1_2

    public static final String CLIENT_SUBCLASS_TEMPLATE_1_2

Since:
  1.2
See Also:
  Constant Field Values

### CLIENT_SUPERCLASS_TEMPLATE_1_2

    public static final String CLIENT_SUPERCLASS_TEMPLATE_1_2

Since:
  1.2
See Also:
  Constant Field Values

### SINGLE_CLASS_TEMPLATE

    public static final String SINGLE_CLASS_TEMPLATE

See Also:
  Constant Field Values

### SUBCLASS_TEMPLATE

    public static final String SUBCLASS_TEMPLATE

See Also:
  Constant Field Values

### SUPERCLASS_TEMPLATE

    public static final String SUPERCLASS_TEMPLATE

See Also:
  Constant Field Values

### SUPERCLASS_PREFIX

    public static final String SUPERCLASS_PREFIX

See Also:
  Constant Field Values

### VERSION_1_1

    protected static final String VERSION_1_1

See Also:
  Constant Field Values

### VERSION_1_2

    protected static final String VERSION_1_2

See Also:
  Constant Field Values

### DEFAULT_VERSION

    protected static final String DEFAULT_VERSION

See Also:
  Constant Field Values

### MODE_DATAMAP

    protected static final String MODE_DATAMAP

See Also:
  Constant Field Values

### MODE_ENTITY

    protected static final String MODE_ENTITY

See Also:
  Constant Field Values

### versionString

    protected String versionString

### objEntities

    protected List objEntities

### superPkg

    protected String superPkg

### dataMap

    protected DataMap dataMap

### vppConfig

    protected foundrylogic.vpp.VPPConfig vppConfig

### mode

    protected String mode

### client

    protected boolean client

Constructor Detail

### MapClassGenerator

    public MapClassGenerator()

### MapClassGenerator

    public MapClassGenerator(DataMap dataMap)

### MapClassGenerator

    public MapClassGenerator(DataMap dataMap,
                             List objEntities)

  Creates a new MapClassGenerator.

  Since:
    1.2

Method Detail

### defaultSingleClassTemplate

    protected String defaultSingleClassTemplate()

### defaultSubclassTemplate

    protected String defaultSubclassTemplate()

### defaultSuperclassTemplate

    protected String defaultSuperclassTemplate()

### openWriter

    public abstract Writer openWriter(ObjEntity entity,
                                      String pkgName,
                                      String className)
                               throws Exception

  Creates a Writer to output source code for a given ObjEntity and Java class.

  Returns:
    Writer to store generated class source code or null if this class generation should be skipped.
  Throws:
    `Exception`

### closeWriter

    public abstract void closeWriter(Writer out)
                              throws Exception

  Closes writer after class code has been successfully written by ClassGenerationInfo.

  Throws:
    `Exception`

### generateClassPairs

    public void generateClassPairs()
                            throws Exception

  Runs class generation. Produces a pair of Java classes for each ObjEntity in the map. Uses default Cayenne templates for classes.

  Throws:
    `Exception`

### generateClassPairs

    public void generateClassPairs(String classTemplate,
                                   String superTemplate,
                                   String superPrefix)
                            throws Exception

  Runs class generation. Produces a pair of Java classes for each ObjEntity in the map. This allows developers to use generated subclass for their custom code, while generated superclass will contain Cayenne code. Superclass will be generated in the same package, its class name will be derived from the class name by adding a `superPrefix`.

  Throws:
    `Exception`

### generateSingleClasses

    public void generateSingleClasses()
                               throws Exception

  Runs class generation. Produces a single Java class for each ObjEntity in the map. Uses default Cayenne templates for classes.

  Throws:
    `Exception`

### generateSingleClasses

    public void generateSingleClasses(String classTemplate,
                                      String superPrefix)
                               throws Exception

  Runs class generation. Produces a single Java class for each ObjEntity in the map.

  Throws:
    `Exception`

### initClassGenerator_1_1

    protected void initClassGenerator_1_1(ClassGenerationInfo gen,
                                          ObjEntity entity,
                                          boolean superclass)

  Initializes ClassGenerationInfo with class name and package of a generated class.

### getSuperPkg

    public String getSuperPkg()

  Returns "superPkg" property value - a name of a superclass package that should be used for all generated superclasses.

### setSuperPkg

    public void setSuperPkg(String superPkg)

  Sets "superPkg" property value.

### isClient

    public boolean isClient()

  Returns whether a default client object template will be used.

  Since:
    1.2

### setClient

    public void setClient(boolean client)

  Sets whether a default client object template should be used.

  Since:
    1.2

### getDataMap

    public DataMap getDataMap()

  Returns:
    Returns the dataMap.

### setDataMap

    public void setDataMap(DataMap dataMap)

  Parameters:
    `dataMap` - The dataMap to set.

### getObjEntities

    public List getObjEntities()

### setObjEntities

    public void setObjEntities(List objEntities)

  Initializes internal ObjEntities list. This method creates a copy of the provided list to allow its indepdendent modification and also filters out entities that do not require class generation.

### getVersionString

    public String getVersionString()

  Returns:
    Returns the versionString.

### setVersionString

    public void setVersionString(String versionString)

  Parameters:
    `versionString` - The versionString to set.

### getVppConfig

    public foundrylogic.vpp.VPPConfig getVppConfig()

  Returns:
    Returns the vppConfig.

### setVppConfig

    public void setVppConfig(foundrylogic.vpp.VPPConfig vppConfig)

  Parameters:
    `vppConfig` - The vppConfig to set.

### setMode

    public void setMode(String mode)

  Parameters:
    `mode` - use "entity" for per-entity generation and "datamap" for per-datamap generation.

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

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