Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.4.1 generated on May 30 2006
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## kodo.jdbc.schema
Class SchemaGenerator

    java.lang.Object
      |
      +--kodo.jdbc.schema.SchemaGenerator

public class SchemaGenerator
extends Object

The SchemaGenerator creates `Schema`s matching the current database. All schemas are added to the current `SchemaGroup`.

Note that tables whose name starts with "JDO" will be not be added to the database schema. This enables the creation of special tables that will never be dropped by the `SchemaTool`.

Inner Class Summary
`class` | `SchemaGenerator.Event` An event corresponding to the generation of a schema object.
`static interface` | `SchemaGenerator.Listener` A listener for a potentially lengthy schema generation process.

Constructor Summary
`SchemaGenerator(JDBCConfiguration conf)` Constructor.

Method Summary
`void` | `addListener(SchemaGenerator.Listener l)` Adds a listener for schema generation events.
`void` | `generateForeignKeys(String schemaName, String[] tableNames)` Generate foreign key information for the given schema.
`void` | `generateForeignKeys(String schemaName, String tableName, Connection conn, DatabaseMetaData meta)` Generates table foreign keys.
`void` | `generateIndexes(String schemaName, String[] tableNames)` Generate index information for the given schema.
`void` | `generateIndexes(String schemaName, String tableName, Connection conn, DatabaseMetaData meta)` Generates table indexes.
`void` | `generatePrimaryKeys(String schemaName, String[] tableNames)` Generate primary key information for the given schema.
`void` | `generatePrimaryKeys(String schemaName, String tableName, Connection conn, DatabaseMetaData meta)` Generates table primary keys.
`void` | `generateSchema(String name, String[] tableNames)` Add a fully-constructed `Schema` matching the given database schema to the current group.
`void` | `generateSchemas()` Generate all schemas set in the configuration.
`void` | `generateSchemas(String[] schemasAndTables)` Generate the schemas and/or tables named in the given strings.
`void` | `generateTables(String schemaName, String tableName, Connection conn, DatabaseMetaData meta)` Adds all tables matching the given name pattern to the schema.
`boolean` | `getForeignKeys()` Return whether foreign keys should be generated.
`boolean` | `getIndexes()` Return whether indexes should be generated.
`boolean` | `getKodoTables()` Whether to generate info on special tables used by Kodo components for bookkeeping.
`boolean` | `getPrimaryKeys()` Return whether primary keys should be generated.
`SchemaGroup` | `getSchemaGroup()` Return the current schema group.
`static void` | `main(String[] args)` Usage: java kodo.jdbc.schema.SchemaGenerator [option]*
`boolean` | `removeListener(SchemaGenerator.Listener l)` Removes a schema generation listener for schema events.
`static void` | `run(JDBCConfiguration conf, boolean pks, boolean indexes, boolean fks, boolean kodoTables, Writer out)` Run the tool.
`static boolean` | `run(JDBCConfiguration conf, String[] args, serp.util.Options opts)` Run the tool.
`void` | `setForeignKeys(boolean fks)` Set whether foreign keys should be generated.
`void` | `setIndexes(boolean indexes)` Set whether indexes should be generated.
`void` | `setKodoTables(boolean kodoTables)` Whether to generate info on special tables used by Kodo components for bookkeeping.
`void` | `setPrimaryKeys(boolean pks)` Set whether primary keys should be generated.
`void` | `setSchemaGroup(SchemaGroup group)` Set the schema group to add generated schemas to.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SchemaGenerator

    public SchemaGenerator(JDBCConfiguration conf)

  Constructor.
  Parameters:
    `conf` - configuration for connecting to the data store

Method Detail

### getIndexes

    public boolean getIndexes()

  Return whether indexes should be generated. Defaults to true.

### setIndexes

    public void setIndexes(boolean indexes)

  Set whether indexes should be generated. Defaults to true.

### getForeignKeys

    public boolean getForeignKeys()

  Return whether foreign keys should be generated. Defaults to true.

### setForeignKeys

    public void setForeignKeys(boolean fks)

  Set whether foreign keys should be generated. Defaults to true.

### getPrimaryKeys

    public boolean getPrimaryKeys()

  Return whether primary keys should be generated. Defaults to true.

### setPrimaryKeys

    public void setPrimaryKeys(boolean pks)

  Set whether primary keys should be generated. Defaults to true.

### getKodoTables

    public boolean getKodoTables()

  Whether to generate info on special tables used by Kodo components for bookkeeping. Defaults to false.

### setKodoTables

    public void setKodoTables(boolean kodoTables)

  Whether to generate info on special tables used by Kodo components for bookkeeping. Defaults to false.

### getSchemaGroup

    public SchemaGroup getSchemaGroup()

  Return the current schema group.

### setSchemaGroup

    public void setSchemaGroup(SchemaGroup group)

  Set the schema group to add generated schemas to.

### generateSchemas

    public void generateSchemas()
                         throws SQLException

  Generate all schemas set in the configuration. This method also calls `generateIndexes(java.lang.String, java.lang.String[])`, `generatePrimaryKeys(java.lang.String, java.lang.String[])`, and `generateForeignKeys(java.lang.String, java.lang.String[])` automatically.

