com.spotfire.ws.im.ds.sql
Class BasicJDBCMetadataProvider

java.lang.Object
  extended by com.spotfire.ws.im.ds.sql.BasicJDBCMetadataProvider
All Implemented Interfaces:
JDBCMetadataProvider

public class BasicJDBCMetadataProvider
extends Object
implements JDBCMetadataProvider

A basic implementation of the JDBCMetadataProvider interface.

Since:
7.2

Constructor Summary
BasicJDBCMetadataProvider()
          Creates a new BasicJDBCMetadataProvider instance.
 
Method Summary
 MetadataItem createCatalogItem(String name)
          Creates a catalog item.
 MetadataItem createColumnItem(String name, Class type, String typeName, String description)
          Creates a column item.
 MetadataItem createColumnItem(String name, int jdbcType, String typeName, int precision, int scale, String description)
          Creates a column item.
 MetadataItem createSchemaItem(String name)
          Creates a schema item.
 MetadataItem createTableItem(String name)
          Creates a table item.
protected  MetadataItem[] getCatalogs()
          Returns a list of catalog items.
protected  MetadataItem[] getColumns(String catalog, String schema, String table)
          Returns a list of column items.
 JDBCContext getContext()
          Returns the JDBCContext.
 MetadataItem[] getMetadata(MetadataItem[] path)
          Returns a list of MetadataItem objects that corresponds to the given path.
protected  ProcedureMetadata getProcedureMetadata(String catalog, String schema, String procedure)
           
protected  MetadataItem[] getProcedures(String catalog, String schema)
           
protected  MetadataItem[] getSchemas(String catalog)
          Returns a list of schema items.
protected  MetadataItem[] getTableAliases(String catalog, String schema)
           
protected  MetadataItem[] getTables(String catalog, String schema)
          Returns a list of table items.
 void setContext(JDBCContext context)
          Sets the JDBCContext.
static MetadataItem[] sortMetadataItemsByName(MetadataItem[] items)
           
 Class toJavaType(int jdbcType, String typeName, int precision, int scale)
          Converts a JDBC type to a Java type.
 int toJDBCType(Class c)
          Converts a Java type to a JDBC type.
protected  void verifyCatalog(DatabaseMetaData dbmd, String catalog)
           
protected  void verifySchema(DatabaseMetaData dbmd, String catalog, String schema)
           
protected  void verifyTable(DatabaseMetaData dbmd, String catalog, String schema, String table)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicJDBCMetadataProvider

public BasicJDBCMetadataProvider()
Creates a new BasicJDBCMetadataProvider instance.

Method Detail

setContext

public void setContext(JDBCContext context)
Description copied from interface: JDBCMetadataProvider
Sets the JDBCContext.

Specified by:
setContext in interface JDBCMetadataProvider

getContext

public JDBCContext getContext()
Returns the JDBCContext.

Returns:
a JDBCContext instance

getMetadata

public MetadataItem[] getMetadata(MetadataItem[] path)
                           throws InvalidMetadataPath
Description copied from interface: JDBCMetadataProvider
Returns a list of MetadataItem objects that corresponds to the given path.

Specified by:
getMetadata in interface JDBCMetadataProvider
Parameters:
path - a path of MetadataItem objects.
Returns:
a list of MetadataItem objects.
Throws:
InvalidMetadataPath - if the given path is invalid

getCatalogs

protected MetadataItem[] getCatalogs()
                              throws InvalidMetadataPath
Returns a list of catalog items.

Returns:
a list of catalog items
Throws:
InvalidMetadataPath - if the catalog level is not supported
SQLException - if a database error occurs

getSchemas

protected MetadataItem[] getSchemas(String catalog)
                             throws InvalidMetadataPath
Returns a list of schema items.

Parameters:
catalog - a catalog name, may be ""
Returns:
a list of schema items
Throws:
InvalidMetadataPath - if the catalog is invalid or if the schema level is not supported
SQLException - if a database error occurs

getTables

protected MetadataItem[] getTables(String catalog,
                                   String schema)
                            throws InvalidMetadataPath
Returns a list of table items.

Parameters:
catalog - a catalog name, may be ""
schema - a schema name, may be ""
Returns:
a list of table items
Throws:
InvalidMetadataPath - if the given catalog or schema is invalid
SQLException - if a database error occurs

getTableAliases

protected MetadataItem[] getTableAliases(String catalog,
                                         String schema)

getColumns

protected MetadataItem[] getColumns(String catalog,
                                    String schema,
                                    String table)
                             throws InvalidMetadataPath
Returns a list of column items.

Parameters:
catalog - a catalog name, may be ""
schema - a schema name, may be ""
table - a table name, may be ""
Returns:
a list of column items
Throws:
InvalidMetadataPath - if the given catalog, schema or table is invalid
SQLException - if a database error occurs

getProcedures

protected MetadataItem[] getProcedures(String catalog,
                                       String schema)

getProcedureMetadata

protected ProcedureMetadata getProcedureMetadata(String catalog,
                                                 String schema,
                                                 String procedure)

verifyCatalog

protected void verifyCatalog(DatabaseMetaData dbmd,
                             String catalog)
                      throws InvalidMetadataPath
Throws:
InvalidMetadataPath

verifySchema

protected void verifySchema(DatabaseMetaData dbmd,
                            String catalog,
                            String schema)
                     throws InvalidMetadataPath
Throws:
InvalidMetadataPath

verifyTable

protected void verifyTable(DatabaseMetaData dbmd,
                           String catalog,
                           String schema,
                           String table)
                    throws InvalidMetadataPath
Throws:
InvalidMetadataPath

createCatalogItem

public MetadataItem createCatalogItem(String name)
Creates a catalog item.

Parameters:
name - a catalog name
Returns:
a catalog item

createSchemaItem

public MetadataItem createSchemaItem(String name)
Creates a schema item.

Parameters:
name - a schema name
Returns:
a schema item

createTableItem

public MetadataItem createTableItem(String name)
Creates a table item.

Parameters:
name - a table name
Returns:
a table item

createColumnItem

public MetadataItem createColumnItem(String name,
                                     Class type,
                                     String typeName,
                                     String description)
Creates a column item.

Parameters:
name - a column name
type - a column type
typeName - data source dependent type name
description - comment describing column
Returns:
a column item
See Also:
BasicJDBCMetadataProvider.toJavaType(int, java.lang.String, int, int)

createColumnItem

public MetadataItem createColumnItem(String name,
                                     int jdbcType,
                                     String typeName,
                                     int precision,
                                     int scale,
                                     String description)
Creates a column item.

Parameters:
name - a column name
jdbcType - a JDBC type
typeName - data source dependent type name
precision - a precision, used for numeric types
scale - a scale, used for numeric types
description - comment describing column
Returns:
a column item
See Also:
BasicJDBCMetadataProvider.toJavaType(int, java.lang.String, int, int)

toJavaType

public Class toJavaType(int jdbcType,
                        String typeName,
                        int precision,
                        int scale)
Description copied from interface: JDBCMetadataProvider
Converts a JDBC type to a Java type.

The following Java types are supported:

Specified by:
toJavaType in interface JDBCMetadataProvider
Parameters:
jdbcType - a JDBC type
typeName - data source dependent type name
precision - a precision used for numberic types
scale - a scale used for numeric types
Returns:
a Java type
See Also:
Types

toJDBCType

public int toJDBCType(Class c)
Description copied from interface: JDBCMetadataProvider
Converts a Java type to a JDBC type.

The following Java types must be supported:

Specified by:
toJDBCType in interface JDBCMetadataProvider
Parameters:
c - a Java type
Returns:
a JDBC type
See Also:
Types

sortMetadataItemsByName

public static MetadataItem[] sortMetadataItemsByName(MetadataItem[] items)


Copyright © 2000-2009 TIBCO Software Inc. All Rights Reserved.