com.avaje.ebean.config
Class UnderscoreNamingConvention

java.lang.Object
  extended by com.avaje.ebean.config.AbstractNamingConvention
      extended by com.avaje.ebean.config.UnderscoreNamingConvention
All Implemented Interfaces:
NamingConvention

public class UnderscoreNamingConvention
extends AbstractNamingConvention

Converts between Camel Case and Underscore based names for both table and column names (and is the default naming convention in Ebean).

Author:
emcgreal, rbygrave

Field Summary
 
Fields inherited from class com.avaje.ebean.config.AbstractNamingConvention
DEFAULT_SEQ_FORMAT
 
Constructor Summary
UnderscoreNamingConvention()
          Create with a sequence format of "{table}_seq".
UnderscoreNamingConvention(String sequenceFormat)
          Create with a given sequence format.
 
Method Summary
 String getColumnFromProperty(Class<?> beanClass, String propertyName)
          Converts Camel case property name to underscore based column name.
 String getPropertyFromColumn(Class<?> beanClass, String dbColumnName)
          Converts underscore based column name to Camel case property name.
 TableName getTableNameByConvention(Class<?> beanClass)
          Returns the last part of the class name.
 boolean isDigitsCompressed()
          Returns true if digits are compressed.
 boolean isForceUpperCase()
          Return true if the result will be upper case.
 void setDigitsCompressed(boolean digitsCompressed)
          Sets to true for digits to be compressed (without a leading underscore).
 void setForceUpperCase(boolean forceUpperCase)
          Set to true to make the result upper case.
 
Methods inherited from class com.avaje.ebean.config.AbstractNamingConvention
getCatalog, getM2MJoinTableName, getSchema, getSequenceFormat, getSequenceName, getTableName, isUseForeignKeyPrefix, setCatalog, setDatabasePlatform, setSchema, setSequenceFormat, setUseForeignKeyPrefix
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnderscoreNamingConvention

public UnderscoreNamingConvention(String sequenceFormat)
Create with a given sequence format.

Parameters:
sequenceFormat - the sequence format

UnderscoreNamingConvention

public UnderscoreNamingConvention()
Create with a sequence format of "{table}_seq".

Method Detail

getTableNameByConvention

public TableName getTableNameByConvention(Class<?> beanClass)
Returns the last part of the class name.

Parameters:
beanClass - the bean class
Returns:
the table name from class

getColumnFromProperty

public String getColumnFromProperty(Class<?> beanClass,
                                    String propertyName)
Converts Camel case property name to underscore based column name.

Returns:
the column from property

getPropertyFromColumn

public String getPropertyFromColumn(Class<?> beanClass,
                                    String dbColumnName)
Converts underscore based column name to Camel case property name.

Parameters:
beanClass - the bean class
dbColumnName - the db column name
Returns:
the property from column

isForceUpperCase

public boolean isForceUpperCase()
Return true if the result will be upper case.

False if it will be lower case.


setForceUpperCase

public void setForceUpperCase(boolean forceUpperCase)
Set to true to make the result upper case.


isDigitsCompressed

public boolean isDigitsCompressed()
Returns true if digits are compressed.


setDigitsCompressed

public void setDigitsCompressed(boolean digitsCompressed)
Sets to true for digits to be compressed (without a leading underscore).



Copyright © 2010. All Rights Reserved.