Interface DBIdentifierUtil
-
- All Superinterfaces:
IdentifierUtil
- All Known Implementing Classes:
DBIdentifierUtilImpl
public interface DBIdentifierUtil extends IdentifierUtil
An interface for DB identifier utility-style operations. This interface extends the basic operations provided by IdentifierUtil with additional operations those specific to DBIdentifiers and identifier conversion.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ANY
static int
COLUMN
static int
SEQUENCE
static int
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DBIdentifier
append(DBIdentifier.DBIdentifierType resultId, DBIdentifier... names)
Appends multiple names together using the appropriate name delimiter.java.lang.String
appendColumns(Column[] columns)
Appends multiple columns names together into comma delimited string.java.lang.String
convertAlias(java.lang.String alias)
Converts a provided alias to a format specified in the configuration.DBIdentifier
convertSchemaCase(DBIdentifier schema)
Converts the name of the specified delimiter to the appropriate case as defined by the configuration.DBIdentifier
fromDBName(java.lang.String name, DBIdentifier.DBIdentifierType id)
Converts the name returned by the database to an identifier of the specified type.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(java.lang.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.java.lang.String
toDBName(java.lang.String name)
Converts the specified string to a format required by the database.java.lang.String
toDBName(java.lang.String name, boolean delimit)
Converts the specified string to a format required by the database, optionally delimiting the name.java.lang.String
toDBName(DBIdentifier name)
Converts the specified identifier to a format required by the database.java.lang.String
toDBName(DBIdentifier name, boolean delimit)
Converts the specified identifier to a format required by the database, optionally delimiting the name.-
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
-
-
-
-
Field Detail
-
ANY
static final int ANY
- See Also:
- Constant Field Values
-
TABLE
static final int TABLE
- See Also:
- Constant Field Values
-
SEQUENCE
static final int SEQUENCE
- See Also:
- Constant Field Values
-
COLUMN
static final int COLUMN
- See Also:
- Constant Field Values
-
-
Method Detail
-
makeIdentifierValid
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. 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.
-
makeNameValid
DBIdentifier makeNameValid(java.lang.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. 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.
-
getValidColumnIdentifier
DBIdentifier getValidColumnIdentifier(DBIdentifier name, Table table, int maxLen, boolean checkForUniqueness)
Returns a valid column name/identifier, based upon the configuration and provided parameters.- Parameters:
name
-table
-maxLen
-checkForUniqueness
-
-
getValidIndexIdentifier
DBIdentifier getValidIndexIdentifier(DBIdentifier name, Table table, int maxLen)
Returns a valid index identifier, based upon the configuration and provided parameters.- Parameters:
name
-table
-maxLen
-checkForUniqueness
-
-
getValidSequenceIdentifier
DBIdentifier getValidSequenceIdentifier(DBIdentifier name, Schema schema, int maxLen)
Returns a valid index identifier, based upon the configuration and provided parameters.- Parameters:
name
-table
-maxLen
-checkForUniqueness
-
-
getValidTableIdentifier
DBIdentifier getValidTableIdentifier(DBIdentifier name, Schema schema, int maxLen)
Returns a valid table identifier, based upon the configuration and provided parameters.- Parameters:
name
-schema
-maxLen
-
-
getValidUniqueIdentifier
DBIdentifier getValidUniqueIdentifier(DBIdentifier name, Table table, int maxLen)
Returns a valid unique constraint identifier, based upon the configuration and provided parameters.- Parameters:
name
-table
-maxLen
-
-
getValidForeignKeyIdentifier
DBIdentifier getValidForeignKeyIdentifier(DBIdentifier name, Table table, Table toTable, int maxLen)
Returns a valid foreign key identifier, based upon the configuration and provided parameters.- Parameters:
name
-table
-toTable
-maxLen
-
-
toDBName
java.lang.String toDBName(DBIdentifier name)
Converts the specified identifier to a format required by the database.- Parameters:
name
-
-
toDBName
java.lang.String toDBName(DBIdentifier name, boolean delimit)
Converts the specified identifier to a format required by the database, optionally delimiting the name.- Parameters:
name
-delimit
-
-
toDBName
java.lang.String toDBName(java.lang.String name)
Converts the specified string to a format required by the database.- Parameters:
name
-
-
toDBName
java.lang.String toDBName(java.lang.String name, boolean delimit)
Converts the specified string to a format required by the database, optionally delimiting the name.- Parameters:
name
-
-
fromDBName
DBIdentifier fromDBName(java.lang.String name, DBIdentifier.DBIdentifierType id)
Converts the name returned by the database to an identifier of the specified type.- Parameters:
name
-
-
appendColumns
java.lang.String appendColumns(Column[] columns)
Appends multiple columns names together into comma delimited string.- Parameters:
columns
-
-
convertSchemaCase
DBIdentifier convertSchemaCase(DBIdentifier schema)
Converts the name of the specified delimiter to the appropriate case as defined by the configuration.- Parameters:
columns
-
-
append
DBIdentifier append(DBIdentifier.DBIdentifierType resultId, DBIdentifier... names)
Appends multiple names together using the appropriate name delimiter.- Parameters:
resultId
-names
-
-
getGeneratedKeySequenceName
DBIdentifier getGeneratedKeySequenceName(Column col, int maxLen)
Returns a generated key sequence identifier for the column.- Parameters:
col
-maxLen
-
-
convertAlias
java.lang.String convertAlias(java.lang.String alias)
Converts a provided alias to a format specified in the configuration.- Parameters:
alias
-
-
-