Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.1.0)

E13403-02

oracle.javatools.db.ddl
Class BundleDDLGenerator<T extends DDLType>

java.lang.Object
  extended by oracle.javatools.db.property.AbstractPropertyManager
      extended by oracle.javatools.db.ddl.TokenDDLGenerator<T>
          extended by oracle.javatools.db.ddl.BundleDDLGenerator<T>
All Implemented Interfaces:
DDLGenerator, PropertyManager

public abstract class BundleDDLGenerator<T extends DDLType>
extends TokenDDLGenerator<T>

TokenDDLGenerator subclass that uses either a set of Properties files or ResourceBundles with specially formatted keys to automatically register DDL for generation. In addition to the automatic registration process, additional tokens can be registered from the bundles by calling the registerBundle* methods from a subclass.

If the a key in a bundle is of the form:
TYPE.ACTION.DDLTYPE
e.g. TABLE.CREATE.TAB or SEQUENCE.ALTER.SEQ
then its value will automatically be registered as a token for that object TYPE against the given ACTION (CREATE, DROP, UNDELETE, or ALTER). The final DDLTYPE value is passed to getDDLType(java.lang.String) method which should return a DDLType appropriate to this generator.

When processing the entries of the resoure bundle, if any key contains two "."s and doesn't match a type, action or ddltype a severe message will be logged on the logger.


Constructor Summary
BundleDDLGenerator(DBObjectProvider pro, java.lang.String... resourceNames)
          Note the first parameter is a DBObjectProvider, not a Database.
 
Method Summary
protected  void addBundles(java.util.ResourceBundle... bundles)
          Adds the given bundles to this generator.
protected  void addResourceNames(java.lang.String... resourceNames)
          Adds the given resource names to this generator.
protected  boolean canChangeWithAlter(DBObject orig, DBObject update, java.lang.String prop)
          Returns true if the given property can be changed using an alter on the given original and updated objects.
protected  boolean canCreate(java.lang.String type, java.lang.String prop)
          Tests whether the given property is supported for create on the given object type.
protected  java.lang.String findResource(java.lang.String key)
           
protected  DDL<T> finish(DDLOptions options, DDL<T> ddl)
          This method is called on every DDL created before it is returned.
 DDL<T> getCreateDDL(DDLOptions options, DBObject... objects)
          Gets CREATE statements for the given objects.
 Ddl getCreateDDL(Schema schema)
          Retrieves the DDL for creating a new Schema
 Ddl getCreateDDL(SchemaObject[] objects, boolean replace, boolean cascade)
          Retrieves the DDL for creating the specified objects.
 Ddl getCreateDDL(SchemaObject obj, boolean replace, boolean cascade)
          Retrieves the DDL for creating the specified object.
protected  DDL<T> getCreateDDLImpl(DDLOptions options, DBObject... objects)
           
protected abstract  T getDDLType(java.lang.String type)
          Implement in subclasses to return the right DDLType implementation for the given string.
 DDL<T> getDeleteDDL(DDLOptions options, DBObject... objects)
          Gets DROP statements for the given objects.
 Ddl getDeleteDDL(Schema schema, boolean cascade)
           
 Ddl getDeleteDDL(SchemaObject[] objects, boolean cascade)
          Retrieves the DDL for deleting an array of objects.
 Ddl getDeleteDDL(SchemaObject object, boolean cascade)
          Retrieves the DDL for deleting an object.
protected  DDL<T> getDeleteDDLImpl(DDLOptions options, DBObject... objects)
           
