Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

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

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

public class TokenDDLGenerator<T extends DDLType>
extends AbstractPropertyManager

TokenDDLGenerator is DDLGenerator implementation that takes the registration of "ddl code tokens" and registers CreateDDLGenerator, DropDDLGenerator and AlterDDLGenerator with the superclass as appropriate. This allows users (or subclasses) to create a full DDLGenerator implementation just by provider ddl "token code" which will then be processed as appropriate when DDL is requested.

Since:
11

Constructor Summary
TokenDDLGenerator(DBObjectProvider pro)
          Note the first parameter is a DBObjectProvider.
 
Method Summary
protected  DDL append(DDL ddl1, DDL ddl2)
          Appends the two ddls together and returns the result coping with either being null.
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  void copyGenerators(oracle.javatools.db.ddl.DDLGeneratorImpl other, java.lang.String type, boolean incAlter)
          Copies the ddl generators for the given object type from this generator to another generator implementation.
protected  DDL createDDL(DDLOptions options, java.lang.String code, DBObject obj, DDLType ddlType)
          Creates a new DDL object with the given ddlCode by processing the given code using a TokenProcessor and using the resulting String as the DDL string.
protected  DDL createUpdateDDL(DDLOptions options, java.lang.String code, Difference rs, DDLType ddlType)
          Creates a new update DDL object with the given ddlCode by processing the given update code using a TokenProcessor and using the resulting String as the DDL string.
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)
          Deprecated. 
 Ddl getCreateDDL(SchemaObject[] objects, boolean replace, boolean cascade)
          Deprecated. 
 Ddl getCreateDDL(SchemaObject obj, boolean replace, boolean cascade)
          Deprecated. 
protected  DDL<T> getCreateDDLImpl(DDLOptions options, DBObject... objects)
           
 DDL<T> getDeleteDDL(DDLOptions options, DBObject... objects)
          Gets DROP statements for the given objects.
 Ddl getDeleteDDL(Schema schema, boolean cascade)
          Deprecated. 
 Ddl getDeleteDDL(SchemaObject[] objects, boolean cascade)
          Deprecated. 
 Ddl getDeleteDDL(SchemaObject object, boolean cascade)
          Deprecated. 
protected  DDL<T> getDeleteDDLImpl(DDLOptions options, DBObject... objects)
           
protected  PropertyHelper getPropertyHelper()
           
 DDL<T> getUndeleteDDL(DDLOptions options, DBObject... objects)
          Gets statements to undelete (e.g.
 DDL<T> getUpdateDDL(DDLOptions options, Difference resultSet)
          Gets ALTER statements for the given objects where possible, or DROP/CREATE, or CREATE AND REPLACE where appropriate/necessary.
 Ddl[] getUpdateDDL(Difference resultSet, boolean replace, boolean cascade)
          Deprecated. 
 Ddl[] getUpdateDDL(SchemaObject[] oldObjects, SchemaObject[] newObjects)
          Deprecated. 
 Ddl[] getUpdateDDL(SchemaObject oldObject, SchemaObject newObject)
          Deprecated. 
protected  DDL<T> getUpdateDDLImpl(DDLOptions options, Difference rs)
          Gets the update DDL for the given Difference.
 void includeSyntax(DatabaseDescriptor otherDatabase, java.lang.String type, boolean includeAlter)
          Includes the ddl syntax from another database type's ddl generator into this ddl generator for a given object type.
 void registerAlterDDL(java.lang.String type, java.lang.String code, DDLType ddlType)
           
protected  void registerAlterGenerator(java.lang.String type, AlterDDLGenerator deletor)
           
 void registerCreateDDL(java.lang.String type, java.lang.String code, DDLType ddlType)
           
protected  void registerCreateGenerator(java.lang.String type, CreateDDLGenerator creator)
           
 void registerDropDDL(java.lang.String type, java.lang.String code, DDLType ddlType)
           
protected  void registerDropGenerator(java.lang.String type, DropDDLGenerator dropper)
           
 void registerTokenGenerator(java.lang.String tokenName, TokenGenerator gen)
          Registers the given token generator for a tokenName.
protected  void registerTopLevelChild(java.lang.String type, java.lang.String propPath, java.lang.String childType)
          Registers a child object property, that can be treated as a top level object in the ddl, and therefore when encountered the generator should recurse onto the object.
 void registerUndeleteDDL(java.lang.String type, java.lang.String code, DDLType ddlType)
           
protected  void registerUndeleteGenerator(java.lang.String type, UndeleteDDLGenerator undeletor)
           
 boolean supportsAction(java.lang.String type, PropertyAction.Type actionType)
          Asks whether a given action is supported for the specified object type in this provider.
 
Methods inherited from class oracle.javatools.db.property.AbstractPropertyManager
canAlterProperty, 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
canAlterProperty, canChangeProperty, canUpdateObject, canUpdateObject, supportsProperty
 

Constructor Detail

TokenDDLGenerator

public TokenDDLGenerator(DBObjectProvider pro)
Note the first 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.

Method Detail

registerTokenGenerator

public void registerTokenGenerator(java.lang.String tokenName,
                                   TokenGenerator gen)
Registers the given token generator for a tokenName.

Parameters:
tokenName - the token name this new generator is responsible for
gen - the generator itself

registerCreateDDL

public final void registerCreateDDL(java.lang.String type,
                                    java.lang.String code,
                                    DDLType ddlType)

registerDropDDL

public final void registerDropDDL(java.lang.String type,
                                  java.lang.String code,
                                  DDLType ddlType)

registerUndeleteDDL

public final void registerUndeleteDDL(java.lang.String type,
                                      java.lang.String code,
                                      DDLType ddlType)

registerAlterDDL

public final void registerAlterDDL(java.lang.String type,
                                   java.lang.String code,
                                   DDLType ddlType)

createDDL

protected DDL createDDL(DDLOptions options,
                        java.lang.String code,
                        DBObject obj,
                        DDLType ddlType)
Creates a new DDL object with the given ddlCode by processing the given code using a TokenProcessor and using the resulting String as the DDL string.

This method can return null if the token processor returns an empty string. This is possible if the entire statement is an "if" which is allowed for certain DDL statements (which may only execute given certain conditions/properties).

Parameters:
options - the ddl generation options
code - the token code to process
obj - the context object
ddlCode - the type of DDL we are creating
Returns:
a newly created DDL object

createUpdateDDL

protected DDL createUpdateDDL(DDLOptions options,
                              java.lang.String code,
                              Difference rs,
                              DDLType ddlType)
Creates a new update DDL object with the given ddlCode by processing the given update code using a TokenProcessor and using the resulting String as the DDL string.

This method can return null if the token processor returns an empty string. This is possible if the entire statement is an "if" which is allowed for certain DDL statements (which may only execute given certain conditions/properties).

Parameters:
options - the ddl generation options
code - the token code to process
rs - the changes to generate update DDL for
ddlCode - the type of DDL we are creating
Returns:
a newly created DDL object

includeSyntax

public void includeSyntax(DatabaseDescriptor otherDatabase,
                          java.lang.String type,
                          boolean includeAlter)
Includes the ddl syntax from another database type's ddl generator into this ddl generator for a given object type. If the other database's ddl generator is incompatible (or has no syntax for the given object type) this will do nothing.

Parameters:
otherDatabase - the descriptor for the type of database the syntax is to be included from
type - the object type the ddl is for
includeAlter - whether to include alter syntax (true), or just create and drop (false).

getPropertyHelper

protected PropertyHelper getPropertyHelper()

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)

copyGenerators

protected final void copyGenerators(oracle.javatools.db.ddl.DDLGeneratorImpl other,
                                    java.lang.String type,
                                    boolean incAlter)
Copies the ddl generators for the given object type from this generator to another generator implementation.

Parameters:
other - the ddl generator to copy syntax to
type - the object type to copy
incAlter - whether to include alter ddl statements, or just create and drop.

registerTopLevelChild

protected final void registerTopLevelChild(java.lang.String type,
                                           java.lang.String propPath,
                                           java.lang.String childType)
Registers a child object property, that can be treated as a top level object in the ddl, and therefore when encountered the generator should recurse onto the object. For example, Indexes exist on Tables and are also objects that can be created in their own right. The ddl statements for both are identical, so to provide support for indexes on tables, the child type is registered using this method.

Parameters:
type - the parent object type (e.g. Table.TYPE)
propPath - the path to the child property (e.g. indexes)
childType - the child object type that can be treated in its own right in the ddl generator (e.g. Index.TYPE)

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,
                                  Difference rs)
Gets the update DDL for the given Difference. The Difference should be a generic DBObject diff and will be at the object level (i.e. it will be a MAP Difference 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 Difference 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.


supportsAction

public boolean supportsAction(java.lang.String type,
                              PropertyAction.Type actionType)
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

getCreateDDL

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

Specified by:
getCreateDDL in interface DDLGenerator<T extends DDLType>

getDeleteDDL

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

Specified by:
getDeleteDDL in interface DDLGenerator<T extends DDLType>

getUpdateDDL

public final DDL<T> getUpdateDDL(DDLOptions options,
                                 Difference 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.

Specified by:
getUpdateDDL in interface DDLGenerator<T extends DDLType>

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 - can be null

append

protected DDL append(DDL ddl1,
                     DDL ddl2)
Appends the two ddls together and returns the result coping with either being null.


getCreateDDL

@Deprecated
public final Ddl getCreateDDL(SchemaObject obj,
                                         boolean replace,
                                         boolean cascade)
Deprecated. 


getCreateDDL

@Deprecated
public final Ddl getCreateDDL(SchemaObject[] objects,
                                         boolean replace,
                                         boolean cascade)
Deprecated. 


getDeleteDDL

@Deprecated
public final Ddl getDeleteDDL(SchemaObject object,
                                         boolean cascade)
Deprecated. 


getDeleteDDL

@Deprecated
public final Ddl getDeleteDDL(SchemaObject[] objects,
                                         boolean cascade)
Deprecated. 


getUpdateDDL

@Deprecated
public final Ddl[] getUpdateDDL(SchemaObject oldObject,
                                           SchemaObject newObject)
Deprecated. 


getUpdateDDL

@Deprecated
public final Ddl[] getUpdateDDL(SchemaObject[] oldObjects,
                                           SchemaObject[] newObjects)
Deprecated. 


getUpdateDDL

@Deprecated
public final Ddl[] getUpdateDDL(Difference resultSet,
                                           boolean replace,
                                           boolean cascade)
Deprecated. 


getCreateDDL

@Deprecated
public final Ddl getCreateDDL(Schema schema)
Deprecated. 


getDeleteDDL

@Deprecated
public final Ddl getDeleteDDL(Schema schema,
                                         boolean cascade)
Deprecated. 


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

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