com.triactive.jdo.store.sql
Class TableName

java.lang.Object
  extended bycom.triactive.jdo.store.sql.QualifiedName
      extended bycom.triactive.jdo.store.sql.TableName

public final class TableName
extends QualifiedName

An SQL table name.

A TableName is a type of QualifiedName naming an SQL database table or view.

Table names in TJDO are generated such that there are always enough spare characters at the end to append the various suffixes used in ConstraintNames and IndexNames. This usually results in truncation only on databases having a fairly short maximum table name length.

Author:
Mike Martin

Field Summary
static int MAX_SUFFIX_LENGTH
          The maximum length in characters reserved at the end of table names for suffixes used to construct related names (such as _PK for a table's primary key).
 
Fields inherited from class com.triactive.jdo.store.sql.QualifiedName
identifier, schemaName
 
Constructor Summary
TableName(DatabaseAdapter dba, SchemaName schemaName, java.lang.String identifier)
          Constructs a table name.
TableName(DatabaseAdapter dba, java.lang.String identifier)
          Constructs a table name.
TableName(DatabaseAdapter dba, java.lang.String schemaName, java.lang.String identifier)
          Constructs a table name.
TableName(DatabaseAdapter dba, java.lang.String catalogName, java.lang.String schemaName, java.lang.String identifier)
          Constructs a table name.
 
Method Summary
static TableName fromJavaName(DatabaseAdapter dba, SchemaName schemaName, java.lang.String javaName)
          Converts a Java name string to an SQL table name.
static TableName fromJavaName(DatabaseAdapter dba, java.lang.String javaName)
          Converts a Java name string to an SQL table name.
static TableName fromStrings(DatabaseAdapter dba, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName)
          Constructs a table name from strings.
 
Methods inherited from class com.triactive.jdo.store.sql.QualifiedName
effectiveCatalogName, effectiveSchemaName, equals, fullyQualified, getIdentifier, getSchemaName, hashCode, intern, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_SUFFIX_LENGTH

public static int MAX_SUFFIX_LENGTH
The maximum length in characters reserved at the end of table names for suffixes used to construct related names (such as _PK for a table's primary key).

Constructor Detail

TableName

public TableName(DatabaseAdapter dba,
                 java.lang.String identifier)
Constructs a table name. The identifier will be truncated if necessary to the maximum allowed table name length. The name will not be schema-qualified.

Parameters:
dba - a database adapter for the relevant database
identifier - the SQL identifier value as a string

TableName

public TableName(DatabaseAdapter dba,
                 java.lang.String schemaName,
                 java.lang.String identifier)
Constructs a table name. The identifier will be truncated if necessary to the maximum allowed table name length. The name will be schema-qualified if schemaName is not null. The schema name will not be catalog-qualified.

Parameters:
dba - a database adapter for the relevant database
schemaName - the SQL schema name as a string, or null
identifier - the SQL identifier value as a string

TableName

public TableName(DatabaseAdapter dba,
                 java.lang.String catalogName,
                 java.lang.String schemaName,
                 java.lang.String identifier)
Constructs a table name. The identifier will be truncated if necessary to the maximum allowed table name length. The name will be schema-qualified if schemaName is not null. The name will be catalog-qualified if catalogName is not null.

Parameters:
dba - a database adapter for the relevant database
catalogName - the SQL catalog name as a string, or null
schemaName - the SQL schema name as a string, or null
identifier - the SQL identifier value as a string

TableName

public TableName(DatabaseAdapter dba,
                 SchemaName schemaName,
                 java.lang.String identifier)
Constructs a table name. The identifier will be truncated if necessary to the maximum allowed table name length.

Parameters:
dba - a database adapter for the relevant database
schemaName - the schema name part of the table name, or null if the name is not schema-qualified
identifier - the SQL identifier value as a string
Method Detail

fromStrings

public static TableName fromStrings(DatabaseAdapter dba,
                                    java.lang.String catalogName,
                                    java.lang.String schemaName,
                                    java.lang.String tableName)
Constructs a table name from strings.

Parameters:
dba - a database adapter for the relevant database
catalogName - the catalog name, or null
schemaName - the schema name, or null
tableName - the table name
Returns:
a new TableName object

fromJavaName

public static TableName fromJavaName(DatabaseAdapter dba,
                                     java.lang.String javaName)
Converts a Java name string to an SQL table name. Equivalent to:
 fromJavaName(dba, null, javaName)
 

Parameters:
dba - a database adapter for the relevant database
javaName - the Java identifier name. Must not be null.
Returns:
a new TableName object.

fromJavaName

public static TableName fromJavaName(DatabaseAdapter dba,
                                     SchemaName schemaName,
                                     java.lang.String javaName)
Converts a Java name string to an SQL table name. This method returns a new TableName object where the SQL identifier is generated from the given Java identifier. The table name SQL identifier will be truncated if necessary to the maximum allowed table name length, minus characters reserved for any constraint or index name suffix.

Parameters:
dba - a database adapter for the relevant database
schemaName - the schema name part of the table name, or null if the name is not schema-qualified
javaName - the Java identifier name. Must not be null.
Returns:
a new TableName object.
See Also:
SqlIdentifier.javaToSql(java.lang.String)


Copyright 2001-2007 The TJDO Project All Rights Reserved.