protected  DiffEngine getLegacyDiffEngine(java.lang.String type)
          Deprecated. 
 DDL<T> getUndeleteDDL(DDLOptions options, DBObject... objects)
          Gets statements to undelete (e.g.
 DDL<T> getUpdateDDL(DDLOptions options, ResultSet resultSet)
          Gets ALTER statements for the given objects where possible, or DROP/CREATE, or CREATE AND REPLACE where appropriate/necessary.
 Ddl[] getUpdateDDL(ResultSet resultSet, boolean replace, boolean cascade)
          Retrieves the DDL for updating the definition of an object.
 Ddl[] getUpdateDDL(SchemaObject[] oldObjects, SchemaObject[] newObjects)
          Retrieves DDL to update an array of SchemaObject objects.
 Ddl[] getUpdateDDL(SchemaObject oldObject, SchemaObject newObject)
          Retrieves the DDL for updating the definition of an object.
protected  DDL<T> getUpdateDDLImpl(DDLOptions options, ResultSet rs)
          Gets the update DDL for the given ResultSet.
protected  void processResultSet(DDLOptions options, ResultSet rs, DDL<T> ddl)
           
protected  void registerAlterGenerator(java.lang.String type, AlterDDLGenerator deletor)
           
protected  void registerBundleAlterDDL(java.lang.String type, java.lang.String resName, T ddlType)
          Registers alter DDL code from the ResourceBundle by the resource name of the code in that bundle.
protected  void registerBundleCreateDDL(java.lang.String type, java.lang.String resName, T ddlType)
          Registers create DDL code from the ResourceBundle by the resource name of the code in that bundle.
protected  void registerBundleDropDDL(java.lang.String type, java.lang.String resName, T ddlType)
          Registers drop DDL code from the ResourceBundle by the resource name of the code in that bundle.
protected  void registerBundleTokens()
          Registers all the tokens in the underyling resource bundles.
protected  void registerBundleUndeleteDDL(java.lang.String type, java.lang.String resName, T ddlType)
          Registers undelete DDL code from the ResourceBundle by the resource name of the code in that bundle.
protected  void registerCreateGenerator(java.lang.String type, CreateDDLGenerator creator)
           
protected  void registerDropGenerator(java.lang.String type, DropDDLGenerator dropper)
           
protected  void registerUndeleteGenerator(java.lang.String type, UndeleteDDLGenerator undeletor)
           
 void setOldGenerator(AbstractDDLGenerator oldGen)
          Deprecated. - the old DDLGenerator API is deprecated so this method will be removed when it is.
 boolean supportsAction(java.lang.String type, PropertyAction action)
          Asks whether a given action is supported for the specified object type in this provider.
 
Methods inherited from class oracle.javatools.db.ddl.TokenDDLGenerator
createDDL, createUpdateDDL, registerAlterDDL, registerCreateDDL, registerDropDDL, registerTokenGenerator, registerUndeleteDDL
 
Methods inherited from class oracle.javatools.db.property.AbstractPropertyManager
canChangeProperty, canChangeWithReplace, canCreate, canUpdateObject, canUpdateObject, getLogger, getProvider, getProviderClass, supportsProperty, supportsProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.javatools.db.property.PropertyManager
canChangeProperty, canUpdateObject, canUpdateObject, supportsProperty
 

Constructor Detail

BundleDDLGenerator

public BundleDDLGenerator(DBObjectProvider pro,
                          java.lang.String... resourceNames)
Note the first parameter is a DBObjectProvider, not a Database. 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.

If the resourceNames parameter is non-null this will call #addResourcesNames and therefore initialise the generator. If resourceNames is omitted, addResourceNames(java.lang.String...) or addBundles(java.util.ResourceBundle...) must be called for the generator to function.

Parameters:
pro - the provider for this generator to use for name externalisation etc
bundles - either Strings (for properties files) or ResourceBundles that contains the ddl token syntax.
Method Detail

addResourceNames

protected void addResourceNames(java.lang.String... resourceNames)
Adds the given resource names to this generator. Resource names are the names of properties files to load that contain the token syntax for the ddl.This or addBundles(java.util.ResourceBundle...) should be called only once for a given generator to avoid duplicate registration of resources.

Parameters:
resourceNames - the names of properties files containing the resources

addBundles

protected void addBundles(java.util.ResourceBundle... bundles)
Adds the given bundles to this generator. The resource bundles should contain the token syntax for the ddl. This or addResourceNames(java.lang.String...) should be called only once for a given generator to avoid duplicate registration of resources.

Parameters:
bundles - the ResourceBundles containing the ddl token strings.

findResource

protected final java.lang.String findResource(java.lang.String key)

registerBundleTokens

protected final void registerBundleTokens()
Registers all the tokens in the underyling resource bundles.


getDDLType

protected abstract T getDDLType(java.lang.String type)
Implement in subclasses to return the right DDLType implementation for the given string.


registerBundleCreateDDL

protected final void registerBundleCreateDDL(java.lang.String type,
                                             java.lang.String resName,
                                             T ddlType)
Registers create DDL code from the ResourceBundle by the resource name of the code in that bundle.

See Also:
TokenDDLGenerator.registerCreateDDL(String,String,oracle.javatools.db.ddl.DDLType)

registerBundleDropDDL

protected final void registerBundleDropDDL(java.lang.String type,
                                           java.lang.String resName,
                                           T ddlType)
Registers drop DDL code from the ResourceBundle by the resource name of the code in that bundle.

See Also:
TokenDDLGenerator.registerDropDDL(String,String,oracle.javatools.db.ddl.DDLType)

registerBundleUndeleteDDL

protected final void registerBundleUndeleteDDL(java.lang.String type,
                                               java.lang.String resName,
                                               T ddlType)
Registers undelete DDL code from the ResourceBundle by the resource name of the code in that bundle.

See Also:
TokenDDLGenerator.registerDropDDL(String,String,oracle.javatools.db.ddl.DDLType)

registerBundleAlterDDL

protected final void registerBundleAlterDDL(java.lang.String type,
                                            java.lang.String resName,
                                            T ddlType)
Registers alter DDL code from the ResourceBundle by the resource name of the code in that bundle.

See Also:
TokenDDLGenerator.registerAlterDDL(String,String,oracle.javatools.db.ddl.DDLType)

registerCreateGenerator

protected final void registerCreateGenerator(java.lang.String type,
                                             CreateDDLGenerator creator)

registerDropGenerator

protected final void registerDropGenerator(java.lang.String type,
                                           DropDDLGenerator dropper)

registerAlterGenerator

protected final void registerAlterGenerator(java.lang.String type,
                                            AlterDDLGenerator deletor)

registerUndeleteGenerator

protected final void registerUndeleteGenerator(java.lang.String type,
                                               UndeleteDDLGenerator undeletor)

getCreateDDLImpl

protected DDL<T> getCreateDDLImpl(DDLOptions options,
                                  DBObject... objects)

getDeleteDDLImpl

protected DDL<T> getDeleteDDLImpl(DDLOptions options,
                                  DBObject... objects)

getUndeleteDDL

public DDL<T> getUndeleteDDL(DDLOptions options,
                             DBObject... objects)
Description copied from interface: DDLGenerator
Gets statements to undelete (e.g. FLASHBACK) the given objects.


getUpdateDDLImpl

protected DDL<T> getUpdateDDLImpl(DDLOptions options,
                                  ResultSet rs)
Gets the update DDL for the given ResultSet. The ResultSet should be a generic DBObject diff and will be at the object level (i.e. it will be a MAP ResultSet that has a SchemaObject as a() and b() for which we require the update DDL if possible, otherwise drop/recreate DDL.

Parameters:
options - the options for generation
rs - the ResultSet for the object to alter
Returns:
the DDL to perform the operation

canCreate

protected boolean canCreate(java.lang.String type,
                            java.lang.String prop)
Description copied from class: AbstractPropertyManager
Tests whether the given property is supported for create on the given object type.


finish

protected DDL<T> finish(DDLOptions options,
                        DDL<T> ddl)
This method is called on every DDL created before it is returned. It allows implementations to customise the ddl given the options (e.g. to add prompts).

Parameters:
options - the options for the current generation
ddl - the ddl we've generated and are about to return

supportsAction

public boolean supportsAction(java.lang.String type,
                              PropertyAction action)
Description copied from interface: PropertyManager
Asks whether a given action is supported for the specified object type in this provider.

Specified by:
supportsAction in interface PropertyManager

canChangeWithAlter

protected boolean canChangeWithAlter(DBObject orig,
                                     DBObject update,
                                     java.lang.String prop)
Description copied from class: AbstractPropertyManager
Returns true if the given property can be changed using an alter on the given original and updated objects.

Overrides:
canChangeWithAlter in class AbstractPropertyManager

setOldGenerator

@Deprecated
public final void setOldGenerator(AbstractDDLGenerator oldGen)
Deprecated. - the old DDLGenerator API is deprecated so this method will be removed when it is.

Sets the old ddl generator implementation if this provider still has one.


getCreateDDL

public final DDL<T> getCreateDDL(DDLOptions options,
                                 DBObject... objects)
Description copied from interface: DDLGenerator
Gets CREATE statements for the given objects.


getDeleteDDL

public final DDL<T> getDeleteDDL(DDLOptions options,
                                 DBObject... objects)
Description copied from interface: DDLGenerator
Gets DROP statements for the given objects.


getUpdateDDL

public final DDL<T> getUpdateDDL(DDLOptions options,
                                 ResultSet resultSet)
Description copied from interface: DDLGenerator
Gets ALTER statements for the given objects where possible, or DROP/CREATE, or CREATE AND REPLACE where appropriate/necessary.


getLegacyDiffEngine

@Deprecated
protected DiffEngine getLegacyDiffEngine(java.lang.String type)
Deprecated. 


processResultSet

protected final void processResultSet(DDLOptions options,
                                      ResultSet rs,
                                      DDL<T> ddl)

getCreateDDL

public final Ddl getCreateDDL(SchemaObject obj,
                              boolean replace,
                              boolean cascade)
Description copied from interface: DDLGenerator
Retrieves the DDL for creating the specified object.

If the replace option is specified, and the object exists in the provider, DDL is create to drop the object. (except views, where CREATE OR REPLACE is generated)

Specified by:
getCreateDDL in interface DDLGenerator
Parameters:
obj - the object for which DDL is required
replace - whether an existing object should be replaced
cascade - whether any DROP associated with replace should be cascaded
Returns:
a string array containing the DDL statements necessary to create the object

getCreateDDL

public final Ddl getCreateDDL(SchemaObject[] objects,
                              boolean replace,
                              boolean cascade)
Description copied from interface: DDLGenerator
Retrieves the DDL for creating the specified objects.

If the replace option is specified, DDL is generated to drop all the Foreign Keys in the tables in the specified objects. DDL is then generated to drop all of the specified objects (except views) which exist in the provider.

Specified by:
getCreateDDL in interface DDLGenerator
replace - whether an existing object should be replaced
cascade - whether any DROP associated with replace should be cascaded
Returns:
a string array containing the DDL statements necessary to create the objects

getDeleteDDL

public final Ddl getDeleteDDL(SchemaObject object,
                              boolean cascade)
Description copied from interface: DDLGenerator
Retrieves the DDL for deleting an object.

Specified by:
getDeleteDDL in interface DDLGenerator
Parameters:
object - the object to be deleted
cascade - a boolean value indicating whether a cascade delete should be performed, if appropriate for the object type
Returns:
a string array containing the DDL statements for deleting the object

getDeleteDDL

public final Ddl getDeleteDDL(SchemaObject[] objects,
                              boolean cascade)
Description copied from interface: DDLGenerator
Retrieves the DDL for deleting an array of objects.

Specified by:
getDeleteDDL in interface DDLGenerator
cascade - a boolean value indicating whether a cascade delete should be performed, if appropriate for the object type
Returns:
a string array containing the DDL statements for deleting the object

getUpdateDDL

public final Ddl[] getUpdateDDL(SchemaObject oldObject,
                                SchemaObject newObject)
Description copied from interface: DDLGenerator
Retrieves the DDL for updating the definition of an object.

Specified by:
getUpdateDDL in interface DDLGenerator
Parameters:
oldObject - the original version of the object
newObject - the updated data model
Returns:
a array of objects containing the DDL statements that will update the old object to the new model

getUpdateDDL

public final Ddl[] getUpdateDDL(SchemaObject[] oldObjects,
                                SchemaObject[] newObjects)
Description copied from interface: DDLGenerator
Retrieves DDL to update an array of SchemaObject objects.

The generated DDL will modified the dbUpdatable objects to match the dbMaster objects.

Specified by:
getUpdateDDL in interface DDLGenerator
Parameters:
oldObjects - the original versions of the objects
newObjects - the updated data model
Returns:
an array of objects containing the DDL statements that will update the old objects to the new model

getUpdateDDL

public final Ddl[] getUpdateDDL(ResultSet resultSet,
                                boolean replace,
                                boolean cascade)
Description copied from interface: DDLGenerator
Retrieves the DDL for updating the definition of an object.

Specified by:
getUpdateDDL in interface DDLGenerator
Parameters:
resultSet - description of the differences between two objects
replace - whether to replace any existing objects being created
cascade - whether to cascade the delete of any objects
Returns:
the DDL statements that will update the old object to the new model

getCreateDDL

public final Ddl getCreateDDL(Schema schema)
Description copied from interface: DDLGenerator
Retrieves the DDL for creating a new Schema

Specified by:
getCreateDDL in interface DDLGenerator
Parameters:
schema - the Schema for which the DDL is required
Returns:
an array of the DDL statements for creating the new Schema

getDeleteDDL

public final Ddl getDeleteDDL(Schema schema,
                              boolean cascade)
Specified by:
getDeleteDDL in interface DDLGenerator

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.1.0)

E13403-02

Copyright © 1997, 2009, Oracle. All rights reserved.