### generateSchemas

    public void generateSchemas(String[] schemasAndTables)
                         throws SQLException

  Generate the schemas and/or tables named in the given strings. See the `main(java.lang.String[])` method description for how to specify schema and table names. This method calls `generateIndexes(java.lang.String, java.lang.String[])`, `generatePrimaryKeys(java.lang.String, java.lang.String[])`, and `generateForeignKeys(java.lang.String, java.lang.String[])` automatically.

### generateSchema

    public void generateSchema(String name,
                               String[] tableNames)
                        throws SQLException

  Add a fully-constructed `Schema` matching the given database schema to the current group. No foreign keys are generated because some keys might span schemas. You must call `generatePrimaryKeys(java.lang.String, java.lang.String[])`, `generateIndexes(java.lang.String, java.lang.String[])`, and `generateForeignKeys(java.lang.String, java.lang.String[])` separately.
  Parameters:
    `name` - the database name of the schema, or null for all schemas
    `tableNames` - a list of tables to generate in the schema, or null to generate all tables

### generatePrimaryKeys

    public void generatePrimaryKeys(String schemaName,
                                    String[] tableNames)
                             throws SQLException

  Generate primary key information for the given schema. This method must be called in addition to `generateSchema(java.lang.String, java.lang.String[])`. It should only be called after all schemas are generated. The schema name and tables array can be null to indicate that indexes should be generated for all schemas and/or tables.

### generateIndexes

    public void generateIndexes(String schemaName,
                                String[] tableNames)
                         throws SQLException

  Generate index information for the given schema. This method must be called in addition to `generateSchema(java.lang.String, java.lang.String[])`. It should only be called after all schemas are generated. The schema name and tables array can be null to indicate that indexes should be generated for all schemas and/or tables.

### generateForeignKeys

    public void generateForeignKeys(String schemaName,
                                    String[] tableNames)
                             throws SQLException

  Generate foreign key information for the given schema. This method must be called in addition to `generateSchema(java.lang.String, java.lang.String[])`. It should only be called after all schemas are generated. The schema name and tables array can be null to indicate that indexes should be generated for all schemas and/or tables.

### generateTables

    public void generateTables(String schemaName,
                               String tableName,
                               Connection conn,
                               DatabaseMetaData meta)
                        throws SQLException

  Adds all tables matching the given name pattern to the schema.

### generatePrimaryKeys

    public void generatePrimaryKeys(String schemaName,
                                    String tableName,
                                    Connection conn,
                                    DatabaseMetaData meta)
                             throws SQLException

  Generates table primary keys.

### generateIndexes

    public void generateIndexes(String schemaName,
                                String tableName,
                                Connection conn,
                                DatabaseMetaData meta)
                         throws SQLException

  Generates table indexes.

### generateForeignKeys

    public void generateForeignKeys(String schemaName,
                                    String tableName,
                                    Connection conn,
                                    DatabaseMetaData meta)
                             throws SQLException

  Generates table foreign keys.

### addListener

    public void addListener(SchemaGenerator.Listener l)

  Adds a listener for schema generation events.
  Parameters:
    `l` - the listener to add

### removeListener

    public boolean removeListener(SchemaGenerator.Listener l)

  Removes a schema generation listener for schema events.
  Parameters:
    `l` - the listener to remove
  Returns:
    true if it was successfully removed

### main

    public static void main(String[] args)
                     throws IOException,
                            SQLException

  Usage: java kodo.jdbc.schema.SchemaGenerator [option]*

  Where the following options are recognized.

  - -properties/-p <properties file or resource>: The path or resource name of a Kodo properties file containing information such as the license key and connection data as outlined in `JDBCConfiguration`. Optional.
  - -<property name> <property value>: All bean properties of the Kodo `JDBCConfiguration` can be set by using their names and supplying a value. For example: `-licenseKey adslfja83r3lkadf`
  - -schemas/-s <schema and table names>: Comma-separated list of schema and table names to generate.
  - -indexes/-ix <true/t | false/f>: If false, no index information will be generated.
  - -foreignKeys/-fk <true/t | false/f>: If false, no foreign key information will be generated.
  - -primaryKeys/-pk <true/t | false/f>: If false, no primary key information will be generated.
  - -kodoTables/-kt <true/t | false/f>: If true, the generated info will include special tables Kodo uses for bookkeeping; these tables are typically ignored.
  - -file/-f <stdout | output file or resource>: The path or resource name of a file the schema should be generated to; if this option is not specified the schema will be generated to stdout.

  You can use the `-schemas` argument to give a comma- separated list of schemas and tables to generate. All table names must be of the form `<schema>.<table>`. If the table's schema is unknown or null, specify the table name with a preceding period: `.<table>`. If a schema name is given but no tables are listed for that schema, all tables in the shcema will be generated. If no arguments at all are given, all tables of all schemas listed in the `JDBCConfiguration` will be generated.

### run

    public static boolean run(JDBCConfiguration conf,
                              String[] args,
                              serp.util.Options opts)
                       throws IOException,
                              SQLException

  Run the tool. Returns false if invalid options were given.
  See Also:
    `main(java.lang.String[])`

### run

    public static void run(JDBCConfiguration conf,
                           boolean pks,
                           boolean indexes,
                           boolean fks,
                           boolean kodoTables,
                           Writer out)
                    throws IOException,
                           SQLException

  Run the tool.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.4.1 generated on May 30 2006
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.