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 ClassGenerationAction

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

Direct Known Subclasses:
  ClassGenerationAction1_1, ClientClassGenerationAction

    public class ClassGenerationAction

extends Object

Since:
  3.0
Author:
  Andrus Adamchik

Field Summary
`protected Collection<Artifact>` | `artifacts`
`protected ArtifactsGenerationMode` | `artifactsGenerationMode`
`protected org.apache.velocity.VelocityContext` | `context`
`protected DataMap` | `dataMap`
`protected File` | `destDir`
`static String` | `EMBEDDABLE_SINGLE_CLASS_TEMPLATE`
`static String` | `EMBEDDABLE_SUBCLASS_TEMPLATE`
`static String` | `EMBEDDABLE_SUPERCLASS_TEMPLATE`
`protected String` | `embeddableSuperTemplate`
`protected String` | `embeddableTemplate`
`protected String` | `encoding`
`protected org.apache.commons.logging.Log` | `logger`
`protected boolean` | `makePairs`
`protected String` | `outputPattern`
`protected boolean` | `overwrite`
`static String` | `SINGLE_CLASS_TEMPLATE`
`static String` | `SUBCLASS_TEMPLATE`
`static String` | `SUPERCLASS_PREFIX`
`static String` | `SUPERCLASS_TEMPLATE`
`protected String` | `superPkg`
`protected String` | `superTemplate`
`protected String` | `template`
`protected Map<String,org.apache.velocity.Template>` | `templateCache`
`protected long` | `timestamp`
`protected boolean` | `usePkgPath`

Constructor Summary
`ClassGenerationAction()`

Method Summary
`void` | `addEmbeddables(Collection<Embeddable> embeddables)`
`void` | `addEntities(Collection<ObjEntity> entities)` Adds entities to the internal entity list.
`protected String` | `customTemplateName(TemplateType type)`
`protected String` | `defaultTemplateName(TemplateType type)`
`void` | `execute()` Executes class generation once per each artifact.
`protected void` | `execute(Artifact artifact)` Executes class generation for a single artifact.
`protected File` | `fileForClass()` Returns a target file where a generated class must be saved.
`protected File` | `fileForSuperclass()` Returns a target file where a generated superclass must be saved.
`protected String` | `getSuperclassPrefix()` Returns a String used to prefix class name to create a generated superclass.
`protected org.apache.velocity.Template` | `getTemplate(TemplateType type)`
`protected boolean` | `isOld(File file)` Returns true if `file` parameter is older than internal timestamp of this class generator.
`protected File` | `mkpath(File dest, String pkgName)` Returns a File object corresponding to a directory where files that belong to `pkgName` package should reside.
`protected Writer` | `openWriter(TemplateType templateType)` Opens a Writer to write generated output.
`protected void` | `resetContextForArtifact(Artifact artifact)` VelocityContext initialization method called once per artifact.
`protected void` | `resetContextForArtifactTemplate(Artifact artifact, TemplateType templateType)` VelocityContext initialization method called once per each artifact and template type combination.
`void` | `setArtifactsGenerationMode(String mode)`
`void` | `setContext(org.apache.velocity.VelocityContext context)` Sets an optional shared VelocityContext.
`void` | `setDataMap(DataMap dataMap)`
`void` | `setDestDir(File destDir)` Sets the destDir.
`void` | `setEmbeddableSuperTemplate(String embeddableSuperTemplate)`
`void` | `setEmbeddableTemplate(String embeddableTemplate)`
`void` | `setEncoding(String encoding)` Sets file encoding.
`void` | `setLogger(org.apache.commons.logging.Log logger)` Injects an optional logger that will be used to trace generated files at the info level.
`void` | `setMakePairs(boolean makePairs)` Sets `makepairs` property.
`void` | `setOutputPattern(String outputPattern)` Sets `outputPattern` property.
`void` | `setOverwrite(boolean overwrite)` Sets `overwrite` property.
`void` | `setSuperPkg(String superPkg)` Sets "superPkg" property value.
`void` | `setSuperTemplate(String superTemplate)` Sets `superTemplate` property.
`void` | `setTemplate(String template)` Sets `template` property.
`void` | `setTimestamp(long timestamp)`
`void` | `setUsePkgPath(boolean usePkgPath)` Sets `usepkgpath` property.
`protected void` | `validateAttributes()` Validates the state of this class generator.

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

Field Detail

### 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

### EMBEDDABLE_SINGLE_CLASS_TEMPLATE

    public static final String EMBEDDABLE_SINGLE_CLASS_TEMPLATE

See Also:
  Constant Field Values

### EMBEDDABLE_SUBCLASS_TEMPLATE

    public static final String EMBEDDABLE_SUBCLASS_TEMPLATE

See Also:
  Constant Field Values

### EMBEDDABLE_SUPERCLASS_TEMPLATE

    public static final String EMBEDDABLE_SUPERCLASS_TEMPLATE

See Also:
  Constant Field Values

### SUPERCLASS_PREFIX

    public static final String SUPERCLASS_PREFIX

See Also:
  Constant Field Values

### artifacts

    protected Collection<Artifact> artifacts

### superPkg

    protected String superPkg

### dataMap

    protected DataMap dataMap

### artifactsGenerationMode

    protected ArtifactsGenerationMode artifactsGenerationMode

### makePairs

    protected boolean makePairs

### logger

    protected org.apache.commons.logging.Log logger

### destDir

    protected File destDir

### overwrite

    protected boolean overwrite

### usePkgPath

    protected boolean usePkgPath

### template

    protected String template

### superTemplate

    protected String superTemplate

### embeddableTemplate

    protected String embeddableTemplate

### embeddableSuperTemplate

    protected String embeddableSuperTemplate

### timestamp

    protected long timestamp

### outputPattern

    protected String outputPattern

### encoding

    protected String encoding

### context

    protected org.apache.velocity.VelocityContext context

### templateCache

    protected Map<String,org.apache.velocity.Template> templateCache

Constructor Detail

### ClassGenerationAction

    public ClassGenerationAction()

Method Detail

### defaultTemplateName

    protected String defaultTemplateName(TemplateType type)

### customTemplateName

    protected String customTemplateName(TemplateType type)

### getSuperclassPrefix

    protected String getSuperclassPrefix()

  Returns a String used to prefix class name to create a generated superclass. Default value is "_".

### resetContextForArtifact

    protected void resetContextForArtifact(Artifact artifact)

  VelocityContext initialization method called once per artifact.

### resetContextForArtifactTemplate

    protected void resetContextForArtifactTemplate(Artifact artifact,
                                                   TemplateType templateType)

  VelocityContext initialization method called once per each artifact and template type combination.

### execute

    public void execute()
                 throws Exception

  Executes class generation once per each artifact.

  Throws:
    `Exception`

### execute

    protected void execute(Artifact artifact)
                    throws Exception

  Executes class generation for a single artifact.

  Throws:
    `Exception`

### getTemplate

    protected org.apache.velocity.Template getTemplate(TemplateType type)
                                                throws Exception

  Throws:
    `Exception`

### validateAttributes

    protected void validateAttributes()

  Validates the state of this class generator. Throws CayenneRuntimeException if it is in an inconsistent state. Called internally from "execute".

### setDestDir

    public void setDestDir(File destDir)

  Sets the destDir.

### setOverwrite

    public void setOverwrite(boolean overwrite)

  Sets `overwrite` property.

### setMakePairs

    public void setMakePairs(boolean makePairs)

  Sets `makepairs` property.

### setTemplate

    public void setTemplate(String template)

  Sets `template` property.

### setSuperTemplate

    public void setSuperTemplate(String superTemplate)

  Sets `superTemplate` property.

### setUsePkgPath

    public void setUsePkgPath(boolean usePkgPath)

  Sets `usepkgpath` property.

### setOutputPattern

    public void setOutputPattern(String outputPattern)

  Sets `outputPattern` property.

### openWriter

    protected Writer openWriter(TemplateType templateType)
                         throws Exception

  Opens a Writer to write generated output. Returned Writer is mapped to a filesystem file (although subclasses may override that). File location is determined from the current state of VelocityContext and the TemplateType passed as a parameter. Writer encoding is determined from the value of the "encoding" property.

  Throws:
    `Exception`

### fileForSuperclass

    protected File fileForSuperclass()
                              throws Exception

  Returns a target file where a generated superclass must be saved. If null is returned, class shouldn't be generated.

  Throws:
    `Exception`

### fileForClass

    protected File fileForClass()
                         throws Exception

  Returns a target file where a generated class must be saved. If null is returned, class shouldn't be generated.

  Throws:
    `Exception`

### isOld

    protected boolean isOld(File file)

  Returns true if `file` parameter is older than internal timestamp of this class generator.

### mkpath

    protected File mkpath(File dest,
                          String pkgName)
                   throws Exception

  Returns a File object corresponding to a directory where files that belong to `pkgName` package should reside. Creates any missing diectories below `dest`.

  Throws:
    `Exception`

### setTimestamp

    public void setTimestamp(long timestamp)

### setEncoding

    public void setEncoding(String encoding)

  Sets file encoding. If set to null, default system encoding will be used.

### setSuperPkg

    public void setSuperPkg(String superPkg)

  Sets "superPkg" property value.

### setDataMap

    public void setDataMap(DataMap dataMap)

  Parameters:
    `dataMap` - The dataMap to set.

### addEntities

    public void addEntities(Collection<ObjEntity> entities)

  Adds entities to the internal entity list.

### addEmbeddables

    public void addEmbeddables(Collection<Embeddable> embeddables)

### setContext

    public void setContext(org.apache.velocity.VelocityContext context)

  Sets an optional shared VelocityContext. Useful with tools like VPP that can set custom values in the context, not known to Cayenne.

### setLogger

    public void setLogger(org.apache.commons.logging.Log logger)

  Injects an optional logger that will be used to trace generated files at the info level.

### setEmbeddableTemplate

    public void setEmbeddableTemplate(String embeddableTemplate)

### setEmbeddableSuperTemplate

    public void setEmbeddableSuperTemplate(String embeddableSuperTemplate)

### setArtifactsGenerationMode

    public void setArtifactsGenerationMode(String mode)

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-2008 Apache Cayenne. All Rights Reserved.