org.datanucleus.store.mapped.identifier
Class DN2IdentifierFactory

java.lang.Object
  extended by org.datanucleus.store.mapped.identifier.AbstractIdentifierFactory
      extended by org.datanucleus.store.mapped.identifier.DNIdentifierFactory
          extended by org.datanucleus.store.mapped.identifier.DN2IdentifierFactory
All Implemented Interfaces:
IdentifierFactory

public class DN2IdentifierFactory
extends DNIdentifierFactory

Factory that creates immutable instances of DatastoreIdentifier for mapped datastores. Provides a more concise and consistent alternative to "jpox". Naming as follows:-


Field Summary
 
Fields inherited from class org.datanucleus.store.mapped.identifier.DNIdentifierFactory
tablePrefix, tableSuffix
 
Fields inherited from class org.datanucleus.store.mapped.identifier.AbstractIdentifierFactory
candidates, CASE_LOWER, CASE_PRESERVE, CASE_UPPER, clr, columns, dba, defaultCatalogName, defaultSchemaName, foreignkeys, identifierCase, indexes, LOCALISER, primarykeys, quoteString, rdba, references, sequences, tables, wordSeparator
 
Constructor Summary
DN2IdentifierFactory(DatastoreAdapter dba, ClassLoaderResolver clr, java.util.Map props)
          Constructor.
 
Method Summary
 java.lang.String generateIdentifierNameForJavaName(java.lang.String javaName)
          Generate a datastore identifier from a Java identifier.
 DatastoreIdentifier newAdapterIndexFieldIdentifier()
          Method to return an identifier for an adapter index datastore field.
 DatastoreIdentifier newForeignKeyFieldIdentifier(AbstractMemberMetaData ownerFmd, DatastoreIdentifier destinationId, boolean embedded, int fieldRole)
          Method to generate a FK/FK-index field identifier.
 DatastoreIdentifier newIndexFieldIdentifier(AbstractMemberMetaData mmd)
          Method to return an identifier for an index (ordering) datastore field.
 DatastoreIdentifier newJoinTableFieldIdentifier(AbstractMemberMetaData ownerFmd, AbstractMemberMetaData relatedFmd, DatastoreIdentifier destinationId, boolean embedded, int fieldRole)
          Method to generate a join-table identifier.
 DatastoreIdentifier newVersionFieldIdentifier()
          Method to return an identifier for a version datastore field.
 
Methods inherited from class org.datanucleus.store.mapped.identifier.DNIdentifierFactory
getColumnIdentifierSuffix, newDatastoreContainerIdentifier, newDatastoreContainerIdentifier, newDiscriminatorFieldIdentifier, newForeignKeyFieldIdentifier, newReferenceFieldIdentifier
 
Methods inherited from class org.datanucleus.store.mapped.identifier.AbstractIdentifierFactory
getDatastoreAdapter, getIdentifierCase, getIdentifierInAdapterCase, getIdentifierNamePartsFromName, getWordSeparator, newCandidateKeyIdentifier, newDatastoreContainerIdentifier, newDatastoreFieldIdentifier, newDatastoreFieldIdentifier, newForeignKeyIdentifier, newIdentifier, newIdentifier, newIndexIdentifier, newPrimaryKeyIdentifier, newSequenceIdentifier, setCatalogSchemaForTable, truncate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DN2IdentifierFactory

public DN2IdentifierFactory(DatastoreAdapter dba,
                            ClassLoaderResolver clr,
                            java.util.Map props)
Constructor. The properties accepted are

Parameters:
dba - Database adapter
clr - ClassLoader resolver
props - Any properties controlling identifier generation
Method Detail

newJoinTableFieldIdentifier

public DatastoreIdentifier newJoinTableFieldIdentifier(AbstractMemberMetaData ownerFmd,
                                                       AbstractMemberMetaData relatedFmd,
                                                       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 IdentifierFactory
Overrides:
newJoinTableFieldIdentifier in class DNIdentifierFactory
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 DatastoreIdentifier newForeignKeyFieldIdentifier(AbstractMemberMetaData ownerFmd,
                                                        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 DatastoreIdentifier newVersionFieldIdentifier()
Method to return an identifier for a version datastore field.

Specified by:
newVersionFieldIdentifier in interface IdentifierFactory
Overrides:
newVersionFieldIdentifier in class DNIdentifierFactory
Returns:
The version datastore field identifier

newIndexFieldIdentifier

public DatastoreIdentifier newIndexFieldIdentifier(AbstractMemberMetaData mmd)
Method to return an identifier for an index (ordering) datastore field.

Specified by:
newIndexFieldIdentifier in interface IdentifierFactory
Overrides:
newIndexFieldIdentifier in class DNIdentifierFactory
Parameters:
mmd - MetaData for the field/property - not used here
Returns:
The index datastore field identifier

newAdapterIndexFieldIdentifier

public 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 IdentifierFactory
Overrides:
newAdapterIndexFieldIdentifier in class DNIdentifierFactory
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 DNIdentifierFactory
Parameters:
javaName - the Java identifier.
Returns:
The datastore identifier


Copyright © 2010. All Rights Reserved.