public abstract class DatabaseDescriptor<T extends Database>
extends java.lang.Object
DatabaseFactory.getDatabaseDescriptor(Class)
, DBObjectProvider.getDescriptor()
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BUILT_IN_OBJECT
Object property to indicate that a given DBObject is "built-in" to the provider it was listed from.
|
static java.lang.String |
FEATURE_BITMAP_INDEXING
Deprecated.
|
static java.lang.String |
FEATURE_COLUMN_SEQUENCES
Deprecated.
|
static java.lang.String |
FEATURE_GLOBAL_HASH_INDEX_PARTITIONING
Deprecated.
|
static java.lang.String |
FEATURE_LOB_PARAMETERS
Deprecated.
|
static java.lang.String |
FEATURE_MAXTRANS
Deprecated.
|
static java.lang.String |
FEATURE_STORAGE_OPTIONS
Deprecated.
|
static java.lang.String |
FEATURE_TABLE_PARTITIONING
Deprecated.
|
static java.lang.String |
FEATURE_XMLTYPE_COL_PROPS
Deprecated.
|
Modifier | Constructor and Description |
---|---|
protected |
DatabaseDescriptor(java.lang.Class<? extends T> clz)
Constructs a new descriptor for the given Database implementation class.
|
protected |
DatabaseDescriptor(DatabaseDescriptor base)
Constructs a new descriptor using the given base descriptor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areNamesEqual(DBObject obj1, DBObject obj2)
Tests whether the two objects have the same name.
|
boolean |
areNamesEqual(java.lang.String name1, java.lang.String name2, java.lang.String objectType, boolean external)
Tests whether two strings representing object names are the same.
|
DataTypeUsage |
createDefaultTypeUsage()
Creates a default usage of a data type for use in a new Column, PlSqlMethod etc.
|
protected java.lang.String |
escapeQuoteCharacter(java.lang.String quote)
Escapes the quote character.
|
protected DatabaseDescriptor |
getBaseDescriptor()
If this descriptor is a customisation of a base descriptor, this method returns that base descriptor.
|
abstract int |
getCasePolicy()
Returns the case policy for names of the Database being described.
|
protected java.lang.Class<? extends T> |
getDatabaseClass()
Gets the Class of Database class that is being describing (provided by the subclass on construction).
|
java.lang.String |
getDatabaseName()
Gets a translated String respresenting the type and version of the described database.
|
abstract java.lang.String |
getDatabaseType()
Gets a String representing the type of database.
|
abstract int |
getDatabaseVersion()
Gets an int representing the version of the database type.
|
DataType |
getDataType(java.lang.String typeName)
Gets the datatype with given name.
|
DDLGenerator |
getDDLGenerator(DBObjectProvider pro)
Gets a DDLGenerator that will generate DDL for the type of Database represented by this descriptor, setup to work with the given provider.
|
DefaultSourceOptions |
getDefaultSourceOptions()
Returns an object which defines options controlling the default source for a SourceObject.
|
DerivedPropertyBuilder |
getDerivedPropertyBuilder(java.lang.Class<? extends AbstractBuildableObject> objClz, DBObjectProvider pro)
If an object can have derived properties, then this method returns the DerivedPropertyBuilder that should be present on that object to build and maintain those derived properties from their source property.
|
java.lang.String |
getExternalName(java.lang.String name, java.lang.String objectType)
Converts the specified name into the format used externally to represent the identifier.
|
java.util.List<PropertyInitializer> |
getExternalPropertyDefaulters(DBObjectProvider pro)
Deprecated.
|
java.nio.charset.Charset |
getIdeCharset() |
abstract java.lang.String |
getIdentifierQuoteString()
Returns the identifier quote string for the Database being described.
|
java.lang.String |
getInternalName(java.lang.String name, java.lang.String objectType)
Converts the specified name into the format used internally within the metadata.
|
abstract int |
getMaxNameLength(java.lang.String type)
Returns the maximum length for a name of the given
type . |
java.util.List<PropertyInitializer> |
getPropertyInitializers(DBObjectProvider pro)
Gets a list of PropertyInitializers responsible for defining the initial value for properties in the given provider.
|
java.lang.String |
getPublicSchemaName()
Gets the name of the "PUBLIC" schema for objects that are public (for example a PUBLIC SYNONYM).
|
int |
getQuotedNameCasePolicy()
Deprecated.
getCasePolicy() covers both quoted and unquoted names. |
java.util.Collection<java.lang.String> |
getReservedWords()
Returns a collection of the reserved words for the database being described
|
SqlAliasExpander |
getSqlAliasExpander(DBObjectProvider pro) |
SqlAliasExpander |
getSqlAliasExpander(DBObjectProvider pro, Schema defaultSchema) |
SQLQueryBuilderFactory |
getSQLQueryBuilderFactory()
Gets the SQLQueryBuilderFactory implementation for creating a
SQLQueryBuilder for this database type. |
DBObjectLister |
getTriggerLister(DBObjectProvider pro)
Returns a DBObjectLister implementation that will return a list of Triggers on the object (or objects) defined by a given
DBObjectCriteria . |
java.util.List<UpdateProcessor> |
getUpdateProcessors()
Gets a list of UpdateProcessors that should be used to pre-process any Difference passed to updateObjects before sending to the DBObjectProvider's back-end.
|
abstract java.util.Map<java.lang.String,DBObjectValidator> |
getValidators(DBObjectProvider pro)
Gets a map of object type (e.g.
|
protected void |
initialiseBuiltInObject(SystemObject obj)
Called on every object returned by listBuiltInObjects to set any specific properties that mark the object as "built-in".
|
protected void |
initialiseDefaultSourceOptions(DefaultSourceOptions opts)
Sub-classes to override initialisation of DefaultSourceOptions
|
boolean |
isCompatibleUpgrade(java.lang.Class<? extends Database> dbClz, java.lang.Class<? extends Database> testClz)
Deprecated.
and replaced with
isCompatibleWith(oracle.javatools.db.DatabaseDescriptor) . |
boolean |
isCompatibleWith(DatabaseDescriptor other)
Tests whether all datatypes and features supported in this descriptor are also supported in the target descriptor.
|
boolean |
isSameDatabase(DatabaseDescriptor other)
Tests whether the other descriptor is for the same database type and version as this descriptor.
|
boolean |
isValidFKDataType(DataType fktype, DataType reftype)
Assesses if the datatype of a foreign key column is valid given the datatype of the column which it references.
|
protected boolean |
isValidFKDataTypeImpl(DataType fktype, DataType reftype) |
boolean |
isValidName(java.lang.String type, java.lang.String name)
Checks to see whether a name is valid.
|
<T extends SystemObject> |
listBuiltInObjects(DBObjectCriteria<T> criteria)
A built-in object is a SystemObject definition that we define in the database descriptor for well-known objects.
|
protected <T extends SystemObject> |
listBuiltInObjectsImpl(DBObjectCriteria<T> criteria)
Implementation for listing built-in objects.
|
java.util.Collection<java.lang.String> |
listPreferredDataTypeNames()
Override to provide the names of the prefered types for the described database.
|
java.util.Collection<DataType> |
listPreferredDataTypes()
Lists the preferred datatypes of this provider.
|
java.util.Collection<java.lang.String> |
listSchemaNamespaceTypes(DBObjectProvider pro)
Gets all the object types that are in the schema namespace for the database - i.e.
|
java.util.Collection<DataType> |
listSupportedDataTypes()
Lists the datatypes supported by the described database type.
|
void |
makeNameValidAndUnique(DBObject object, DBObjectProvider pro)
Deprecated.
Use getUniqueName() in DBObjectProvider instead
|
protected boolean |
needsQuoting(java.lang.String internalName)
Determines whether internalName needs quoting to make it a valid external name.
|
java.lang.String |
quoteIdentifier(java.lang.String internalName, boolean force)
Determines if internalName needs quoting to make it a valid external name, and if so returns a quoted copy of it.
|
void |
setIdeCharset(java.nio.charset.Charset charSet) |
boolean |
supportsFeature(java.lang.String feature)
Deprecated.
the PropertyManager should be used to determine whether properties (and therefore features) are supported or not.
|
boolean |
supportsRowID(DBObjectProvider pro, java.lang.String objectName)
Tests whether ROWID is supported for the given provider and object name.
|
void |
validateEncoding(java.lang.String string, java.lang.Object property)
Tests whether the given string is encoded property for the given property.
|
static void |
validateIdentifier(java.lang.String identifier, char quoter, int maxLength, java.lang.String allowedChars, boolean alphaStart, java.util.Set reservedWords, int casePolicy)
Validates that name is a valid external name such that : If the name is unquoted (does not start with
quoter ), it only contains alphanumeric and allowedChars characters. If the name is unquoted, and alphaStart is true, it starts with a letter. If the name is unquoted, it does not contain any reservedWords . If the name is quoted (starts with quoter ), it is correctly quoted, and does not include any excludedChars . If the name is quoted, and quoter is not in excludedChars , that any occurences of quoter are escaped (doubled-up). The name does not exceed maxLength, taking quotes into account. Used by the more specific validate*Identifier() methods on the Database implementations. |
static void |
validateIdentifier(java.lang.String identifier, char quoter, int maxLength, java.lang.String allowedChars, java.lang.String excludedChars, boolean alphaStart, java.util.Set reservedWords, int casePolicy)
Validates that name is a valid external name such that : If the name is unquoted (does not start with
quoter ), it only contains alphanumeric and allowedChars characters. If the name is unquoted, and alphaStart is true, it starts with a letter. If the name is unquoted, it does not contain any reservedWords . If the name is quoted (starts with quoter ), it is correctly quoted, and does not include any excludedChars . If the name is quoted, and quoter is not in excludedChars , that any occurences of quoter are escaped (doubled-up). The name does not exceed maxLength, taking quotes into account. Used by the more specific validate*Identifier() methods on the Database implementations. |
abstract void |
validateName(java.lang.String type, java.lang.String name)
Validates the given object name and throws an InvalidNameExcpetion if it isn't valid for the Database being described.
|
@Deprecated public static final java.lang.String FEATURE_TABLE_PARTITIONING
@Deprecated public static final java.lang.String FEATURE_GLOBAL_HASH_INDEX_PARTITIONING
@Deprecated public static final java.lang.String FEATURE_COLUMN_SEQUENCES
@Deprecated public static final java.lang.String FEATURE_STORAGE_OPTIONS
@Deprecated public static final java.lang.String FEATURE_BITMAP_INDEXING
@Deprecated public static final java.lang.String FEATURE_LOB_PARAMETERS
@Deprecated public static final java.lang.String FEATURE_MAXTRANS
@Deprecated public static final java.lang.String FEATURE_XMLTYPE_COL_PROPS
public static final java.lang.String BUILT_IN_OBJECT
protected DatabaseDescriptor(java.lang.Class<? extends T> clz)
protected DatabaseDescriptor(DatabaseDescriptor base)
protected final java.lang.Class<? extends T> getDatabaseClass()
The class should not be needed externally as the datatbase type and version should be used when making decisions.
getDatabaseType()
, getDatabaseVersion()
public final java.lang.String getDatabaseName()
public abstract java.lang.String getDatabaseType()
public abstract int getDatabaseVersion()
protected DatabaseDescriptor getBaseDescriptor()
public void setIdeCharset(java.nio.charset.Charset charSet)
public java.nio.charset.Charset getIdeCharset()
public boolean isSameDatabase(DatabaseDescriptor other)
Note the descriptors need not be equal (e.g. one could be for a Database and one for different DBObjectProvider implementation).
other
- the other descriptor to testpublic boolean isCompatibleWith(DatabaseDescriptor other)
For example, if this descriptor is describing Oracle9i and the other descriptor is Oracle11g then this will return true
because that is a compatible database.
Conversly the descriptor for Oracle11g will return false
if asked whether it is compatible with Oracle9i because there are 11g features that are not present in 9i.
The base implementation simply checks that the "database type" of the two descriptors is the same, and that the "database version" of the other descriptor is greater than or equal to this descriptor's "database version".
other
- the db descriptor to testgetDatabaseType()
, getDatabaseVersion()
@Deprecated public final boolean isCompatibleUpgrade(java.lang.Class<? extends Database> dbClz, java.lang.Class<? extends Database> testClz)
isCompatibleWith(oracle.javatools.db.DatabaseDescriptor)
.public final boolean isValidName(java.lang.String type, java.lang.String name)
name
- the name to checkpublic abstract void validateName(java.lang.String type, java.lang.String name) throws InvalidNameException
public abstract int getCasePolicy()
AbstractDBObjectProvider.LOWER_CASE_NAME_POLICY
, AbstractDBObjectProvider.MIXED_CASE_NAME_POLICY
, AbstractDBObjectProvider.UPPER_CASE_NAME_POLICY
, AbstractDBObjectProvider.CASE_SENSITIVE_NAME_POLICY
@Deprecated public int getQuotedNameCasePolicy()
getCasePolicy()
covers both quoted and unquoted names.public final boolean areNamesEqual(DBObject obj1, DBObject obj2)
case policy
to work out how to compare the names.obj1
- the first objectobj2
- the second objectareNamesEqual(String,String,String,boolean)
public boolean areNamesEqual(java.lang.String name1, java.lang.String name2, java.lang.String objectType, boolean external)
case policy
to work out how to compare the names.name1
- the first name to compare.name2
- the second name to compare.objectType
- the object type that the names are for - can be null.external
- whether the names are in external form, so should be internalised before comparison.public abstract java.lang.String getIdentifierQuoteString()
public abstract int getMaxNameLength(java.lang.String type)
type
.@Deprecated public boolean supportsFeature(java.lang.String feature)
public void validateEncoding(java.lang.String string, java.lang.Object property) throws ValidationException
string
- the string to testproperty
- the property identifier that the string is a value forValidationException
- if the encoding is invalidprotected boolean needsQuoting(java.lang.String internalName)
internalName
-public java.lang.String quoteIdentifier(java.lang.String internalName, boolean force) throws DBException
internalName
-force
- Always quote the nameDBException
protected java.lang.String escapeQuoteCharacter(java.lang.String quote)
public java.lang.String getInternalName(java.lang.String name, java.lang.String objectType)
name
- a String containing the name to convertobjectType
- the type of object the name is forpublic java.lang.String getExternalName(java.lang.String name, java.lang.String objectType)
quoteIdentifier
, specifying false
for the force argument. Note, however, that exceptions are not thrown; rather, the original name will be returned.name
- a String containing the name to externalizepublic final java.util.Collection<java.lang.String> listSchemaNamespaceTypes(DBObjectProvider pro)
public abstract java.util.Map<java.lang.String,DBObjectValidator> getValidators(DBObjectProvider pro)
public DBObjectLister getTriggerLister(DBObjectProvider pro)
DBObjectCriteria
. NB. As a DBObjectCriteria is used to specify SystemObjects
, the Trigger DBObjectLister cannot be used to list DATABASE level triggers, only TABLE, VIEW and SCHEMA level.pro
- the DBObjectProviderpublic java.util.List<PropertyInitializer> getPropertyInitializers(DBObjectProvider pro)
@Deprecated public java.util.List<PropertyInitializer> getExternalPropertyDefaulters(DBObjectProvider pro)
PropertyManager.getImplicitDefaultValue(oracle.javatools.db.DBObject, java.lang.String)
public java.util.List<UpdateProcessor> getUpdateProcessors()
public DDLGenerator getDDLGenerator(DBObjectProvider pro)
Note the parameter is a DBObjectProvider. All DDLGenerator implementations must be instantiable with a DBObjectProvider so that generic features (like the offline database) can leverage DDL generation for all supported databases.
pro
- the provider to initialise the DDLGenerator withpublic SQLQueryBuilderFactory getSQLQueryBuilderFactory()
SQLQueryBuilder
for this database type.public DerivedPropertyBuilder getDerivedPropertyBuilder(java.lang.Class<? extends AbstractBuildableObject> objClz, DBObjectProvider pro)
objClz
- the class of object to build.pro
- the provider the object is from.public boolean supportsRowID(DBObjectProvider pro, java.lang.String objectName)
pro
- the provider to test inobjectName
- the name of the object to testpublic java.util.Collection<DataType> listSupportedDataTypes()
public final java.util.Collection<DataType> listPreferredDataTypes()
listPreferredDataTypeNames()
public java.util.Collection<java.lang.String> listPreferredDataTypeNames()
listPreferredDataTypes()
, createDefaultTypeUsage()
public DataTypeUsage createDefaultTypeUsage()
listPreferredDataTypes()
returns any types, this will be a usage of the first type in that list. Otherwise a VARCHAR or CHAR type will be searched for and a usage of that returned.public DataType getDataType(java.lang.String typeName)
typeName
- the type to getpublic final <T extends SystemObject> java.util.Collection<T> listBuiltInObjects(DBObjectCriteria<T> criteria)
protected <T extends SystemObject> java.util.Collection<T> listBuiltInObjectsImpl(DBObjectCriteria<T> criteria)
protected void initialiseBuiltInObject(SystemObject obj)
obj
-public java.lang.String getPublicSchemaName()
public final boolean isValidFKDataType(DataType fktype, DataType reftype)
fktype
- the datatype of the column in the foreign keyreftype
- the datatype of the column in the parent table's referenced constraint@Deprecated public void makeNameValidAndUnique(DBObject object, DBObjectProvider pro) throws InvalidNameException
InvalidNameException
public java.util.Collection<java.lang.String> getReservedWords()
public SqlAliasExpander getSqlAliasExpander(DBObjectProvider pro)
public SqlAliasExpander getSqlAliasExpander(DBObjectProvider pro, Schema defaultSchema)
public static void validateIdentifier(java.lang.String identifier, char quoter, int maxLength, java.lang.String allowedChars, java.lang.String excludedChars, boolean alphaStart, java.util.Set reservedWords, int casePolicy) throws InvalidNameException
quoter
), it only contains alphanumeric and allowedChars
characters.alphaStart
is true, it starts with a letter.reservedWords
.quoter
), it is correctly quoted, and does not include any excludedChars
.quoter
is not in excludedChars
, that any occurences of quoter
are escaped (doubled-up).identifier
- the external name to checkquoter
- the quote string (e.g. " )maxLength
- the maximum length a name can be (not including quotes)allowedChars
- characters that are allowed in an unquoted identifier (aswell as alphanumerics)excludedChars
- characters that are not allowed in quoted identifiers.alphaStart
- whether to enforce that the unquoted identifiers must start with an alphabet character.reservedWords
- Set of words that are reserved in the databasecasePolicy
- the case policy to useInvalidNameException
- with an appropriate message if the identifier isn't valid.public final DefaultSourceOptions getDefaultSourceOptions()
protected void initialiseDefaultSourceOptions(DefaultSourceOptions opts)
public static void validateIdentifier(java.lang.String identifier, char quoter, int maxLength, java.lang.String allowedChars, boolean alphaStart, java.util.Set reservedWords, int casePolicy) throws InvalidNameException
quoter
), it only contains alphanumeric and allowedChars
characters.alphaStart
is true, it starts with a letter.reservedWords
.quoter
), it is correctly quoted, and does not include any excludedChars
.quoter
is not in excludedChars
, that any occurences of quoter
are escaped (doubled-up).identifier
- the external name to checkquoter
- the quote string (e.g. " )maxLength
- the maximum length a name can be (not including quotes)allowedChars
- characters that are allowed in an unquoted identifier (aswell as alphanumerics)alphaStart
- whether to enforce that the unquoted identifiers must start with an alphabet character.reservedWords
- Set of words that are reserved in the databasecasePolicy
- the case policy to useInvalidNameException
- with an appropraite message if the identifier isn't valid.