| java.lang.Object com.versant.core.jdbc.sql.DefaultJdbcNameGenerator
DefaultJdbcNameGenerator | public class DefaultJdbcNameGenerator implements JdbcNameGenerator(Code) | | The standard name generator. This tries to make sure that generated names
will be valid for all databases. This ensures that applications deployed
against different databases maintain the same schema.
|
Method Summary | |
public void | addColumnName(String tableName, String columnName) Add a column name. | protected String | addColumnNameImp(String tableName, String columnName) Add a column name. | public void | addIndexName(String tableName, String indexName) Add an index name. | public void | addPkConstraintName(String tableName, String pkConstraintName) Add the primary key constaint name specified in jdo meta data. | public void | addRefConstraintName(String tableName, String refConstraintName) Add the referential integrity constaint name specified in jdo meta data. | public void | addTableName(String name) Add a table name specified in jdo meta data.
throws: IllegalArgumentException - if the name is invalid(e.g. | protected String | appendInt(String name, int i, int maxLen) Generate a new name comprised of name with i appended. | public String | generateClassIdColumnName(String tableName) Generate and add the name for a classId column. | public String | generateClassTableName(String className) Generate a table name for a persistent class. | public String | generateDatastorePKName(String tableName) Generate and add a name for the primary key column for a PC class using
datastore identity. | public String | generateFieldColumnName(String tableName, String fieldName, boolean primaryKey) Generate and add the name for a field column. | public String | generateIndexName(String tableName, String[] columnNames) Generate and add an index name. | public void | generateLinkTableMainRefNames(String tableName, String[] mainTablePkNames, String[] linkMainRefNames) Generate and add names for the column(s) in a link table that reference
the primary key of the main table. | public String | generateLinkTableName(String tableName, String fieldName, String elementTableName) Generate a table name for a link table (normally used to hold the values
of a collection or array). | public String | generateLinkTableSequenceName(String tableName) Generate and add the name for a the column in a link table that stores
the element sequence number. | public String | generateLinkTableValueName(String tableName, Class valueCls, boolean key) Generate and add the name for a the column in a link table that stores
the value where the value is not a PC class (int, String etc). | public void | generateLinkTableValueRefNames(String tableName, String[] valuePkNames, String valueClassName, String[] linkValueRefNames, boolean key) Generate and add names for the column(s) in a link table that reference
the primary key of the value table. | public String | generatePkConstraintName(String tableName) Generate a name for the primary key constaint for tableName. | public void | generatePolyRefFieldColumnNames(String tableName, String fieldName, String[] columnNames) Generate and add names for one or more columns for a field that is
a polymorphic reference to any other PC class. | public String | generateRefConstraintName(String tableName, String refTableName, String[] fkNames, String[] refPkNames) Generate a name for a referential integrity constaint for tableName. | public void | generateRefFieldColumnNames(String tableName, String fieldName, String[] columnNames, String refTableName, String[] refPkNames, boolean otherRefs) Generate and add names for one or more columns for a field that is
a reference to another PC class. | public String | getClassIdColumnName() | protected String | getColumnNameForFieldName(String fieldName, int i) Generate a column name from a field name and an index. | protected String | getColumnNameForFieldName(String fieldName, int col, int i) Generate a column name from a field name, a column number and an index.
If the index is less then 2 it must be ignored. | protected String | getColumnNameForRefColumn(String base, int i) Generate a column name from a ref column name and an index. | public String | getIndexNamePrefix() | protected String | getJdbcName(String name) Generate a JDBC name from a java class or field name. | public String | getKeyColumnName() | public int | getMaxColumnNameLength() | public int | getMaxConstraintNameLength() | public int | getMaxIndexNameLength() | public int | getMaxTableNameLength() | protected String | getPKNameForTableName(String tableName, int i) Generate a primary key column name from a table name and an index.
If the index is less then 2 it must be ignored. | public String | getPkConstraintPrefix() | public String | getPkSuffix() | public String | getPolyRefClassIdSuffix() | public String | getSequenceColumnName() | public String | getValueColumnName() | public String | getWordBreak() | public boolean | isColumnInTable(String tableName, String columnName) | protected void | populateReservedWords(HashMap rw) Populate rw with all reserved words and their replacements. | public void | removeTableName(String name) Remove all information about table. | public void | setClassIdColumnName(String classIdColumnName) Set the name used for classId columns. | public void | setDatabaseType(String db) This is called immediately after the name generator has been constructed
to indicate which database is in use. | public void | setIndexNamePrefix(String indexNamePrefix) Set the prefix used to generate index names. | public void | setKeyColumnName(String keyColumnName) Set the name used for keys columns in link tables for maps where the
keys are not references to PC instances. | public void | setMaxColumnNameLength(int maxColumnNameLength) Set the max length in characters for a column name. | public void | setMaxConstraintNameLength(int maxConstraintNameLength) Set the max length in characters for a constraint name. | public void | setMaxIndexNameLength(int maxIndexNameLength) Set the max length in characters for an index name. | public void | setMaxTableNameLength(int maxTableNameLength) Set the max length in characters for a table name. | public void | setPkConstraintPrefix(String pkConstraintPrefix) Set the prefix added to a table name to generate its primary key
constraint name. | public void | setPkSuffix(String pkSuffix) Set the suffix added to table or field names to name primary key
columns. | public void | setPolyRefClassIdSuffix(String polyRefClassIdSuffix) | public void | setSequenceColumnName(String sequenceColumnName) Set the name used for sequence columns in link tables. | public void | setValueColumnName(String valueColumnName) Set the name used for value columns in link tables where the values
are not references to PC instances. | public void | setWordBreak(String wordBreak) Set the string used to break 'words' when generating names from
field and class names and so on. | protected String | shrinkName(String name, int maxlen) Shrink the supplied name to maxlen chars if it is longer than maxlen. |
constraintNames | protected HashSet constraintNames(Code) | | All the constraint names we know about.
|
indexNames | protected HashSet indexNames(Code) | | All the index names we know about.
|
maxColumnNameLength | protected int maxColumnNameLength(Code) | | |
maxConstraintNameLength | protected int maxConstraintNameLength(Code) | | |
maxIndexNameLength | protected int maxIndexNameLength(Code) | | |
maxTableNameLength | protected int maxTableNameLength(Code) | | |
polyRefClassIdSuffix | protected String polyRefClassIdSuffix(Code) | | |
refConstraintPrefix | protected String refConstraintPrefix(Code) | | |
tableMap | protected HashMap tableMap(Code) | | This maps a table name to a HashSet of its column names.
|
DefaultJdbcNameGenerator | public DefaultJdbcNameGenerator()(Code) | | |
addColumnNameImp | protected String addColumnNameImp(String tableName, String columnName)(Code) | | Add a column name. The tableName will have already been added.
null if ok or error message |
addIndexName | public void addIndexName(String tableName, String indexName)(Code) | | Add an index name. The tableName will have already been added.
|
appendInt | protected String appendInt(String name, int i, int maxLen)(Code) | | Generate a new name comprised of name with i appended. Characters are
stripped from the end of name to make space for i if maxLen would
be exceeded. This is used to resolve generated name clashes.
|
generateDatastorePKName | public String generateDatastorePKName(String tableName)(Code) | | Generate and add a name for the primary key column for a PC class using
datastore identity.
|
generateFieldColumnName | public String generateFieldColumnName(String tableName, String fieldName, boolean primaryKey)(Code) | | Generate and add the name for a field column.
|
generateLinkTableMainRefNames | public void generateLinkTableMainRefNames(String tableName, String[] mainTablePkNames, String[] linkMainRefNames)(Code) | | Generate and add names for the column(s) in a link table that reference
the primary key of the main table. Some of the columns may already
have names which must be kept (no need to add them).
Parameters: tableName - The link table Parameters: mainTablePkNames - The names of the main table primary key Parameters: linkMainRefNames - The corresponding column names in the link table |
generateLinkTableName | public String generateLinkTableName(String tableName, String fieldName, String elementTableName)(Code) | | Generate a table name for a link table (normally used to hold the values
of a collection or array). The name generator must 'add' it.
Parameters: tableName - The table on the 1 side of the the link Parameters: fieldName - The field the link table is for Parameters: elementTableName - The table on the n side of the link or null ifnone (e.g. a link table for a collection of String's) See Also: DefaultJdbcNameGenerator.addTableName |
generateLinkTableSequenceName | public String generateLinkTableSequenceName(String tableName)(Code) | | Generate and add the name for a the column in a link table that stores
the element sequence number.
|
generateLinkTableValueName | public String generateLinkTableValueName(String tableName, Class valueCls, boolean key)(Code) | | Generate and add the name for a the column in a link table that stores
the value where the value is not a PC class (int, String etc).
Parameters: tableName - The link table Parameters: valueCls - The value class Parameters: key - Is this a key in a link table for a map? |
generateLinkTableValueRefNames | public void generateLinkTableValueRefNames(String tableName, String[] valuePkNames, String valueClassName, String[] linkValueRefNames, boolean key)(Code) | | Generate and add names for the column(s) in a link table that reference
the primary key of the value table. This is called for collections of
PC classes. Some of the columns may already have names which must be
kept (no need to add them).
Parameters: tableName - The link table Parameters: valuePkNames - The names of the value table primary key (may benull if the value class is not stored in JDBC) Parameters: valueClassName - The name of the value class Parameters: linkValueRefNames - The corresponding column names in the link table |
generatePkConstraintName | public String generatePkConstraintName(String tableName)(Code) | | Generate a name for the primary key constaint for tableName.
|
generatePolyRefFieldColumnNames | public void generatePolyRefFieldColumnNames(String tableName, String fieldName, String[] columnNames) throws IllegalArgumentException(Code) | | Generate and add names for one or more columns for a field that is
a polymorphic reference to any other PC class. Some of the columns may
already have names.
Parameters: columnNames - Store the column names here (some may already havenames if specified in the .jdo meta data). The class-id columnis at index 0. throws: IllegalArgumentException - if any existing names are invalid |
generateRefConstraintName | public String generateRefConstraintName(String tableName, String refTableName, String[] fkNames, String[] refPkNames)(Code) | | Generate a name for a referential integrity constaint for tableName.
The name generator must add it.
Parameters: tableName - The table with the constraint Parameters: refTableName - The table being referenced Parameters: fkNames - The names of the foreign keys in tableName Parameters: refPkNames - The names of the primary key of refTableName See Also: DefaultJdbcNameGenerator.addRefConstraintName |
generateRefFieldColumnNames | public void generateRefFieldColumnNames(String tableName, String fieldName, String[] columnNames, String refTableName, String[] refPkNames, boolean otherRefs)(Code) | | Generate and add names for one or more columns for a field that is
a reference to another PC class. Some of the columns may already have
names.
Parameters: columnNames - Store the column names here (some may already havenames if specified in the .jdo meta data) Parameters: refTableName - The table being referenced (null if not a JDBC class) Parameters: refPkNames - The names of the primary key columns of refTableName Parameters: otherRefs - Are there other field referencing the same class here? throws: IllegalArgumentException - if any existing names are invalid |
getClassIdColumnName | public String getClassIdColumnName()(Code) | | |
getColumnNameForFieldName | protected String getColumnNameForFieldName(String fieldName, int i)(Code) | | Generate a column name from a field name and an index. If the index
is less then 2 it must be ignored. Otherwise it must be used in the
generated name. This is used to resolve name clashes. The returned
name must not exceed maxColumnNameLength.
|
getColumnNameForFieldName | protected String getColumnNameForFieldName(String fieldName, int col, int i)(Code) | | Generate a column name from a field name, a column number and an index.
If the index is less then 2 it must be ignored. Otherwise it must be
used in the generated name. This is used to resolve name clashes. The
columnNumber must also be used in the name. The returned name must not
exceed maxColumnNameLength. This is used for fields comprising of
multiple columns.
|
getColumnNameForRefColumn | protected String getColumnNameForRefColumn(String base, int i)(Code) | | Generate a column name from a ref column name and an index. If the
index is less then 2 it must be ignored. Otherwise it must be used in
the generated name. This is used to resolve name clashes. The returned
name must not exceed maxColumnNameLength.
|
getJdbcName | protected String getJdbcName(String name)(Code) | | Generate a JDBC name from a java class or field name. This breaks
the name at each capital inserting underscores and converts to
lower case. If the name turns out to be a reserved word it is replaced.
Any leading underscores are removed.
'$' are also removed.
|
getMaxColumnNameLength | public int getMaxColumnNameLength()(Code) | | |
getMaxConstraintNameLength | public int getMaxConstraintNameLength()(Code) | | |
getMaxIndexNameLength | public int getMaxIndexNameLength()(Code) | | |
getMaxTableNameLength | public int getMaxTableNameLength()(Code) | | |
getPKNameForTableName | protected String getPKNameForTableName(String tableName, int i)(Code) | | Generate a primary key column name from a table name and an index.
If the index is less then 2 it must be ignored. Otherwise it must
be used in the generated name. This is used to resolve name clashes.
The returned name must not exceed maxColumnNameLength.
|
getPkConstraintPrefix | public String getPkConstraintPrefix()(Code) | | |
getPolyRefClassIdSuffix | public String getPolyRefClassIdSuffix()(Code) | | |
getSequenceColumnName | public String getSequenceColumnName()(Code) | | |
isColumnInTable | public boolean isColumnInTable(String tableName, String columnName)(Code) | | Does the table contain the column?
|
populateReservedWords | protected void populateReservedWords(HashMap rw)(Code) | | Populate rw with all reserved words and their replacements.
Any identifiers that match a reserved word will be replaced.
All keys must be lower case.
|
removeTableName | public void removeTableName(String name)(Code) | | Remove all information about table.
|
setClassIdColumnName | public void setClassIdColumnName(String classIdColumnName)(Code) | | Set the name used for classId columns. These are added to the table for
the base class in an inheritance heirachy.
|
setDatabaseType | public void setDatabaseType(String db)(Code) | | This is called immediately after the name generator has been constructed
to indicate which database is in use.
|
setIndexNamePrefix | public void setIndexNamePrefix(String indexNamePrefix)(Code) | | Set the prefix used to generate index names.
|
setKeyColumnName | public void setKeyColumnName(String keyColumnName)(Code) | | Set the name used for keys columns in link tables for maps where the
keys are not references to PC instances.
|
setMaxColumnNameLength | public void setMaxColumnNameLength(int maxColumnNameLength)(Code) | | Set the max length in characters for a column name.
|
setMaxConstraintNameLength | public void setMaxConstraintNameLength(int maxConstraintNameLength)(Code) | | Set the max length in characters for a constraint name.
|
setMaxIndexNameLength | public void setMaxIndexNameLength(int maxIndexNameLength)(Code) | | Set the max length in characters for an index name.
|
setMaxTableNameLength | public void setMaxTableNameLength(int maxTableNameLength)(Code) | | Set the max length in characters for a table name.
|
setPkConstraintPrefix | public void setPkConstraintPrefix(String pkConstraintPrefix)(Code) | | Set the prefix added to a table name to generate its primary key
constraint name.
|
setPkSuffix | public void setPkSuffix(String pkSuffix)(Code) | | Set the suffix added to table or field names to name primary key
columns. The default is _id so the pk for the employee table will
be employee_id.
|
setPolyRefClassIdSuffix | public void setPolyRefClassIdSuffix(String polyRefClassIdSuffix)(Code) | | |
setSequenceColumnName | public void setSequenceColumnName(String sequenceColumnName)(Code) | | Set the name used for sequence columns in link tables. These are used
to preserve the order of elements in ordered collections (lists and
arrays).
|
setValueColumnName | public void setValueColumnName(String valueColumnName)(Code) | | Set the name used for value columns in link tables where the values
are not references to PC instances.
|
setWordBreak | public void setWordBreak(String wordBreak)(Code) | | Set the string used to break 'words' when generating names from
field and class names and so on.
|
shrinkName | protected String shrinkName(String name, int maxlen)(Code) | | Shrink the supplied name to maxlen chars if it is longer than maxlen.
This implementation removes vowels first and then truncates if it has
to.
|
|
|