|
SolarMetric Kodo JDO 3.1.6 generated on August 25 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--kodo.jdbc.meta.ReverseMappingTool
Reverse-maps a schema into class mappings and the assiciated java code. Generates an XML schema definition file, an XML mapping file, java code files for persistent classes and their application IDs, and metadata files for these classes. The schema definition file and XML mapping file can then be imported into the schema factory and mapping factory of your choosing.
| Field Summary | |
static String |
LEVEL_CLASS
|
static String |
LEVEL_PACKAGE
|
| Constructor Summary | |
ReverseMappingTool(JDBCConfiguration conf)
Constructor. |
|
| Method Summary | |
void |
addClassIndicator(ClassIndicator cls,
ClassMapping owner)
Add a mapping. |
boolean |
addClassMapping(ClassMapping mapping)
Add a mapping. |
boolean |
addFieldMapping(FieldMapping field,
ClassMapping owner)
Add a mapping. |
void |
addVersionIndicator(VersionIndicator version,
ClassMapping owner)
Add a mapping. |
Class |
generateClass(String name,
Class parent)
Generate a new class with the given name. |
void |
generateMappings()
Generate mappings and class code for the current schema group. |
boolean |
getBlobAsObject()
Whether to reverse-map blob columns as containing serialized Java objects, rather than the default of using a byte[] field. |
ClassMapping |
getClassMapping(Table table)
Return the class mapping for the given table, or null if none. |
String |
getClassName(Table table)
Return a Java identifier-formatted name for the given table name, using the default package. |
serp.util.CodeFormat |
getCodeFormat()
The code formatter for the generated Java code. |
JDBCConfiguration |
getConfiguration()
Return the configuration provided on construction. |
ReverseCustomizer |
getCustomizer()
Return the customizer in use, or null if none. |
File |
getDirectory()
The file to output the generated code to, or null for the current directory. |
String |
getFieldName(String name,
ClassMetaData fieldOwner)
Return a default Java identifier-formatted name for the given column/table name. |
Class |
getFieldType(Column col,
boolean forceObject)
Return the default field type for the given column. |
Log |
getLog()
Return the log to write to. |
ClassMapping[] |
getMappings()
Return the generated mappings. |
boolean |
getNullableAsObject()
Return whether even nullable columns will be mapped to wrappers rather than primitives. |
boolean |
getOneToManyRelations()
Whether to generate inverse 1-many relations for all 1-1 relations. |
String |
getPackageName()
Return the default package for the generated classes, or null if unset. |
boolean |
getPrimaryKeyOnJoin()
Return true if join tables are allowed to have primary keys, false if all primary key tables will be mapped as persistent classes. |
String |
getRelationName(Class fieldType,
boolean coll,
ForeignKey fk,
boolean inverse,
ClassMetaData fieldOwner)
Return a default java identifier-formatted field relation name for the given class name. |
MappingRepository |
getRepository()
Return the mapping repository used to hold generated mappings. |
SchemaGroup |
getSchemaGroup()
Return the schema group to reverse map. |
boolean |
getUseDatastoreIdentity()
Whether to use datastore identity when possible. |
boolean |
getUseForeignKeyName()
Return whether the foreign key name will be used to generate relation names. |
boolean |
getUseSchemaName()
Return true if the schema name will be included in the generated class name for each table. |
static void |
main(String[] args)
Usage: java kodo.jdbc.meta.ReverseMappingTool [option]* <.schema file or resource>* |
ClassMetaData |
newClassMetaData(Class cls,
Class pcParent,
int idType)
Return a new class metadata for the given name and parent. |
FieldMetaData |
newFieldMetaData(String name,
Class type,
ClassMetaData owner)
Return a new field metadata for the given name, type, and owner. |
static boolean |
run(JDBCConfiguration conf,
String[] args,
serp.util.Options opts)
Run the tool. |
static void |
run(JDBCConfiguration conf,
String[] args,
String packageName,
File codeDir,
boolean useSchemaName,
boolean useFKName,
boolean nullAsObj,
boolean blobAsObj,
boolean pkOnJoin,
boolean datastore,
boolean oneMany,
String metaLevel,
ReverseCustomizer customizer,
serp.util.CodeFormat format,
ClassLoader loader)
Run the tool. |
void |
setBlobAsObject(boolean blobAsObj)
Whether to reverse-map blob columns as containing serialized Java objects, rather than the default of using a byte[] field. |
void |
setCodeFormat(serp.util.CodeFormat format)
Set the code formatter for the generated Java code. |
void |
setCustomizer(ReverseCustomizer customizer)
Set the customizer. |
void |
setDirectory(File dir)
The file to output the generated code to, or null for the current directory. |
void |
setNullableAsObject(boolean nullAsObj)
Set whether even nullable columns will be mapped to wrappers rather than primitives. |
void |
setOneToManyRelations(boolean oneMany)
Whether to generate inverse 1-many relations for all 1-1 relations. |
void |
setPackageName(String packageName)
Set the default package for the generated classes; use null to indicate no package. |
void |
setPrimaryKeyOnJoin(boolean pkOnJoin)
Set to true if join tables are allowed to have primary keys, false if all primary key tables will be mapped as persistent classes. |
void |
setRepository(MappingRepository repos)
Set the repository to use. |
void |
setSchemaGroup(SchemaGroup schema)
Set the schema to reverse map. |
void |
setUseDatastoreIdentity(boolean datastore)
Whether to use datastore identity when possible. |
void |
setUseForeignKeyName(boolean useFK)
Set whether the foreign key name will be used to generate relation names. |
void |
setUseSchemaName(boolean useSchema)
Set whether the schema name will be included in the generated class name for each table. |
void |
writeApplicationIdentityCode()
Uses the ApplicationIdTool to write identity classes to the
proper packages. |
void |
writeCode()
Uses CodeGenerators to write the Java code for the generated
mappings to the proper packages. |
void |
writeMappings(boolean perClass)
Uses the XMLMappingInfoSerializer to write the generated
metadata to the proper packages. |
void |
writeMetaData(boolean perClass)
Uses the JDOMetaDataSerializer to write the generated metadata
to the proper packages. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String LEVEL_PACKAGE
public static final String LEVEL_CLASS
| Constructor Detail |
public ReverseMappingTool(JDBCConfiguration conf)
| Method Detail |
public JDBCConfiguration getConfiguration()
public Log getLog()
public String getPackageName()
public void setPackageName(String packageName)
public File getDirectory()
public void setDirectory(File dir)
public boolean getUseSchemaName()
public void setUseSchemaName(boolean useSchema)
public boolean getUseForeignKeyName()
public void setUseForeignKeyName(boolean useFK)
public boolean getNullableAsObject()
public void setNullableAsObject(boolean nullAsObj)
public boolean getBlobAsObject()
public void setBlobAsObject(boolean blobAsObj)
public boolean getPrimaryKeyOnJoin()
public void setPrimaryKeyOnJoin(boolean pkOnJoin)
public boolean getUseDatastoreIdentity()
public void setUseDatastoreIdentity(boolean datastore)
public boolean getOneToManyRelations()
public void setOneToManyRelations(boolean oneMany)
public serp.util.CodeFormat getCodeFormat()
public void setCodeFormat(serp.util.CodeFormat format)
public ReverseCustomizer getCustomizer()
public void setCustomizer(ReverseCustomizer customizer)
public MappingRepository getRepository()
public void setRepository(MappingRepository repos)
public SchemaGroup getSchemaGroup()
public void setSchemaGroup(SchemaGroup schema)
public ClassMapping[] getMappings()
public void generateMappings()
public void writeCode()
throws IOException
CodeGenerators to write the Java code for the generated
mappings to the proper packages.
public void writeMetaData(boolean perClass)
throws IOException
JDOMetaDataSerializer to write the generated metadata
to the proper packages.
public void writeMappings(boolean perClass)
throws IOException
XMLMappingInfoSerializer to write the generated
metadata to the proper packages.
public void writeApplicationIdentityCode()
throws IOException
ApplicationIdTool to write identity classes to the
proper packages.public ClassMapping getClassMapping(Table table)
public boolean addClassMapping(ClassMapping mapping)
public boolean addFieldMapping(FieldMapping field,
ClassMapping owner)
public void addVersionIndicator(VersionIndicator version,
ClassMapping owner)
public void addClassIndicator(ClassIndicator cls,
ClassMapping owner)
public ClassMetaData newClassMetaData(Class cls,
Class pcParent,
int idType)
name - the full name of the class to generateidType - ClassMetaData.ID_APPLICATION or
ClassMetaData.ID_DATASTOREpcParent - nearest persistent parent class, or null
public FieldMetaData newFieldMetaData(String name,
Class type,
ClassMetaData owner)
public String getClassName(Table table)
public String getFieldName(String name,
ClassMetaData fieldOwner)
public String getRelationName(Class fieldType,
boolean coll,
ForeignKey fk,
boolean inverse,
ClassMetaData fieldOwner)
public Class getFieldType(Column col,
boolean forceObject)
public Class generateClass(String name,
Class parent)
public static void main(String[] args)
throws IOException,
SQLException
Usage: java kodo.jdbc.meta.ReverseMappingTool [option]* <.schema file or resource>*
Where the following options are recognized.
JDOConfiguration. Optional.JDBCConfiguration can be set by
using their names and supplying a value. For example:
-licenseKey adslfja83r3lkadfReverseCustomizer implementation to use to
customize the reverse mapping process. Optional.ReverseCustomizer.CodeFormat.Each schema given as an argument will be reverse-mapped into JDO classes and associated metadata. If no arguments are given, the database schemas defined by the system configuration will be reverse-mapped.
public static boolean run(JDBCConfiguration conf,
String[] args,
serp.util.Options opts)
throws IOException,
SQLException
main(java.lang.String[])
public static void run(JDBCConfiguration conf,
String[] args,
String packageName,
File codeDir,
boolean useSchemaName,
boolean useFKName,
boolean nullAsObj,
boolean blobAsObj,
boolean pkOnJoin,
boolean datastore,
boolean oneMany,
String metaLevel,
ReverseCustomizer customizer,
serp.util.CodeFormat format,
ClassLoader loader)
throws IOException,
SQLException
|
SolarMetric Kodo JDO 3.1.6 generated on August 25 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||