org.eigenbase.test
Class MockCatalogReader

java.lang.Object
  extended by org.eigenbase.test.MockCatalogReader
All Implemented Interfaces:
SqlValidatorCatalogReader

public class MockCatalogReader
extends Object
implements SqlValidatorCatalogReader

Mock implementation of SqlValidatorCatalogReader which returns tables "EMP", "DEPT", "BONUS", "SALGRADE" (same as Oracle's SCOTT schema).

Version:
$Id: //open/dev/farrago/src/org/eigenbase/test/MockCatalogReader.java#28 $
Author:
jhyde

Nested Class Summary
static class MockCatalogReader.MockSchema
           
static class MockCatalogReader.MockTable
          Mock implementation of SqlValidatorTable.
 
Field Summary
private  RelDataType addressType
           
protected static String defaultSchema
           
protected  Map<String,MockCatalogReader.MockSchema> schemas
           
private  Map<List<String>,MockCatalogReader.MockTable> tables
           
protected  RelDataTypeFactory typeFactory
           
 
Constructor Summary
  MockCatalogReader(RelDataTypeFactory typeFactory)
          Creates a MockCatalogReader.
protected MockCatalogReader(RelDataTypeFactory typeFactory, boolean dummy)
          Creates a MockCatalogReader but does not initialize.
 
Method Summary
 List<SqlMoniker> getAllSchemaObjectNames(List<String> names)
          Gets schema object names as specified.
 RelDataType getNamedType(SqlIdentifier typeName)
          Finds a user-defined type with the given name, possibly qualified.
 String getSchemaName()
          Returns the name of the current schema.
 SqlValidatorTable getTable(String[] names)
          Finds a table with the given name, possibly qualified.
protected  void init()
          Initializes this catalog reader.
protected  void registerSchema(MockCatalogReader.MockSchema schema)
           
protected  void registerTable(MockCatalogReader.MockTable table)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultSchema

protected static final String defaultSchema
See Also:
Constant Field Values

typeFactory

protected final RelDataTypeFactory typeFactory

tables

private final Map<List<String>,MockCatalogReader.MockTable> tables

schemas

protected final Map<String,MockCatalogReader.MockSchema> schemas

addressType

private RelDataType addressType
Constructor Detail

MockCatalogReader

public MockCatalogReader(RelDataTypeFactory typeFactory)
Creates a MockCatalogReader.

Parameters:
typeFactory - Type factory

MockCatalogReader

protected MockCatalogReader(RelDataTypeFactory typeFactory,
                            boolean dummy)
Creates a MockCatalogReader but does not initialize.

Protected constructor for use by subclasses, which must call init() at the end of their public constructor.

Parameters:
typeFactory - Type factory
dummy - Dummy parameter to distinguish from public constructor
Method Detail

init

protected void init()
Initializes this catalog reader.


registerTable

protected void registerTable(MockCatalogReader.MockTable table)

registerSchema

protected void registerSchema(MockCatalogReader.MockSchema schema)

getTable

public SqlValidatorTable getTable(String[] names)
Description copied from interface: SqlValidatorCatalogReader
Finds a table with the given name, possibly qualified.

Specified by:
getTable in interface SqlValidatorCatalogReader
Parameters:
names - Name of table
Returns:
named table, or null if not found

getNamedType

public RelDataType getNamedType(SqlIdentifier typeName)
Description copied from interface: SqlValidatorCatalogReader
Finds a user-defined type with the given name, possibly qualified.

NOTE jvs 12-Feb-2005: the reason this method is defined here instead of on RelDataTypeFactory is that it has to take into account context-dependent information such as SQL schema path, whereas a type factory is context-independent.

Specified by:
getNamedType in interface SqlValidatorCatalogReader
Parameters:
typeName - Name of type
Returns:
named type, or null if not found

getAllSchemaObjectNames

public List<SqlMoniker> getAllSchemaObjectNames(List<String> names)
Description copied from interface: SqlValidatorCatalogReader
Gets schema object names as specified. They can be schema or table object. If names array contain 1 element, return all schema names and all table names under the default schema (if that is set) If names array contain 2 elements, treat 1st element as schema name and return all table names in this schema

Specified by:
getAllSchemaObjectNames in interface SqlValidatorCatalogReader
Parameters:
names - the array contains either 2 elements representing a partially qualified object name in the format of 'schema.object', or an unqualified name in the format of 'object'
Returns:
the list of all object (schema and table) names under the above criteria

getSchemaName

public String getSchemaName()
Description copied from interface: SqlValidatorCatalogReader
Returns the name of the current schema.

Specified by:
getSchemaName in interface SqlValidatorCatalogReader
Returns:
name of the current schema