Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.java.ao.schema
Class UnderscoreFieldNameConverter

    java.lang.Object
      net.java.ao.schema.AbstractFieldNameConverter
          net.java.ao.schema.UnderscoreFieldNameConverter

All Implemented Interfaces:
  FieldNameConverter

    public class UnderscoreFieldNameConverter

extends AbstractFieldNameConverter

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.

Author:
  Daniel Spiewak

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

### UnderscoreFieldNameConverter

    public UnderscoreFieldNameConverter(boolean uppercase)

  Creates a new field name converter in which all field names will be either fully uppercase or fully lowercase.

  Parameters:
    `uppercase` - `true` if field names should be all uppercase, `false` if field names should be all lowercase.

Method Detail

### isUppercase

    public boolean isUppercase()

  Returns whether or not resulting field names will be entirely uppercase. If `false`, field names will be entirely lowercase.

### convertName

    protected String convertName(String name,
                                 boolean entity,
                                 boolean polyType)

  Description copied from class: `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.

  Specified by:
    `convertName` in class `AbstractFieldNameConverter`
  Parameters:
    `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.
  Returns:
    A valid database field name which uniquely corresponds to the method name in question. Should never return `null`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007-2011. All Rights Reserved.