|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.gen.MapClassGenerator
org.apache.cayenne.gen.DefaultClassGenerator
public class DefaultClassGenerator
Extends MapClassGenerator to allow target-specific filesystem locations where the files should go. Adds "execute" method that performs class generation based on the internal state of this object.
Field Summary | |
---|---|
protected java.io.File |
destDir
|
protected java.lang.String |
encoding
Stores the encoding of the generated file. |
protected boolean |
makePairs
|
protected java.lang.String |
outputPattern
|
protected boolean |
overwrite
|
protected java.lang.String |
superTemplate
|
protected java.lang.String |
template
|
protected long |
timestamp
|
protected boolean |
usePkgPath
|
Constructor Summary | |
---|---|
DefaultClassGenerator()
|
|
DefaultClassGenerator(DataMap dataMap)
Creates class generator and initializes it with DataMap. |
|
DefaultClassGenerator(DataMap dataMap,
java.util.List selectedObjEntities)
Creates class generator and initializes it with the list of ObjEntities that will be used in class generation. |
|
DefaultClassGenerator(java.util.List selectedObjEntities)
Deprecated. Use DefaultClassGenerator(DataMap, List) to provide support for v1.2 templates. |
Method Summary | |
---|---|
void |
closeWriter(java.io.Writer out)
Closes writer after class code has been successfully written by ClassGenerationInfo. |
void |
execute()
Runs class generation. |
protected java.io.File |
fileForClass(java.lang.String pkgName,
java.lang.String className)
Returns a target file where a generated class must be saved. |
protected java.io.File |
fileForSuperclass(java.lang.String pkgName,
java.lang.String className)
Returns a target file where a generated superclass must be saved. |
java.lang.String |
getEncoding()
Returns file encoding for the generated files. |
protected java.lang.String |
getSupertemplateForPairs()
Returns template file path for Java superclass when generating class pairs. |
protected java.lang.String |
getTemplateForPairs()
Returns template file path for Java subclass when generating class pairs. |
protected java.lang.String |
getTemplateForSingles()
Returns template file path for Java class when generating single classes. |
long |
getTimestamp()
Returns internal timestamp of this generator used to make decisions about overwriting individual files. |
protected boolean |
isOld(java.io.File file)
Returns true if file parameter is older than internal timestamp of
this class generator. |
protected java.io.File |
mkpath(java.io.File dest,
java.lang.String pkgName)
Returns a File object corresponding to a directory where files that belong to pkgName package should reside. |
java.io.Writer |
openWriter(ObjEntity entity,
java.lang.String pkgName,
java.lang.String className)
Opens a Writer to write generated output. |
void |
setDestDir(java.io.File destDir)
Sets the destDir. |
void |
setEncoding(java.lang.String encoding)
Sets file encoding. |
void |
setMakePairs(boolean makePairs)
Sets makepairs property. |
void |
setOutputPattern(java.lang.String outputPattern)
Sets outputPattern property. |
void |
setOverwrite(boolean overwrite)
Sets overwrite property. |
void |
setSuperTemplate(java.io.File superTemplate)
Deprecated. since 1.2 use setSuperTemplate(String) as custom template can
also be looked up in CLASSPATH. |
void |
setSuperTemplate(java.lang.String superTemplate)
Sets superTemplate property. |
void |
setTemplate(java.io.File template)
Deprecated. since 1.2 use setTemplate(String) as custom template can also
be looked up in CLASSPATH. |
void |
setTemplate(java.lang.String template)
Sets template property. |
void |
setTimestamp(long timestamp)
|
void |
setUsePkgPath(boolean usePkgPath)
Sets usepkgpath property. |
void |
validateAttributes()
Validates the state of this class generator. |
Methods inherited from class org.apache.cayenne.gen.MapClassGenerator |
---|
defaultSingleClassTemplate, defaultSubclassTemplate, defaultSuperclassTemplate, generateClassPairs, generateClassPairs, generateSingleClasses, generateSingleClasses, generateSingleClasses, getDataMap, getObjEntities, getSuperPkg, getVersionString, getVppConfig, initClassGenerator_1_1, isClient, setClient, setDataMap, setMode, setObjEntities, setSuperPkg, setVersionString, setVppConfig |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.File destDir
protected boolean overwrite
protected boolean usePkgPath
protected boolean makePairs
protected java.lang.String template
protected java.lang.String superTemplate
protected long timestamp
protected java.lang.String outputPattern
protected java.lang.String encoding
Constructor Detail |
---|
public DefaultClassGenerator()
public DefaultClassGenerator(DataMap dataMap)
public DefaultClassGenerator(DataMap dataMap, java.util.List selectedObjEntities)
public DefaultClassGenerator(java.util.List selectedObjEntities)
Method Detail |
---|
public void execute() throws java.lang.Exception
java.lang.Exception
public void validateAttributes() throws java.lang.Exception
java.lang.Exception
public void setDestDir(java.io.File destDir)
public void setOverwrite(boolean overwrite)
overwrite
property.
public void setMakePairs(boolean makePairs)
makepairs
property.
public void setTemplate(java.io.File template)
setTemplate(String)
as custom template can also
be looked up in CLASSPATH.
template
property.
public void setSuperTemplate(java.io.File superTemplate)
setSuperTemplate(String)
as custom template can
also be looked up in CLASSPATH.
superTemplate
property.
public void setTemplate(java.lang.String template)
template
property.
public void setSuperTemplate(java.lang.String superTemplate)
superTemplate
property.
public void setUsePkgPath(boolean usePkgPath)
usepkgpath
property.
public void setOutputPattern(java.lang.String outputPattern)
outputPattern
property.
public void closeWriter(java.io.Writer out) throws java.lang.Exception
MapClassGenerator
closeWriter
in class MapClassGenerator
java.lang.Exception
public java.io.Writer openWriter(ObjEntity entity, java.lang.String pkgName, java.lang.String className) throws java.lang.Exception
openWriter
in class MapClassGenerator
java.lang.Exception
protected java.io.File fileForSuperclass(java.lang.String pkgName, java.lang.String className) throws java.lang.Exception
java.lang.Exception
protected java.io.File fileForClass(java.lang.String pkgName, java.lang.String className) throws java.lang.Exception
java.lang.Exception
protected boolean isOld(java.io.File file)
file
parameter is older than internal timestamp of
this class generator.
protected java.io.File mkpath(java.io.File dest, java.lang.String pkgName) throws java.lang.Exception
pkgName
package should reside. Creates any missing diectories below
dest
.
java.lang.Exception
protected java.lang.String getTemplateForSingles() throws java.io.IOException
java.io.IOException
protected java.lang.String getTemplateForPairs() throws java.io.IOException
java.io.IOException
protected java.lang.String getSupertemplateForPairs() throws java.io.IOException
java.io.IOException
public long getTimestamp()
public void setTimestamp(long timestamp)
public java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |