Java Doc for DefaultJdbcNameGenerator.java in  » Testing » PolePosition-0.20 » com » versant » core » jdbc » sql » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » PolePosition 0.20 » com.versant.core.jdbc.sql 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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.


Field Summary
protected  StringclassIdColumnName
    
protected  HashSetconstraintNames
     All the constraint names we know about.
protected  StringdatabaseType
    
protected  StringindexNamePrefix
    
protected  HashSetindexNames
     All the index names we know about.
protected  StringkeyColumnName
    
protected  intmaxColumnNameLength
    
protected  intmaxConstraintNameLength
    
protected  intmaxIndexNameLength
    
protected  intmaxTableNameLength
    
protected  StringpkConstraintPrefix
    
protected  StringpkSuffix
    
protected  StringpolyRefClassIdSuffix
    
protected  StringrefConstraintPrefix
    
protected  HashMapreservedWords
    
protected  StringsequenceColumnName
    
protected  HashMaptableMap
     This maps a table name to a HashSet of its column names.
protected  StringvalueColumnName
    
protected  StringwordBreak
    

Constructor Summary
public  DefaultJdbcNameGenerator()
    

Method Summary
public  voidaddColumnName(String tableName, String columnName)
     Add a column name.
protected  StringaddColumnNameImp(String tableName, String columnName)
     Add a column name.
public  voidaddIndexName(String tableName, String indexName)
     Add an index name.
public  voidaddPkConstraintName(String tableName, String pkConstraintName)
     Add the primary key constaint name specified in jdo meta data.
public  voidaddRefConstraintName(String tableName, String refConstraintName)
     Add the referential integrity constaint name specified in jdo meta data.
public  voidaddTableName(String name)
     Add a table name specified in jdo meta data.
throws:
  IllegalArgumentException - if the name is invalid(e.g.
protected  StringappendInt(String name, int i, int maxLen)
     Generate a new name comprised of name with i appended.
public  StringgenerateClassIdColumnName(String tableName)
     Generate and add the name for a classId column.
public  StringgenerateClassTableName(String className)
     Generate a table name for a persistent class.
public  StringgenerateDatastorePKName(String tableName)
     Generate and add a name for the primary key column for a PC class using datastore identity.
public  StringgenerateFieldColumnName(String tableName, String fieldName, boolean primaryKey)
     Generate and add the name for a field column.
public  StringgenerateIndexName(String tableName, String[] columnNames)
     Generate and add an index name.
public  voidgenerateLinkTableMainRefNames(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  StringgenerateLinkTableName(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  StringgenerateLinkTableSequenceName(String tableName)
     Generate and add the name for a the column in a link table that stores the element sequence number.
public  StringgenerateLinkTableValueName(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  voidgenerateLinkTableValueRefNames(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  StringgeneratePkConstraintName(String tableName)
     Generate a name for the primary key constaint for tableName.
public  voidgeneratePolyRefFieldColumnNames(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  StringgenerateRefConstraintName(String tableName, String refTableName, String[] fkNames, String[] refPkNames)
     Generate a name for a referential integrity constaint for tableName.
public  voidgenerateRefFieldColumnNames(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  StringgetClassIdColumnName()
    
protected  StringgetColumnNameForFieldName(String fieldName, int i)
     Generate a column name from a field name and an index.
protected  StringgetColumnNameForFieldName(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  StringgetColumnNameForRefColumn(String base, int i)
     Generate a column name from a ref column name and an index.
public  StringgetIndexNamePrefix()
    
protected  StringgetJdbcName(String name)
     Generate a JDBC name from a java class or field name.
public  StringgetKeyColumnName()
    
public  intgetMaxColumnNameLength()
    
public  intgetMaxConstraintNameLength()
    
public  intgetMaxIndexNameLength()
    
public  intgetMaxTableNameLength()
    
protected  StringgetPKNameForTableName(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  StringgetPkConstraintPrefix()
    
public  StringgetPkSuffix()
    
public  StringgetPolyRefClassIdSuffix()
    
public  StringgetSequenceColumnName()
    
public  StringgetValueColumnName()
    
public  StringgetWordBreak()
    
public  booleanisColumnInTable(String tableName, String columnName)
    
protected  voidpopulateReservedWords(HashMap rw)
     Populate rw with all reserved words and their replacements.
public  voidremoveTableName(String name)
     Remove all information about table.
public  voidsetClassIdColumnName(String classIdColumnName)
     Set the name used for classId columns.
public  voidsetDatabaseType(String db)
     This is called immediately after the name generator has been constructed to indicate which database is in use.
public  voidsetIndexNamePrefix(String indexNamePrefix)
     Set the prefix used to generate index names.
public  voidsetKeyColumnName(String keyColumnName)
     Set the name used for keys columns in link tables for maps where the keys are not references to PC instances.
public  voidsetMaxColumnNameLength(int maxColumnNameLength)
     Set the max length in characters for a column name.
public  voidsetMaxConstraintNameLength(int maxConstraintNameLength)
     Set the max length in characters for a constraint name.
public  voidsetMaxIndexNameLength(int maxIndexNameLength)
     Set the max length in characters for an index name.
public  voidsetMaxTableNameLength(int maxTableNameLength)
     Set the max length in characters for a table name.
public  voidsetPkConstraintPrefix(String pkConstraintPrefix)
     Set the prefix added to a table name to generate its primary key constraint name.
public  voidsetPkSuffix(String pkSuffix)
     Set the suffix added to table or field names to name primary key columns.
public  voidsetPolyRefClassIdSuffix(String polyRefClassIdSuffix)
    
public  voidsetSequenceColumnName(String sequenceColumnName)
     Set the name used for sequence columns in link tables.
public  voidsetValueColumnName(String valueColumnName)
     Set the name used for value columns in link tables where the values are not references to PC instances.
public  voidsetWordBreak(String wordBreak)
     Set the string used to break 'words' when generating names from field and class names and so on.
protected  StringshrinkName(String name, int maxlen)
     Shrink the supplied name to maxlen chars if it is longer than maxlen.

Field Detail
classIdColumnName
protected String classIdColumnName(Code)



constraintNames
protected HashSet constraintNames(Code)
All the constraint names we know about.



databaseType
protected String databaseType(Code)



indexNamePrefix
protected String indexNamePrefix(Code)



indexNames
protected HashSet indexNames(Code)
All the index names we know about.



keyColumnName
protected String keyColumnName(Code)



maxColumnNameLength
protected int maxColumnNameLength(Code)



maxConstraintNameLength
protected int maxConstraintNameLength(Code)



maxIndexNameLength
protected int maxIndexNameLength(Code)



maxTableNameLength
protected int maxTableNameLength(Code)



pkConstraintPrefix
protected String pkConstraintPrefix(Code)



pkSuffix
protected String pkSuffix(Code)



polyRefClassIdSuffix
protected String polyRefClassIdSuffix(Code)



refConstraintPrefix
protected String refConstraintPrefix(Code)



reservedWords
protected HashMap reservedWords(Code)



sequenceColumnName
protected String sequenceColumnName(Code)



tableMap
protected HashMap tableMap(Code)
This maps a table name to a HashSet of its column names.



valueColumnName
protected String valueColumnName(Code)



wordBreak
protected String wordBreak(Code)




Constructor Detail
DefaultJdbcNameGenerator
public DefaultJdbcNameGenerator()(Code)




Method Detail
addColumnName
public void addColumnName(String tableName, String columnName) throws IllegalArgumentException(Code)
Add a column name. The tableName will have already been added.
throws:
  IllegalArgumentException - if the name is invalid(e.g. 'duplicate column name' or 'invalid character XXX in name'etc.)



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.



addPkConstraintName
public void addPkConstraintName(String tableName, String pkConstraintName) throws IllegalArgumentException(Code)
Add the primary key constaint name specified in jdo meta data.
throws:
  IllegalArgumentException - if it is invalid



addRefConstraintName
public void addRefConstraintName(String tableName, String refConstraintName) throws IllegalArgumentException(Code)
Add the referential integrity constaint name specified in jdo meta data.
throws:
  IllegalArgumentException - if it is invalid



addTableName
public void addTableName(String name) throws IllegalArgumentException(Code)
Add a table name specified in jdo meta data.
throws:
  IllegalArgumentException - if the name is invalid(e.g. 'duplicate table name' or 'invalid character XXX in name'etc.)



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.



generateClassIdColumnName
public String generateClassIdColumnName(String tableName)(Code)
Generate and add the name for a classId column.
See Also:   DefaultJdbcNameGenerator.addColumnNameImp



generateClassTableName
public String generateClassTableName(String className)(Code)
Generate a table name for a persistent class. The name generator must 'add' it.
See Also:   DefaultJdbcNameGenerator.addTableName



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.



generateIndexName
public String generateIndexName(String tableName, String[] columnNames)(Code)
Generate and add an index name.
See Also:   DefaultJdbcNameGenerator.addIndexName



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.



getIndexNamePrefix
public String getIndexNamePrefix()(Code)



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.



getKeyColumnName
public String getKeyColumnName()(Code)



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)



getPkSuffix
public String getPkSuffix()(Code)



getPolyRefClassIdSuffix
public String getPolyRefClassIdSuffix()(Code)



getSequenceColumnName
public String getSequenceColumnName()(Code)



getValueColumnName
public String getValueColumnName()(Code)



getWordBreak
public String getWordBreak()(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.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.