|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.java.ao.schema.AbstractFieldNameConverter
net.java.ao.schema.UnderscoreFieldNameConverter
public class UnderscoreFieldNameConverter
Imposes an underscore word-separation convention upon field names. This will convert field in the following way:
Method Name | Returns Entity? | Field Name |
getFirstName | false |
first_name |
setLastName | false |
last_name |
getCompany | true |
company_id |
isCool | false |
cool |
This converter allows for both all-lowercase and all-uppercase
field name conventions. For example, depending on the configuration,
getLastName
may convert to "LAST_NAME".
This converter is all that is required to emulate the ActiveRecord field name conversion.
Constructor Summary | |
---|---|
UnderscoreFieldNameConverter(boolean uppercase)
Creates a new field name converter in which all field names will be either fully uppercase or fully lowercase. |
Method Summary | |
---|---|
protected String |
convertName(String name,
boolean entity,
boolean polyType)
Performs the actual conversion logic between a method name (or, more normally a trimmed method name) and the corresponding database field identifier. |
boolean |
isUppercase()
Returns whether or not resulting field names will be entirely uppercase. |
Methods inherited from class net.java.ao.schema.AbstractFieldNameConverter |
---|
getName, getPolyTypeName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UnderscoreFieldNameConverter(boolean uppercase)
uppercase
- true
if field names should be all
uppercase, false
if field names should be all
lowercase.Method Detail |
---|
public boolean isUppercase()
false
, field names will be entirely
lowercase.
protected String convertName(String name, boolean entity, boolean polyType)
AbstractFieldNameConverter
Performs the actual conversion logic between a method name (or, more normally
a trimmed method name) and the corresponding database field identifier. This
method may impose conventions such as camelCase, all-lowercase with underscores
and so on. There is no need for this method to concern itself with method
prefixes such as get, set or is. All of these should be handled within the
AbstractFieldNameConverter.getName(Method)
method.
Some examples of input and their corresponding return values for this method
(assuming the CamelCaseFieldNameConverter
is in use):
Actual Method Name | Param: name | Param: entity | Param: polyType | Return Value |
getFirstName | FirstName | false |
false |
firstName |
getCompany | Company | true |
false |
companyID |
getCompany | Company | true |
true |
companyType |
isCool | Cool | false |
false |
cool |
setLastName | LastName | false |
false |
lastName |
The implementation of this method must execute extremely quickly and be totally thread-safe (stateless if possible). This is because this method will be called many times for some operations. A slow algorithm here will dramaticly affect the execution time of basic tasks.
convertName
in class AbstractFieldNameConverter
name
- The (often trimmed) method name for which a field name is reqiured.entity
- Indicates whether or not the method in question returns an
entity value.polyType
- Indicates whether or not the field in question is a polymorphic
type flagging field.
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |