com.triactive.jdo.store.sql
Class IndexName

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

public final class IndexName
extends QualifiedName

An SQL index name.

An IndexName is a type of QualifiedName naming an SQL database index.

Index names in TJDO are generated using a suffix convention based on their type, unique (_Un) vs. non-unique (_Nn).

Author:
Mike Martin

Field Summary
static int MAX_INDICES
          The maximum number of indices allowed.
static int MAX_SUFFIX_LENGTH
          The maximum length in characters reserved at the end of index names for suffixes used to indicate the type of index.
 
Fields inherited from class com.triactive.jdo.store.sql.QualifiedName
identifier, schemaName
 
Constructor Summary
IndexName(DatabaseAdapter dba, SchemaName schemaName, java.lang.String identifier)
          Constructs an index name.
IndexName(DatabaseAdapter dba, java.lang.String identifier)
          Constructs an index name.
 
Method Summary
static IndexName forTable(BaseTable table, boolean isUnique, int seq)
          Generates a new index name.
 boolean isForTable(BaseTable table)
          Tests if this index name is for an index on the specified table.
 
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 final int MAX_SUFFIX_LENGTH
The maximum length in characters reserved at the end of index names for suffixes used to indicate the type of index.

See Also:
Constant Field Values

MAX_INDICES

public static final int MAX_INDICES
The maximum number of indices allowed. This is limited only due to the suffix convention.

See Also:
Constant Field Values
Constructor Detail

IndexName

public IndexName(DatabaseAdapter dba,
                 java.lang.String identifier)
Constructs an index name. The identifier will be truncated if necessary to the maximum allowed index 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

IndexName

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

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

isForTable

public boolean isForTable(BaseTable table)
Tests if this index name is for an index on the specified table.

Note: the current implementation of this method is simplistic and may return false positives.

Parameters:
table - The base table to test.
Returns:
true if this index name is for an index on table, false otherwise.

forTable

public static IndexName forTable(BaseTable table,
                                 boolean isUnique,
                                 int seq)
Generates a new index name. Always used when generating names for new indices.

The table name is used as the base of the new index name. The table name identifier is first truncated if necessary to reserve MAX_SUFFIX_LENGTH characters for a suffix. Then _Un or _Nn is appended, depending on whether the index isUnique or not, and where n is a character from [0-9A-Z] representing the given seq parameter.

If the specified table's name is schema-qualified then the index name will be schema-qualified.

Parameters:
table - The base table for the named index.
isUnique - true if a unique index is being named
seq - The number of the index for this table. By convention, should start at 1.
Returns:
a new IndexName object.


Copyright © 2001-2007 The TJDO Project All Rights Reserved.