Package org.apache.openjpa.jdbc.meta
Class PropertiesReverseCustomizer
- java.lang.Object
 - 
- org.apache.openjpa.jdbc.meta.PropertiesReverseCustomizer
 
 
- 
- All Implemented Interfaces:
 ReverseCustomizer,Closeable
public class PropertiesReverseCustomizer extends Object implements ReverseCustomizer
SimpleReverseCustomizerthat uses a properties file to to allow customization of basic class and field properties. The customizer uses the following keys:- <table name>.table-type: Override the default type of the
 given table. Legal values are: 
base, secondary, secondary-outer, association, subclass, none. See the TABLE_XXX constants inReverseMappingToolfor descriptions. - <class name>.rename: Override the tool-generated class name
 with the given value. Use full class names, including package. Use a
 value of 
noneto reject the class and leave the corresponding table unmapped. - <table name>.class-name: Assign the given fully-qualified
 class name to the type created from the given table. Use a value of
 
noneto prevent mapping this table. This property can be used in place of therenameproperty. - <class name>.identity: Set this property to
 
datastore,builtin, or the desired fully-qualified application identity class name to override the reverse mapping tool's default identity settings. If the class has been renamed, use the new name. - <class name>.<field name>.rename: Override the
 tool-generated field name with the given value. Use the field owner's
 full class name in the property key. The property value should be the
 new field name, without the preceding class name. Use a value of
 
noneto reject the generated mapping. - <table name>.<column name>.field-name: Assign the
 field name to use for the mapping of a particular column. If this is
 a multi-column mapping, any one of the columns can be used. Use a value
 of 
noneto prevent the column (and associated columns) from being mapped. This property can be used in place of therenameproperty. - <class name>.<field name>.type: The class name of the type to give the named field. Use full class names. If the field has been renamed, use the new name.
 - <class name>.<field name>.value: The initial value for the named field. The given string will be placed as-is in the generated Java code, so be sure to add quotes to strings, etc. If the field has been renamed, use the new name.
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected ReverseMappingTooltool 
- 
Constructor Summary
Constructors Constructor Description PropertiesReverseCustomizer() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Invoked when the customizer is no longer needed.voidcustomize(ClassMapping cls)Customize the given class information produced by the reverse mapping tool.voidcustomize(FieldMapping field)Customize the given field information produced by the reverse mapping tool.StringgetClassCode(ClassMapping mapping)Return a code template for the given class, or null to use the standard system-generated Java code.StringgetClassName(Table table, String defaultName)Return the fully-qualified class name to generate for the given table.StringgetDeclaration(FieldMapping field)Return a code template for the declaration of the given field, or null to use the system-generated default Java code.StringgetFieldCode(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.StringgetFieldName(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.StringgetInitialValue(FieldMapping field)Return code for the initial value for the given field, or null to use the default generated by the system.protected StringgetProperty(String key)Return the property value for the given key, or null if none.intgetTableType(Table table, int defaultType)Return the type of the given table, or the given default type.voidsetConfiguration(Properties props)Set configuration properties given by the user.voidsetTool(ReverseMappingTool tool)Set the reverse mapping tool using this customizer.booleanunmappedTable(Table table)Notification that a table has gone unmapped. 
 - 
 
- 
- 
Field Detail
- 
tool
protected ReverseMappingTool tool
 
 - 
 
- 
Method Detail
- 
setConfiguration
public void setConfiguration(Properties props)
Description copied from interface:ReverseCustomizerSet configuration properties given by the user.- Specified by:
 setConfigurationin interfaceReverseCustomizer
 
- 
setTool
public void setTool(ReverseMappingTool tool)
Description copied from interface:ReverseCustomizerSet 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:
 setToolin interfaceReverseCustomizer
 
- 
getTableType
public int getTableType(Table table, int defaultType)
Description copied from interface:ReverseCustomizerReturn the type of the given table, or the given default type. See the TABLE_XXX constants inReverseMappingTool.- Specified by:
 getTableTypein interfaceReverseCustomizer
 
- 
getClassName
public String getClassName(Table table, String defaultName)
Description copied from interface:ReverseCustomizerReturn 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:
 getClassNamein interfaceReverseCustomizer
 
- 
customize
public void customize(ClassMapping cls)
Description copied from interface:ReverseCustomizerCustomize the given class information produced by the reverse mapping tool. To change the application identity class, useReverseMappingTool.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:
 customizein interfaceReverseCustomizer
 
- 
getClassCode
public String getClassCode(ClassMapping mapping)
Description copied from interface:ReverseCustomizerReturn 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:- ${packageDec}: The package declaration, in the form "package <package name >;", or empty string if no package.
 - ${imports}: Imports for the packages used by the declared field types.
 - ${className}: The name of the class, without package.
 - ${extendsDec}: Extends declaration, in the form "extends <superclass>", or empty string if no superclass.
 - ${constructor}: A constructor that takes in all primary key fields of the class, or empty string if the class uses datastore identity.
 - ${fieldDecs}: Declarations of all the generated fields.
 - ${fieldCode}: Get/set methods for all the generated fields.
 
- Specified by:
 getClassCodein interfaceReverseCustomizer
 
- 
customize
public void customize(FieldMapping field)
Description copied from interface:ReverseCustomizerCustomize the given field information produced by the reverse mapping tool.- Specified by:
 customizein interfaceReverseCustomizer
 
- 
getFieldName
public String getFieldName(ClassMapping dec, Column[] cols, ForeignKey fk, String defaultName)
Description copied from interface:ReverseCustomizerReturn 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:
 getFieldNamein interfaceReverseCustomizer- Parameters:
 dec- the class that will declare this fieldcols- the column(s) this field will representfk- for relation fields, the foreign key to the related type
 
- 
getInitialValue
public String getInitialValue(FieldMapping field)
Description copied from interface:ReverseCustomizerReturn code for the initial value for the given field, or null to use the default generated by the system.- Specified by:
 getInitialValuein interfaceReverseCustomizer
 
- 
getDeclaration
public String getDeclaration(FieldMapping field)
Description copied from interface:ReverseCustomizerReturn 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:- ${fieldName}: The name of the field.
 - ${capFieldName}: The capitalized field name.
 - ${propertyName}: The field name without leading '_', if any.
 - ${fieldType}: The field's type name.
 - ${fieldValue}: The field's initial value, in the form " = <value>", or empty string if none.
 
- Specified by:
 getDeclarationin interfaceReverseCustomizer
 
- 
getFieldCode
public String getFieldCode(FieldMapping field)
Description copied from interface:ReverseCustomizerReturn 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:- ${fieldName}: The name of the field.
 - ${capFieldName}: The capitalized field name.
 - ${propertyName}: The field name without leading '_', if any.
 - ${fieldType}: The field's type name.
 - ${fieldValue}: The field's initial value, in the form "= <value>", or empty string if none.
 
- Specified by:
 getFieldCodein interfaceReverseCustomizer
 
- 
unmappedTable
public boolean unmappedTable(Table table)
Description copied from interface:ReverseCustomizerNotification that a table has gone unmapped. You can map the table yourself using this method. When mapping, useReverseMappingTool.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 thenClassMapping.addDeclaredFieldMapping(java.lang.String, java.lang.Class)to add field metadata.- Specified by:
 unmappedTablein interfaceReverseCustomizer- Returns:
 - true if you map the table, false otherwise
 
 
- 
close
public void close()
Description copied from interface:ReverseCustomizerInvoked when the customizer is no longer needed.- Specified by:
 closein interfaceCloseable- Specified by:
 closein interfaceReverseCustomizer
 
 - 
 
 -