org.apache.openjpa.jdbc.meta
Class PropertiesReverseCustomizer

java.lang.Object
  extended by org.apache.openjpa.jdbc.meta.PropertiesReverseCustomizer
All Implemented Interfaces:
ReverseCustomizer, Closeable

public class PropertiesReverseCustomizer
extends Object
implements ReverseCustomizer

Simple ReverseCustomizer that uses a properties file to to allow customization of basic class and field properties. The customizer uses the following keys:

All keys are optional; if not specified, the customizer keeps the default value generated by the reverse mapping tool.


Field Summary
protected  ReverseMappingTool tool
           
 
Constructor Summary
PropertiesReverseCustomizer()
           
 
Method Summary
 void close()
          Invoked when the customizer is no longer needed.
 void customize(ClassMapping cls)
          Customize the given class information produced by the reverse mapping tool.
 void customize(FieldMapping field)
          Customize the given field information produced by the reverse mapping tool.
 String getClassCode(ClassMapping mapping)
          Return a code template for the given class, or null to use the standard system-generated Java code.
 String getClassName(Table table, String defaultName)
          Return the fully-qualified class name to generate for the given table.
 String getDeclaration(FieldMapping field)
          Return a code template for the declaration of the given field, or null to use the system-generated default Java code.
 String getFieldCode(FieldMapping field)
          Return a code template for the get/set methods of the given field, or null to use the system-generated default Java code.
 String getFieldName(ClassMapping dec, Column[] cols, ForeignKey fk, String defaultName)
          Return the field name used to map the given columns, or null to prevent the columns from being mapped.
 String getInitialValue(FieldMapping field)
          Return code for the initial value for the given field, or null to use the default generated by the system.
protected  String getProperty(String key)
          Return the property value for the given key, or null if none.
 int getTableType(Table table, int defaultType)
          Return the type of the given table, or the given default type.
 void setConfiguration(Properties props)
          Set configuration properties given by the user.
 void setTool(ReverseMappingTool tool)
          Set the reverse mapping tool using this customizer.
 boolean unmappedTable(Table table)
          Notification that a table has gone unmapped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tool

protected ReverseMappingTool tool
Constructor Detail

PropertiesReverseCustomizer

public PropertiesReverseCustomizer()
Method Detail

setConfiguration

public void setConfiguration(Properties props)
Description copied from interface: ReverseCustomizer
Set configuration properties given by the user.

Specified by:
setConfiguration in interface ReverseCustomizer

setTool

public void setTool(ReverseMappingTool tool)
Description copied from interface: ReverseCustomizer
Set the reverse mapping tool using this customizer. You can use the tool to see how it is configured, or to use utility methods the tool provides.

Specified by:
setTool in interface ReverseCustomizer

getTableType

public int getTableType(Table table,
                        int defaultType)
Description copied from interface: ReverseCustomizer
Return the type of the given table, or the given default type. See the TABLE_XXX constants in ReverseMappingTool.

Specified by:
getTableType in interface ReverseCustomizer

getClassName

public String getClassName(Table table,
                           String defaultName)
Description copied from interface: ReverseCustomizer
Return the fully-qualified class name to generate for the given table. Return null to prevent the table from being mapped. Return the given default name if it is acceptable.

Specified by:
getClassName in interface ReverseCustomizer

customize

public void customize(ClassMapping cls)
Description copied from interface: ReverseCustomizer
Customize the given class information produced by the reverse mapping tool. To change the application identity class, use ReverseMappingTool.generateClass(java.lang.String, java.lang.Class) to creat the new class object. The class will not have any fields at the time of this call.

Specified by:
customize in interface ReverseCustomizer

getClassCode

public String getClassCode(ClassMapping mapping)
Description copied from interface: ReverseCustomizer
Return a code template for the given class, or null to use the standard system-generated Java code. To facilitate template reuse, the following parameters can appear in your template; the proper values will be subtituted by the system:

Specified by:
getClassCode in interface ReverseCustomizer

customize

public void customize(FieldMapping field)
Description copied from interface: ReverseCustomizer
Customize the given field information produced by the reverse mapping tool.

Specified by:
customize in interface ReverseCustomizer

getFieldName

public String getFieldName(ClassMapping dec,
                           Column[] cols,
                           ForeignKey fk,
                           String defaultName)
Description copied from interface: ReverseCustomizer
Return the field name used to map the given columns, or null to prevent the columns from being mapped. Return the given default if it is acceptable.

Specified by:
getFieldName in interface ReverseCustomizer
Parameters:
dec - the class that will declare this field
cols - the column(s) this field will represent
fk - for relation fields, the foreign key to the related type

getInitialValue

public String getInitialValue(FieldMapping field)
Description copied from interface: ReverseCustomizer
Return code for the initial value for the given field, or null to use the default generated by the system.

Specified by:
getInitialValue in interface ReverseCustomizer

getDeclaration

public String getDeclaration(FieldMapping field)
Description copied from interface: ReverseCustomizer
Return a code template for the declaration of the given field, or null to use the system-generated default Java code. To facilitate template reuse, the following parameters can appear in your template; the proper values will be subtituted by the system:

Specified by:
getDeclaration in interface ReverseCustomizer

getFieldCode

public String getFieldCode(FieldMapping field)
Description copied from interface: ReverseCustomizer
Return a code template for the get/set methods of the given field, or null to use the system-generated default Java code. To facilitate template reuse, the following parameters can appear in your template; the proper values will be subtituted by the system:

Specified by:
getFieldCode in interface ReverseCustomizer

unmappedTable

public boolean unmappedTable(Table table)
Description copied from interface: ReverseCustomizer
Notification that a table has gone unmapped. You can map the table yourself using this method. When mapping, use ReverseMappingTool.generateClass(java.lang.String, java.lang.Class) to create the class, ReverseMappingTool.newClassMapping(java.lang.Class, org.apache.openjpa.jdbc.schema.Table) to create the class metadata, and then ClassMapping.addDeclaredFieldMapping(java.lang.String, java.lang.Class) to add field metadata.

Specified by:
unmappedTable in interface ReverseCustomizer
Returns:
true if you map the table, false otherwise

close

public void close()
Description copied from interface: ReverseCustomizer
Invoked when the customizer is no longer needed.

Specified by:
close in interface ReverseCustomizer
Specified by:
close in interface Closeable

getProperty

protected String getProperty(String key)
Return the property value for the given key, or null if none.



Copyright © 2006-2007 Apache Software Foundation. All Rights Reserved.