public abstract class AbstractNamingFactory extends Object implements NamingFactory
Modifier and Type | Field and Description |
---|---|
protected ClassLoaderResolver |
clr |
protected NamingCase |
namingCase |
protected NucleusContext |
nucCtx |
protected String |
quoteString
Quote used when the identifier case selected requires it.
|
protected Set<String> |
reservedWords |
protected String |
wordSeparator
Separator to use for words in the identifiers.
|
Constructor and Description |
---|
AbstractNamingFactory(NucleusContext nucCtx) |
Modifier and Type | Method and Description |
---|---|
String |
getColumnName(AbstractMemberMetaData mmd,
ColumnType type)
Method to return the name of the column for the specified field.
|
String |
getColumnName(List<AbstractMemberMetaData> mmds,
int colPosition)
Method to return the name of the column for the position of the specified EMBEDDED field, within the specified owner field.
|
String |
getConstraintName(AbstractClassMetaData cmd,
ConstraintMetaData cnstrmd,
ColumnType type)
Method to return the name of the constraint for the specified class (version, datastore-id, discriminator etc).
|
String |
getConstraintName(AbstractClassMetaData cmd,
ConstraintMetaData cnstrmd,
int position)
Method to return the name of a constraint specified at class level.
|
String |
getConstraintName(String className,
AbstractMemberMetaData mmd,
ConstraintMetaData cnstrmd)
Method to return the name of a constraint specified at member level.
|
protected int |
getMaximumLengthForComponent(SchemaComponent cmpt) |
protected String |
getNameInRequiredCase(String name)
Convenience method to convert the passed name into a name in the required "case".
|
String |
getSequenceName(SequenceMetaData seqmd)
Method to return the name of sequence.
|
String |
getTableName(AbstractClassMetaData cmd)
Method to return the name of the table for the specified class.
|
protected String |
prepareIdentifierNameForUse(String name,
SchemaComponent cmpt)
Convenience method that will truncate the provided name if it is longer than the longest possible for the specified schema component,
and then convert it into the required case.
|
NamingFactory |
setMaximumLength(SchemaComponent cmpt,
int max)
Method to set the maximum length of the name of the specified schema component.
|
NamingFactory |
setNamingCase(NamingCase nameCase)
Method to set the required case of the names.
|
NamingFactory |
setQuoteString(String quote)
Method to set the quote string to use (when the identifiers need to be quoted).
|
NamingFactory |
setReservedKeywords(Set<String> keywords)
Method to set the provided list of keywords as names that identifiers have to surround by quotes to use.
|
NamingFactory |
setWordSeparator(String sep)
Method to set the word separator of the names.
|
protected static String |
truncate(String name,
int length)
Method to truncate a name to fit within the specified name length.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getColumnName, getColumnName, getTableName
protected String wordSeparator
protected String quoteString
protected NamingCase namingCase
protected NucleusContext nucCtx
protected ClassLoaderResolver clr
public AbstractNamingFactory(NucleusContext nucCtx)
public NamingFactory setReservedKeywords(Set<String> keywords)
NamingFactory
setReservedKeywords
in interface NamingFactory
keywords
- The keywordspublic NamingFactory setQuoteString(String quote)
NamingFactory
setIdentifierCase.
setQuoteString
in interface NamingFactory
quote
- The quote stringpublic NamingFactory setWordSeparator(String sep)
NamingFactory
setWordSeparator
in interface NamingFactory
sep
- Separatorpublic NamingFactory setNamingCase(NamingCase nameCase)
NamingFactory
setNamingCase
in interface NamingFactory
nameCase
- Required casepublic NamingFactory setMaximumLength(SchemaComponent cmpt, int max)
NamingFactory
setMaximumLength
in interface NamingFactory
cmpt
- The componentmax
- The maximum it acceptsprotected int getMaximumLengthForComponent(SchemaComponent cmpt)
public String getTableName(AbstractClassMetaData cmd)
NamingFactory
getTableName
in interface NamingFactory
cmd
- Metadata for the classpublic String getColumnName(AbstractMemberMetaData mmd, ColumnType type)
NamingFactory
getColumnNamemethod.
getColumnName
in interface NamingFactory
mmd
- Metadata for the fieldtype
- Type of columnpublic String getColumnName(List<AbstractMemberMetaData> mmds, int colPosition)
NamingFactory
getColumnName
in interface NamingFactory
mmds
- MetaData for the field(s) with the column. The first value is the original field that is embedded, followed by fields of the embedded object(s).colPosition
- The position of the column (where this field has multiple columns)public String getConstraintName(AbstractClassMetaData cmd, ConstraintMetaData cnstrmd, int position)
NamingFactory
getConstraintName
in interface NamingFactory
cmd
- Metadata for the classcnstrmd
- The constraint metadataposition
- Number of the constraint at class level (first is 0)public String getConstraintName(String className, AbstractMemberMetaData mmd, ConstraintMetaData cnstrmd)
NamingFactory
getConstraintName
in interface NamingFactory
className
- Name of the class that this constraint is for.mmd
- Metadata for the membercnstrmd
- The constraint metadatapublic String getConstraintName(AbstractClassMetaData cmd, ConstraintMetaData cnstrmd, ColumnType type)
NamingFactory
getConstraintName
in interface NamingFactory
cmd
- Metadata for the classcnstrmd
- The constraint metadatatype
- Column typepublic String getSequenceName(SequenceMetaData seqmd)
NamingFactory
getSequenceName
in interface NamingFactory
seqmd
- Metadata for the sequenceprotected static String truncate(String name, int length)
TRUNCATE_HASH_LENGTH
) (at the end) to attempt
to create uniqueness.name
- The namelength
- The (max) length to useprotected String getNameInRequiredCase(String name)
name
- The nameprotected String prepareIdentifierNameForUse(String name, SchemaComponent cmpt)
name
- The namecmpt
- The schema component that it is forCopyright © 2015. All rights reserved.