|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.java.ao.schema.AbstractTableNameConverter
net.java.ao.schema.UnderscoreTableNameConverter
public class UnderscoreTableNameConverter
Imposes an underscore word-separation convention on table names. This will convert entity names in the following way:
Entity Name | Table Name |
Person |
person |
LicenseRegistration |
license_registration |
Volume4 |
volume_4 |
Company |
company |
This converter allows for both all-lowercase and all-uppercase
table name conventions. For example, depending on the configuration,
LicenseRegistration
may convert to "LICENSE_REGISTRATION".
This converter, coupled with PluralizedNameConverter
is
all that is required to emulate the ActiveRecord table name conversion.
Constructor Summary | |
---|---|
UnderscoreTableNameConverter(boolean uppercase)
Creates a new table name converter in which all table names will be either fully uppercase or fully lowercase. |
Method Summary | |
---|---|
protected String |
convertName(Class<? extends RawEntity<?>> entity)
Performs the actual operation of converting a class type into a proper table name. |
boolean |
isUppercase()
Returns whether or not resulting table names will be entirely uppercase. |
protected String |
postProcessName(String back)
Performs second-step post-processing on converted names. |
Methods inherited from class net.java.ao.schema.AbstractTableNameConverter |
---|
addClassMapping, addClassMappings, addPatternMapping, addPatternMappings, getName, processName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnderscoreTableNameConverter(boolean uppercase)
uppercase
- true
if table names should be all
uppercase, false
if table names should be all
lowercase.Method Detail |
---|
public boolean isUppercase()
false
, table names will be entirely
lowercase.
protected String convertName(Class<? extends RawEntity<?>> entity)
AbstractTableNameConverter
Performs the actual operation of converting a class type into a proper
table name. This method need not concern itself with particulars of
@Table
annotations or pattern mappings. All of these
things are handled in the AbstractTableNameConverter.getName(Class)
method in the
superclass implementation.
This method must run as fast as possible and should be thread-safe. If
necessary, caching may be employed, but it is also within scope for such
caching to be utilized within the superclass. As such, the implementation
of this method should be kept extremely simple. Also note that this method
may not be called for every entity type which must be converted
(due to mappings, @Table
overrides, etc).
convertName
in class AbstractTableNameConverter
entity
- The entity type which must be converted.
protected String postProcessName(String back)
AbstractTableNameConverter
Performs second-step post-processing on converted names. This method is
called to perform last-stage conventions enforcement prior to utilization
of the table name. This allows implementations to impose sweeping
conventions such as "all table names should be uppercase" and so on. Any
minor or name-specific conventions should be enforced within the AbstractTableNameConverter.processName(String)
method.
The main reason for this method's existence is actually to allow for
table name pluralizing on conversions imposing odd conventions, such as
all uppercase or all lowercase. This method should be invoked as the
last step of any table name conversion (with the exception of class
mappings and @Table
annotations) to allow for extremely
broad-brush changes. The default implementation simply returns the passed
name.
postProcessName
in class AbstractTableNameConverter
back
- The generated table name which should be processed to suit
large-scale conventions.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |