org.apache.openjpa.jdbc.identifier
Class DBIdentifierUtilImpl

java.lang.Object
  extended by org.apache.openjpa.lib.identifier.IdentifierUtilImpl
      extended by org.apache.openjpa.jdbc.identifier.DBIdentifierUtilImpl
All Implemented Interfaces:
DBIdentifierUtil, Configurable, IdentifierUtil

public class DBIdentifierUtilImpl
extends IdentifierUtilImpl
implements DBIdentifierUtil, Configurable


Field Summary
 
Fields inherited from interface org.apache.openjpa.jdbc.identifier.DBIdentifierUtil
ANY, COLUMN, SEQUENCE, TABLE
 
Fields inherited from interface org.apache.openjpa.lib.identifier.IdentifierUtil
BAR, CASE_LOWER, CASE_PRESERVE, CASE_UPPER, DOLLAR_CHAR, DOT, DOUBLE_QUOTE, EMPTY, PERCENT, SPACE, UNDERSCORE, UNDERSCORE_CHAR
 
Constructor Summary
DBIdentifierUtilImpl()
           
DBIdentifierUtilImpl(IdentifierConfiguration config)
           
 
Method Summary
 DBIdentifier append(DBIdentifier.DBIdentifierType resultId, DBIdentifier... names)
          Appends multiple names together using the appropriate name delimiter.
 String appendColumns(Column[] columns)
          Appends multiple columns names together into comma delimited string.
 String convertAlias(String alias)
          Converts a column alias to use the appropriate delimiters
 DBIdentifier convertSchemaCase(DBIdentifier name)
          Convert the specified schema name to a name that the database will be able to understand in metadata operations.
 String delimit(DBIdentifier name, boolean force)
           
 DBIdentifier fromDBName(String name, DBIdentifier.DBIdentifierType id)
          Creates a new identifier of a given type based upon the name returned from the database.
 JDBCConfiguration getConfiguration()
          System configuration.
 DBIdentifier getGeneratedKeySequenceName(Column col, int maxLen)
          Returns a generated key sequence identifier for the column.
 DBIdentifier getValidColumnIdentifier(DBIdentifier name, Table table, int maxLen, boolean checkForUniqueness)
          Returns a valid column name/identifier, based upon the configuration and provided parameters.
 DBIdentifier getValidForeignKeyIdentifier(DBIdentifier name, Table table, Table toTable, int maxLen)
          Returns a valid foreign key identifier, based upon the configuration and provided parameters.
 DBIdentifier getValidIndexIdentifier(DBIdentifier name, Table table, int maxLen)
          Returns a valid index identifier, based upon the configuration and provided parameters.
 DBIdentifier getValidSequenceIdentifier(DBIdentifier name, Schema schema, int maxLen)
          Returns a valid index identifier, based upon the configuration and provided parameters.
 DBIdentifier getValidTableIdentifier(DBIdentifier name, Schema schema, int maxLen)
          Returns a valid table identifier, based upon the configuration and provided parameters.
 DBIdentifier getValidUniqueIdentifier(DBIdentifier name, Table table, int maxLen)
          Returns a valid unique constraint identifier, based upon the configuration and provided parameters.
 DBIdentifier makeIdentifierValid(DBIdentifier sname, NameSet set, int maxLen, boolean checkForUniqueness)
          Shortens the given name to the given maximum length, then checks that it is not a reserved word.
 DBIdentifier makeNameValid(String name, NameSet set, int maxLen, int nameType, boolean checkForUniqueness)
          Shortens the given name to the given maximum length, then checks that it is not a reserved word.
 void setConfiguration(Configuration conf)
          Invoked prior to setting bean properties.
 String shorten(String name, int targetLength)
           
 String toDBName(DBIdentifier name)
          Converts the name to a name which can be used within a SQL statement.
 String toDBName(DBIdentifier name, boolean delimit)
          Converts the name to a name which can be used within a SQL statement.
 String toDBName(String name)
          Converts the identifier to a format appropriate for the configuration.
 String toDBName(String name, boolean delimit)
          Converts the identifier to a format appropriate for the configuration using the default naming rule.
 
Methods inherited from class org.apache.openjpa.lib.identifier.IdentifierUtilImpl
appendNames, appendNames, canSplit, canSplit, canSplit, canSplit, combineFull, combineNames, combineNames, combineNames, combineNames, combineNames, combineNames, combineNames, combineNames, combineNames, combineNames, convert, convertFull, delimit, delimit, delimit, delimit, delimit, delimit, endConfiguration, getIdentifierConfiguration, isDelimited, isDelimited, isDelimited, isDoubleQuoted, isReservedWord, isReservedWord, joinNames, joinNames, joinNames, joinNames, joinNames, joinNames, joinNames, needsConversion, removeDelimiters, removeDelimiters, removeDelimiters, removeDelimiters, removeDelimiters, removeHungarianNotation, removeHungarianNotation, requiresDelimiters, requiresDelimiters, requiresDelimiters, setIdentifierConfiguration, splitName, splitName, splitName, splitName, splitName, splitName, startConfiguration, truncateName, truncateName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.lib.identifier.IdentifierUtil
appendNames, appendNames, canSplit, canSplit, canSplit, canSplit, combineNames, combineNames, combineNames, combineNames, combineNames, combineNames, convert, convertFull, delimit, delimit, delimit, delimit, getIdentifierConfiguration, isDelimited, isDelimited, isReservedWord, isReservedWord, joinNames, joinNames, joinNames, joinNames, joinNames, joinNames, removeDelimiters, removeDelimiters, removeDelimiters, removeHungarianNotation, removeHungarianNotation, requiresDelimiters, requiresDelimiters, setIdentifierConfiguration, splitName, splitName, splitName, splitName, truncateName, truncateName
 
Methods inherited from interface org.apache.openjpa.lib.conf.Configurable
endConfiguration, startConfiguration
 

Constructor Detail

DBIdentifierUtilImpl

public DBIdentifierUtilImpl()

DBIdentifierUtilImpl

public DBIdentifierUtilImpl(IdentifierConfiguration config)
Method Detail

getValidColumnIdentifier

public DBIdentifier getValidColumnIdentifier(DBIdentifier name,
                                             Table table,
                                             int maxLen,
                                             boolean checkForUniqueness)
Description copied from interface: DBIdentifierUtil
Returns a valid column name/identifier, based upon the configuration and provided parameters.

Specified by:
getValidColumnIdentifier in interface DBIdentifierUtil
Returns:

getValidForeignKeyIdentifier

public DBIdentifier getValidForeignKeyIdentifier(DBIdentifier name,
                                                 Table table,
                                                 Table toTable,
                                                 int maxLen)
Description copied from interface: DBIdentifierUtil
Returns a valid foreign key identifier, based upon the configuration and provided parameters.

Specified by:
getValidForeignKeyIdentifier in interface DBIdentifierUtil
Returns:

getValidUniqueIdentifier

public DBIdentifier getValidUniqueIdentifier(DBIdentifier name,
                                             Table table,
                                             int maxLen)
Description copied from interface: DBIdentifierUtil
Returns a valid unique constraint identifier, based upon the configuration and provided parameters.

Specified by:
getValidUniqueIdentifier in interface DBIdentifierUtil
Returns:

getValidIndexIdentifier

public DBIdentifier getValidIndexIdentifier(DBIdentifier name,
                                            Table table,
                                            int maxLen)
Description copied from interface: DBIdentifierUtil
Returns a valid index identifier, based upon the configuration and provided parameters.

Specified by:
getValidIndexIdentifier in interface DBIdentifierUtil
Returns:

getValidSequenceIdentifier

public DBIdentifier getValidSequenceIdentifier(DBIdentifier name,
                                               Schema schema,
                                               int maxLen)
Description copied from interface: DBIdentifierUtil
Returns a valid index identifier, based upon the configuration and provided parameters.

Specified by:
getValidSequenceIdentifier in interface DBIdentifierUtil
Returns:

getValidTableIdentifier

public DBIdentifier getValidTableIdentifier(DBIdentifier name,
                                            Schema schema,
                                            int maxLen)
Description copied from interface: DBIdentifierUtil
Returns a valid table identifier, based upon the configuration and provided parameters.

Specified by:
getValidTableIdentifier in interface DBIdentifierUtil
Returns:

makeNameValid

public DBIdentifier makeNameValid(String name,
                                  NameSet set,
                                  int maxLen,
                                  int nameType,
                                  boolean checkForUniqueness)
Description copied from interface: DBIdentifierUtil
Shortens the given name to the given maximum length, then checks that it is not a reserved word. If it is reserved, appends a "0". If the name conflicts with an existing schema component and uniqueness checking is enabled, the last character is replace with '0', then '1', etc. Note that the given max len may be 0 if the database metadata is incomplete. Note: If the name is delimited, make sure the ending delimiter is not stripped off.

Specified by:
makeNameValid in interface DBIdentifierUtil

makeIdentifierValid

public DBIdentifier makeIdentifierValid(DBIdentifier sname,
                                        NameSet set,
                                        int maxLen,
                                        boolean checkForUniqueness)
Description copied from interface: DBIdentifierUtil
Shortens the given name to the given maximum length, then checks that it is not a reserved word. If it is reserved, appends a "0". If the name conflicts with an existing schema component and uniqueness checking is enabled, the last character is replace with '0', then '1', etc. Note that the given max len may be 0 if the database metadata is incomplete. Note: If the name is delimited, make sure the ending delimiter is not stripped off.

Specified by:
makeIdentifierValid in interface DBIdentifierUtil

toDBName

public String toDBName(DBIdentifier name)
Converts the name to a name which can be used within a SQL statement. Uses the appropriate delimiters and separators.

Specified by:
toDBName in interface DBIdentifierUtil
Returns:

toDBName

public String toDBName(DBIdentifier name,
                       boolean delimit)
Converts the name to a name which can be used within a SQL statement. Uses the appropriate delimiters and separators.

Specified by:
toDBName in interface DBIdentifierUtil
Parameters:
delimit - If true, allows the name to be delimited, if necessary. Otherwise, the identifier is not delimited.
Returns:

toDBName

public String toDBName(String name)
Converts the identifier to a format appropriate for the configuration. Delimits if necessary

Specified by:
toDBName in interface DBIdentifierUtil
Returns:

toDBName

public String toDBName(String name,
                       boolean delimit)
Converts the identifier to a format appropriate for the configuration using the default naming rule.

Specified by:
toDBName in interface DBIdentifierUtil
Parameters:
delimit - If false, do not delimit. Otherwise, delimit if necessary.
Returns:

fromDBName

public DBIdentifier fromDBName(String name,
                               DBIdentifier.DBIdentifierType id)
Creates a new identifier of a given type based upon the name returned from the database.

Specified by:
fromDBName in interface DBIdentifierUtil
Returns:

append

public DBIdentifier append(DBIdentifier.DBIdentifierType resultId,
                           DBIdentifier... names)
Description copied from interface: DBIdentifierUtil
Appends multiple names together using the appropriate name delimiter.

Specified by:
append in interface DBIdentifierUtil
Returns:

appendColumns

public String appendColumns(Column[] columns)
Description copied from interface: DBIdentifierUtil
Appends multiple columns names together into comma delimited string.

Specified by:
appendColumns in interface DBIdentifierUtil
Returns:

delimit

public String delimit(DBIdentifier name,
                      boolean force)

shorten

public String shorten(String name,
                      int targetLength)

getGeneratedKeySequenceName

public DBIdentifier getGeneratedKeySequenceName(Column col,
                                                int maxLen)
Description copied from interface: DBIdentifierUtil
Returns a generated key sequence identifier for the column.

Specified by:
getGeneratedKeySequenceName in interface DBIdentifierUtil
Returns:

convertSchemaCase

public DBIdentifier convertSchemaCase(DBIdentifier name)
Convert the specified schema name to a name that the database will be able to understand in metadata operations.

Specified by:
convertSchemaCase in interface DBIdentifierUtil
Returns:

convertAlias

public String convertAlias(String alias)
Converts a column alias to use the appropriate delimiters

Specified by:
convertAlias in interface DBIdentifierUtil
Returns:

getConfiguration

public JDBCConfiguration getConfiguration()
System configuration.


setConfiguration

public void setConfiguration(Configuration conf)
Description copied from interface: Configurable
Invoked prior to setting bean properties.

Specified by:
setConfiguration in interface Configurable
Overrides:
setConfiguration in class IdentifierUtilImpl


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.