org.jpox.store.rdbms.sqlidentifier
Class JPOX2IdentifierFactory

java.lang.Object
  extended by org.jpox.store.mapped.AbstractIdentifierFactory
      extended by org.jpox.store.rdbms.sqlidentifier.AbstractRDBMSIdentifierFactory
          extended by org.jpox.store.rdbms.sqlidentifier.JPOXIdentifierFactory
              extended by org.jpox.store.rdbms.sqlidentifier.JPOX2IdentifierFactory
All Implemented Interfaces:
org.jpox.store.mapped.IdentifierFactory, RDBMSIdentifierFactory

public class JPOX2IdentifierFactory
extends JPOXIdentifierFactory

Factory that creates immutable instances of DatastoreIdentifier for RDBMS datastores. Provides a more concise and consistent alternative to "jpox". "jpox" is left alone so we preserve backwards compatibility with JPOX 1.1.0. Naming as follows:-

Version:
$Revision: 1.7 $

Field Summary
 
Fields inherited from class org.jpox.store.rdbms.sqlidentifier.JPOXIdentifierFactory
tablePrefix, tableSuffix
 
Fields inherited from class org.jpox.store.rdbms.sqlidentifier.AbstractRDBMSIdentifierFactory
candidates, columns, defaultCatalogName, defaultSchemaName, foreignkeys, indexes, primarykeys, rdba, references, sequences, tables, wordSeparator
 
Fields inherited from class org.jpox.store.mapped.AbstractIdentifierFactory
CASE_LOWER, CASE_PRESERVE, CASE_UPPER, dba, identifierCase, LOCALISER
 
Fields inherited from interface org.jpox.store.mapped.IdentifierFactory
CANDIDATE_KEY, COLUMN, FOREIGN_KEY, IDENTIFIER_LOWER_CASE, IDENTIFIER_LOWER_CASE_QUOTED, IDENTIFIER_MIXED_CASE, IDENTIFIER_MIXED_CASE_QUOTED, IDENTIFIER_UPPER_CASE, IDENTIFIER_UPPER_CASE_QUOTED, INDEX, PRIMARY_KEY, SEQUENCE, TABLE
 
Constructor Summary
JPOX2IdentifierFactory(org.jpox.store.mapped.DatastoreAdapter dba, java.lang.String defaultCatalog, java.lang.String defaultSchema, java.lang.String requiredCase, java.lang.String wordSeparator, java.lang.String tablePrefix, java.lang.String tableSuffix)
          Constructor.
 
Method Summary
 java.lang.String generateIdentifierNameForJavaName(java.lang.String javaName)
          Generate a datastore identifier from a Java identifier.
 org.jpox.store.mapped.DatastoreIdentifier newAdapterIndexFieldIdentifier()
          Method to return an identifier for an adapter index datastore field.
 org.jpox.store.mapped.DatastoreIdentifier newForeignKeyFieldIdentifier(org.jpox.metadata.AbstractMemberMetaData ownerFmd, org.jpox.store.mapped.DatastoreIdentifier destinationId, boolean embedded, int fieldRole)
          Method to generate a FK/FK-index field identifier.
 org.jpox.store.mapped.DatastoreIdentifier newIndexFieldIdentifier()
          Method to return an identifier for an index datastore field.
 org.jpox.store.mapped.DatastoreIdentifier newJoinTableFieldIdentifier(org.jpox.metadata.AbstractMemberMetaData ownerFmd, org.jpox.metadata.AbstractMemberMetaData relatedFmd, org.jpox.store.mapped.DatastoreIdentifier destinationId, boolean embedded, int fieldRole)
          Method to generate a join-table identifier.
 org.jpox.store.mapped.DatastoreIdentifier newVersionFieldIdentifier()
          Method to return an identifier for a version datastore field.
 
Methods inherited from class org.jpox.store.rdbms.sqlidentifier.JPOXIdentifierFactory
getColumnIdentifierSuffix, newDatastoreContainerIdentifier, newDatastoreContainerIdentifier, newDiscriminatorFieldIdentifier, newForeignKeyFieldIdentifier, newReferenceFieldIdentifier
 
Methods inherited from class org.jpox.store.rdbms.sqlidentifier.AbstractRDBMSIdentifierFactory
getIdentifierInAdapterCase, getIdentifierNamePartsFromName, getMaxLengthForIdentifierType, getWordSeparator, newCandidateKeyIdentifier, newDatastoreContainerIdentifier, newDatastoreFieldIdentifier, newDatastoreFieldIdentifier, newForeignKeyIdentifier, newIdentifier, newIdentifier, newIndexIdentifier, newPrimaryKeyIdentifier, newSequenceIdentifier, setCatalogSchemaForTable
 
Methods inherited from class org.jpox.store.mapped.AbstractIdentifierFactory
getDatastoreAdapter, getIdentifierCase, getNameOfIdentifierCase, truncate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jpox.store.mapped.IdentifierFactory
getDatastoreAdapter, getIdentifierCase, getNameOfIdentifierCase
 

Constructor Detail

JPOX2IdentifierFactory

public JPOX2IdentifierFactory(org.jpox.store.mapped.DatastoreAdapter dba,
                              java.lang.String defaultCatalog,
                              java.lang.String defaultSchema,
                              java.lang.String requiredCase,
                              java.lang.String wordSeparator,
                              java.lang.String tablePrefix,
                              java.lang.String tableSuffix)
Constructor. TODO Allow specification of multiple properties in PMF to control the id generation and just pass in a Properties into here

Parameters:
dba - Datastore adapter
defaultCatalog - Name of the default catalog (if any)
defaultSchema - Name of the default schema (if any)
requiredCase - The case the user requires
wordSeparator - Word separator for identifiers
tablePrefix - Prefix for table names when being generated
tableSuffix - Suffix for table names when being generated
Method Detail

newJoinTableFieldIdentifier

public org.jpox.store.mapped.DatastoreIdentifier newJoinTableFieldIdentifier(org.jpox.metadata.AbstractMemberMetaData ownerFmd,
                                                                             org.jpox.metadata.AbstractMemberMetaData relatedFmd,
                                                                             org.jpox.store.mapped.DatastoreIdentifier destinationId,
                                                                             boolean embedded,
                                                                             int fieldRole)
Method to generate a join-table identifier. The identifier could be for a foreign-key to another table (if the destinationId is provided), or could be for a simple column in the join table.

Specified by:
newJoinTableFieldIdentifier in interface RDBMSIdentifierFactory
Overrides:
newJoinTableFieldIdentifier in class JPOXIdentifierFactory
Parameters:
ownerFmd - MetaData for the owner field
relatedFmd - MetaData for the related field
destinationId - Identifier for the identity field of the destination (if FK)
embedded - Whether the identifier is for a field embedded
fieldRole - The role to be performed by this column e.g FK, collection element ?
Returns:
The identifier.

newForeignKeyFieldIdentifier

public org.jpox.store.mapped.DatastoreIdentifier newForeignKeyFieldIdentifier(org.jpox.metadata.AbstractMemberMetaData ownerFmd,
                                                                              org.jpox.store.mapped.DatastoreIdentifier destinationId,
                                                                              boolean embedded,
                                                                              int fieldRole)
Method to generate a FK/FK-index field identifier. The identifier could be for the FK field itself, or for a related index for the FK.

Parameters:
ownerFmd - MetaData for the owner field
destinationId - Identifier for the identity field of the destination table (if strict FK)
embedded - Whether the identifier is for a field embedded
fieldRole - The role to be performed by this column e.g owner, index ?
Returns:
The identifier

newVersionFieldIdentifier

public org.jpox.store.mapped.DatastoreIdentifier newVersionFieldIdentifier()
Method to return an identifier for a version datastore field.

Specified by:
newVersionFieldIdentifier in interface org.jpox.store.mapped.IdentifierFactory
Overrides:
newVersionFieldIdentifier in class JPOXIdentifierFactory
Returns:
The version datastore field identifier

newIndexFieldIdentifier

public org.jpox.store.mapped.DatastoreIdentifier newIndexFieldIdentifier()
Method to return an identifier for an index datastore field.

Specified by:
newIndexFieldIdentifier in interface RDBMSIdentifierFactory
Overrides:
newIndexFieldIdentifier in class JPOXIdentifierFactory
Returns:
The index datastore field identifier

newAdapterIndexFieldIdentifier

public org.jpox.store.mapped.DatastoreIdentifier newAdapterIndexFieldIdentifier()
Method to return an identifier for an adapter index datastore field. An "adapter index" is a column added to be part of a primary key when some other column cant perform that role.

Specified by:
newAdapterIndexFieldIdentifier in interface RDBMSIdentifierFactory
Overrides:
newAdapterIndexFieldIdentifier in class JPOXIdentifierFactory
Returns:
The index datastore field identifier

generateIdentifierNameForJavaName

public java.lang.String generateIdentifierNameForJavaName(java.lang.String javaName)
Generate a datastore identifier from a Java identifier.

Conversion consists of breaking the identifier into words, converting each word to upper-case, and separating each one with a word separator. Words are identified by a leading upper-case character. Any leading or trailing underscores are removed.

Overrides:
generateIdentifierNameForJavaName in class JPOXIdentifierFactory
Parameters:
javaName - the Java identifier.
Returns:
The datastore identifier


Copyright © -2008 . All Rights Reserved.