public abstract class AbstractIdentifierFactory extends Object implements IdentifierFactory
Modifier and Type | Field and Description |
---|---|
protected Map<String,DatastoreIdentifier> |
candidates |
static int |
CASE_LOWER |
static int |
CASE_PRESERVE |
static int |
CASE_UPPER |
protected org.datanucleus.ClassLoaderResolver |
clr |
protected Map<String,DatastoreIdentifier> |
columns |
protected DatastoreAdapter |
dba |
protected String |
defaultCatalogName
Default catalog name for any created identifiers.
|
protected String |
defaultSchemaName
Default schema name for any created identifiers.
|
protected Map<String,DatastoreIdentifier> |
foreignkeys |
protected Map<String,DatastoreIdentifier> |
indexes |
protected org.datanucleus.store.schema.naming.NamingCase |
namingCase
Case to use for identifiers.
|
protected org.datanucleus.store.schema.naming.NamingFactory |
namingFactory |
protected Map<String,DatastoreIdentifier> |
primarykeys |
protected String |
quoteString |
protected Map<String,DatastoreIdentifier> |
references |
protected Map<String,DatastoreIdentifier> |
sequences |
protected Map<String,DatastoreIdentifier> |
tables |
protected String |
wordSeparator
Separator to use for words in the identifiers.
|
Constructor and Description |
---|
AbstractIdentifierFactory(DatastoreAdapter dba,
org.datanucleus.ClassLoaderResolver clr,
Map props)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract String |
generateIdentifierNameForJavaName(String javaName)
Generate a datastore identifier from a Java identifier.
|
protected abstract String |
getColumnIdentifierSuffix(org.datanucleus.metadata.FieldRole role,
boolean embedded)
Accessor for the suffix to add to any column identifier, based on the role type.
|
DatastoreAdapter |
getDatastoreAdapter()
Accessor for the datastore adapter that we are creating identifiers for.
|
String |
getIdentifierInAdapterCase(String identifier)
Convenience method to convert the passed identifier into an identifier
in the correct case, and with any required quoting for the datastore adapter.
|
protected String[] |
getIdentifierNamePartsFromName(String name)
Convenience method to split a fully-specified identifier name (inc catalog/schema)
into its constituent parts.
|
org.datanucleus.store.schema.naming.NamingCase |
getNamingCase()
Accessor for the identifier case being used.
|
String |
getWordSeparator()
Accessor for the word separator for identifiers.
|
DatastoreIdentifier |
newCandidateKeyIdentifier(Table table,
int seq)
Method to generate an identifier for a candidate key in the supplied table.
|
DatastoreIdentifier |
newColumnIdentifier(String identifierName)
Method to use to generate an identifier for a datastore field.
|
DatastoreIdentifier |
newColumnIdentifier(String javaName,
boolean embedded,
org.datanucleus.metadata.FieldRole fieldRole,
boolean custom)
Method to create an identifier for a datastore field where we want the
name based on the supplied java name, and the field has a particular
role (and so could have its naming set according to the role).
|
DatastoreIdentifier |
newForeignKeyIdentifier(Table table,
int seq)
Method to create a new identifier for a foreign key in the supplied table.
|
DatastoreIdentifier |
newIdentifier(DatastoreIdentifier identifier,
String suffix)
Method to return a new Identifier based on the passed identifier, but adding on the passed suffix
|
DatastoreIdentifier |
newIdentifier(IdentifierType identifierType,
String name)
Method to generate an identifier based on the supplied name for the requested type of identifier.
|
DatastoreIdentifier |
newIndexIdentifier(Table table,
boolean isUnique,
int seq)
Method to create an identifier for an Index in the supplied table.
|
DatastoreIdentifier |
newPrimaryKeyIdentifier(Table table)
Method to generate an identifier for a primary key for the supplied table.
|
DatastoreIdentifier |
newSequenceIdentifier(String sequenceName)
Method to generate an identifier for a sequence using the passed name.
|
DatastoreIdentifier |
newTableIdentifier(String identifierName)
Method to use to generate an identifier for a datastore field in the default catalog/schema.
|
DatastoreIdentifier |
newTableIdentifier(String identifierName,
String catalogName,
String schemaName)
Method to use to generate an identifier for a datastore field.
|
protected void |
setCatalogSchemaForTable(org.datanucleus.store.rdbms.identifier.TableIdentifier identifier)
Convenience method to set the catalog/schema on the passed TableIdentifier.
|
protected String |
truncate(String identifier,
int length)
Method to truncate an identifier to fit within the specified identifier length.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newAdapterIndexFieldIdentifier, newDiscriminatorFieldIdentifier, newForeignKeyFieldIdentifier, newIndexFieldIdentifier, newJoinTableFieldIdentifier, newReferenceFieldIdentifier, newTableIdentifier, newTableIdentifier, newVersionFieldIdentifier
public static final int CASE_PRESERVE
public static final int CASE_UPPER
public static final int CASE_LOWER
protected org.datanucleus.store.schema.naming.NamingFactory namingFactory
protected DatastoreAdapter dba
protected org.datanucleus.ClassLoaderResolver clr
protected org.datanucleus.store.schema.naming.NamingCase namingCase
protected String quoteString
protected String wordSeparator
protected Map<String,DatastoreIdentifier> tables
protected Map<String,DatastoreIdentifier> columns
protected Map<String,DatastoreIdentifier> foreignkeys
protected Map<String,DatastoreIdentifier> indexes
protected Map<String,DatastoreIdentifier> candidates
protected Map<String,DatastoreIdentifier> primarykeys
protected Map<String,DatastoreIdentifier> sequences
protected Map<String,DatastoreIdentifier> references
protected String defaultCatalogName
protected String defaultSchemaName
public AbstractIdentifierFactory(DatastoreAdapter dba, org.datanucleus.ClassLoaderResolver clr, Map props)
dba
- Database adapterclr
- ClassLoader resolverprops
- Any properties controlling identifier generationpublic DatastoreAdapter getDatastoreAdapter()
getDatastoreAdapter
in interface IdentifierFactory
public org.datanucleus.store.schema.naming.NamingCase getNamingCase()
getNamingCase
in interface IdentifierFactory
public String getWordSeparator()
protected String truncate(String identifier, int length)
HASH_LENGTH
) (at the end) to attempt to create uniqueness.identifier
- The identifierlength
- The (max) length to usepublic String getIdentifierInAdapterCase(String identifier)
getIdentifierInAdapterCase
in interface IdentifierFactory
identifier
- The identifierpublic DatastoreIdentifier newIdentifier(IdentifierType identifierType, String name)
newIdentifier
in interface IdentifierFactory
identifierType
- the type of identifier to be createdname
- The Java or SQL identifier namepublic DatastoreIdentifier newIdentifier(DatastoreIdentifier identifier, String suffix)
newIdentifier
in interface IdentifierFactory
identifier
- The current identifiersuffix
- The suffixpublic DatastoreIdentifier newTableIdentifier(String identifierName)
newTableIdentifier
in interface IdentifierFactory
identifierName
- The identifier namepublic DatastoreIdentifier newTableIdentifier(String identifierName, String catalogName, String schemaName)
newTableIdentifier
in interface IdentifierFactory
identifierName
- The identifier name for the tablecatalogName
- Optional catalog name (null means not set)schemaName
- Optional schema name (null means not set)public DatastoreIdentifier newColumnIdentifier(String identifierName)
newColumnIdentifier
in interface IdentifierFactory
identifierName
- The identifier namepublic DatastoreIdentifier newColumnIdentifier(String javaName, boolean embedded, org.datanucleus.metadata.FieldRole fieldRole, boolean custom)
newColumnIdentifier
in interface IdentifierFactory
javaName
- The java field nameembedded
- Whether the identifier is for a field embeddedfieldRole
- The role to be performed by this column e.g FK, Index ?custom
- Whether this has a user-defined namepublic DatastoreIdentifier newSequenceIdentifier(String sequenceName)
newSequenceIdentifier
in interface IdentifierFactory
sequenceName
- the name of the sequence to usepublic DatastoreIdentifier newPrimaryKeyIdentifier(Table table)
newPrimaryKeyIdentifier
in interface IdentifierFactory
table
- the tablepublic DatastoreIdentifier newCandidateKeyIdentifier(Table table, int seq)
newCandidateKeyIdentifier
in interface IdentifierFactory
table
- the tableseq
- the sequential numberpublic DatastoreIdentifier newForeignKeyIdentifier(Table table, int seq)
newForeignKeyIdentifier
in interface IdentifierFactory
table
- the tableseq
- the sequential numberpublic DatastoreIdentifier newIndexIdentifier(Table table, boolean isUnique, int seq)
newIndexIdentifier
in interface IdentifierFactory
table
- the tableisUnique
- if the index is uniqueseq
- the sequential numberprotected abstract String getColumnIdentifierSuffix(org.datanucleus.metadata.FieldRole role, boolean embedded)
role
- Datastore field roleembedded
- Whether the column is stored embeddedprotected abstract String generateIdentifierNameForJavaName(String javaName)
javaName
- the Java identifier.protected void setCatalogSchemaForTable(org.datanucleus.store.rdbms.identifier.TableIdentifier identifier)
identifier
- The TableIdentifierprotected String[] getIdentifierNamePartsFromName(String name)
name
- NameCopyright © 2017. All rights reserved.