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

## org.objectstyle.cayenne.gen
Class MapClassGenerator

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

Direct Known Subclasses:
  DefaultClassGenerator

    public abstract class MapClassGenerator

extends java.lang.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:
  Andrei Adamchik

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

Constructor Summary
`MapClassGenerator()`
`MapClassGenerator(DataMap dataMap)`
`MapClassGenerator(DataMap dataMap, java.util.List objEntities)` Creates a new MapClassGenerator.
`MapClassGenerator(java.util.List objEntities)` Deprecated. Since 1.2 use MapClassGenerator(DataMap, List) to provide support for v1.2 templates.

Method Summary
`abstract void` | `closeWriter(java.io.Writer out)` Closes writer after class code has been successfully written by ClassGenerationInfo.
`protected java.lang.String` | `defaultSingleClassTemplate()`
`protected java.lang.String` | `defaultSubclassTemplate()`
`protected java.lang.String` | `defaultSuperclassTemplate()`
`void` | `generateClassPairs()` Runs class generation.
`void` | `generateClassPairs(java.lang.String classTemplate, java.lang.String superTemplate, java.lang.String superPrefix)` Runs class generation.
`void` | `generateSingleClasses()` Runs class generation.
`void` | `generateSingleClasses(java.lang.String classTemplate)` Deprecated. Use generateSingleClasses(String classTemplate, String superPrefix) instead.
`void` | `generateSingleClasses(java.lang.String classTemplate, java.lang.String superPrefix)` Runs class generation.
`DataMap` | `getDataMap()`
`java.util.List` | `getObjEntities()`
`java.lang.String` | `getSuperPkg()` Returns "superPkg" property value - a name of a superclass package that should be used for all generated superclasses.
`java.lang.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 java.io.Writer` | `openWriter(ObjEntity entity, java.lang.String pkgName, java.lang.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(java.lang.String mode)`
`void` | `setObjEntities(java.util.List objEntities)` Initializes internal ObjEntities list.
`void` | `setSuperPkg(java.lang.String superPkg)` Sets "superPkg" property value.
`void` | `setVersionString(java.lang.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 java.lang.String SINGLE_CLASS_TEMPLATE_1_1

See Also:
  Constant Field Values

### SUBCLASS_TEMPLATE_1_1

    public static final java.lang.String SUBCLASS_TEMPLATE_1_1

See Also:
  Constant Field Values

### SUPERCLASS_TEMPLATE_1_1

    public static final java.lang.String SUPERCLASS_TEMPLATE_1_1

See Also:
  Constant Field Values

### SINGLE_CLASS_TEMPLATE_1_2

    public static final java.lang.String SINGLE_CLASS_TEMPLATE_1_2

See Also:
  Constant Field Values

### SUBCLASS_TEMPLATE_1_2

    public static final java.lang.String SUBCLASS_TEMPLATE_1_2

See Also:
  Constant Field Values

### SUPERCLASS_TEMPLATE_1_2

    public static final java.lang.String SUPERCLASS_TEMPLATE_1_2

See Also:
  Constant Field Values

### CLIENT_SUBCLASS_TEMPLATE_1_2

    public static final java.lang.String CLIENT_SUBCLASS_TEMPLATE_1_2

Since:
  1.2
See Also:
  Constant Field Values

### CLIENT_SUPERCLASS_TEMPLATE_1_2

    public static final java.lang.String CLIENT_SUPERCLASS_TEMPLATE_1_2

Since:
  1.2
See Also:
  Constant Field Values

### SINGLE_CLASS_TEMPLATE

    public static final java.lang.String SINGLE_CLASS_TEMPLATE

See Also:
  Constant Field Values

### SUBCLASS_TEMPLATE

    public static final java.lang.String SUBCLASS_TEMPLATE

See Also:
  Constant Field Values

### SUPERCLASS_TEMPLATE

    public static final java.lang.String SUPERCLASS_TEMPLATE

See Also:
  Constant Field Values

### SUPERCLASS_PREFIX

    public static final java.lang.String SUPERCLASS_PREFIX

See Also:
  Constant Field Values

### VERSION_1_1

    protected static final java.lang.String VERSION_1_1

See Also:
  Constant Field Values

### VERSION_1_2

    protected static final java.lang.String VERSION_1_2

See Also:
  Constant Field Values

### DEFAULT_VERSION

    protected static final java.lang.String DEFAULT_VERSION

See Also:
  Constant Field Values

### MODE_DATAMAP

    protected static final java.lang.String MODE_DATAMAP

See Also:
  Constant Field Values

### MODE_ENTITY

    protected static final java.lang.String MODE_ENTITY

See Also:
  Constant Field Values

### versionString

    protected java.lang.String versionString

### objEntities

    protected java.util.List objEntities

### superPkg

    protected java.lang.String superPkg

### dataMap

    protected DataMap dataMap

### vppConfig

    protected foundrylogic.vpp.VPPConfig vppConfig

### mode

    protected java.lang.String mode

### client

    protected boolean client

Constructor Detail

### MapClassGenerator

    public MapClassGenerator()

### MapClassGenerator

    public MapClassGenerator(DataMap dataMap)

### MapClassGenerator

    public MapClassGenerator(DataMap dataMap,
                             java.util.List objEntities)

  Creates a new MapClassGenerator.

  Since:
    1.2

### MapClassGenerator

    public MapClassGenerator(java.util.List objEntities)

  Deprecated. Since 1.2 use MapClassGenerator(DataMap, List) to provide support for v1.2 templates.

Method Detail

### defaultSingleClassTemplate

    protected java.lang.String defaultSingleClassTemplate()

### defaultSubclassTemplate

    protected java.lang.String defaultSubclassTemplate()

### defaultSuperclassTemplate

    protected java.lang.String defaultSuperclassTemplate()

### openWriter

    public abstract java.io.Writer openWriter(ObjEntity entity,
                                              java.lang.String pkgName,
                                              java.lang.String className)
                                       throws java.lang.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:
    `java.lang.Exception`

### closeWriter

    public abstract void closeWriter(java.io.Writer out)
                              throws java.lang.Exception

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

  Throws:
    `java.lang.Exception`

### generateClassPairs

    public void generateClassPairs()
                            throws java.lang.Exception

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

  Throws:
    `java.lang.Exception`

### generateClassPairs

    public void generateClassPairs(java.lang.String classTemplate,
                                   java.lang.String superTemplate,
                                   java.lang.String superPrefix)
                            throws java.lang.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:
    `java.lang.Exception`

### generateSingleClasses

    public void generateSingleClasses()
                               throws java.lang.Exception

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

  Throws:
    `java.lang.Exception`

### generateSingleClasses

    public void generateSingleClasses(java.lang.String classTemplate)
                               throws java.lang.Exception

  Deprecated. Use generateSingleClasses(String classTemplate, String superPrefix) instead.

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

  Throws:
    `java.lang.Exception`

### generateSingleClasses

    public void generateSingleClasses(java.lang.String classTemplate,
                                      java.lang.String superPrefix)
                               throws java.lang.Exception

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

  Throws:
    `java.lang.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 java.lang.String getSuperPkg()

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

### setSuperPkg

    public void setSuperPkg(java.lang.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 java.util.List getObjEntities()

### setObjEntities

    public void setObjEntities(java.util.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 java.lang.String getVersionString()

  Returns:
    Returns the versionString.

### setVersionString

    public void setVersionString(java.lang.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(java.lang.String mode)

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

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

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.