|
||||||||||
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 File |
destDir
|
protected String |
encoding
Stores the encoding of the generated file. |
protected boolean |
makePairs
|
protected String |
outputPattern
|
protected boolean |
overwrite
|
protected String |
superTemplate
|
protected 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,
List selectedObjEntities)
Creates class generator and initializes it with the list of ObjEntities that will be used in class generation. |
Method Summary | |
---|---|
void |
closeWriter(Writer out)
Closes writer after class code has been successfully written by ClassGenerationInfo. |
void |
execute()
Runs class generation. |
protected File |
fileForClass(String pkgName,
String className)
Returns a target file where a generated class must be saved. |
protected File |
fileForSuperclass(String pkgName,
String className)
Returns a target file where a generated superclass must be saved. |
String |
getEncoding()
Returns file encoding for the generated files. |
protected String |
getSupertemplateForPairs()
Returns template file path for Java superclass when generating class pairs. |
protected String |
getTemplateForPairs()
Returns template file path for Java subclass when generating class pairs. |
protected 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(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. |
Writer |
openWriter(ObjEntity entity,
String pkgName,
String className)
Opens a Writer to write generated output. |
void |
setDestDir(File destDir)
Sets the destDir. |
void |
setEncoding(String encoding)
Sets file encoding. |
void |
setMakePairs(boolean makePairs)
Sets makepairs property. |
void |
setOutputPattern(String outputPattern)
Sets outputPattern property. |
void |
setOverwrite(boolean overwrite)
Sets overwrite property. |
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. |
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, 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 File destDir
protected boolean overwrite
protected boolean usePkgPath
protected boolean makePairs
protected String template
protected String superTemplate
protected long timestamp
protected String outputPattern
protected String encoding
Constructor Detail |
---|
public DefaultClassGenerator()
public DefaultClassGenerator(DataMap dataMap)
public DefaultClassGenerator(DataMap dataMap, List selectedObjEntities)
Method Detail |
---|
public void execute() throws Exception
Exception
public void validateAttributes() throws Exception
Exception
public void setDestDir(File destDir)
public void setOverwrite(boolean overwrite)
overwrite
property.
public void setMakePairs(boolean makePairs)
makepairs
property.
public void setTemplate(String template)
template
property.
public void setSuperTemplate(String superTemplate)
superTemplate
property.
public void setUsePkgPath(boolean usePkgPath)
usepkgpath
property.
public void setOutputPattern(String outputPattern)
outputPattern
property.
public void closeWriter(Writer out) throws Exception
MapClassGenerator
closeWriter
in class MapClassGenerator
Exception
public Writer openWriter(ObjEntity entity, String pkgName, String className) throws Exception
openWriter
in class MapClassGenerator
Exception
protected File fileForSuperclass(String pkgName, String className) throws Exception
Exception
protected File fileForClass(String pkgName, String className) throws Exception
Exception
protected boolean isOld(File file)
file
parameter is older than internal timestamp of
this class generator.
protected File mkpath(File dest, String pkgName) throws Exception
pkgName
package should reside. Creates any missing diectories below
dest
.
Exception
protected String getTemplateForSingles() throws IOException
IOException
protected String getTemplateForPairs() throws IOException
IOException
protected String getSupertemplateForPairs() throws IOException
IOException
public long getTimestamp()
public void setTimestamp(long timestamp)
public String getEncoding()
public void setEncoding(String encoding)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |