org.eigenbase.sql.validate
Class DelegatingNamespace

java.lang.Object
  extended by org.eigenbase.sql.validate.DelegatingNamespace
All Implemented Interfaces:
SqlValidatorNamespace

public abstract class DelegatingNamespace
extends Object
implements SqlValidatorNamespace

An implementation of SqlValidatorNamespace that delegates all methods to an underlying object.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/validate/DelegatingNamespace.java#5 $
Author:
jhyde

Field Summary
protected  SqlValidatorNamespace namespace
           
 
Constructor Summary
protected DelegatingNamespace(SqlValidatorNamespace namespace)
          Creates a DelegatingNamespace.
 
Method Summary
 boolean fieldExists(String name)
          Returns whether this namespace has a field of a given name.
 SqlNode getEnclosingNode()
          Returns the parse tree node that at is at the root of this namespace and includes all decorations.
 List<Pair<SqlNode,SqlMonotonicity>> getMonotonicExprs()
          Returns a list of expressions which are monotonic in this namespace.
 SqlMonotonicity getMonotonicity(String columnName)
          Returns whether and how a given column is sorted.
 SqlNode getNode()
          Returns the parse tree node at the root of this namespace.
 RelDataType getRowType()
          Returns the row type of this namespace, which comprises a list of names and types of the output columns.
 RelDataType getRowTypeSansSystemColumns()
          Returns the row type of this namespace, sans any system columns.
 SqlValidatorTable getTable()
          Returns the underlying table, or null if there is none.
 SqlValidator getValidator()
          Returns the validator.
 boolean isWrapperFor(Class<?> clazz)
          Returns whether this namespace implements a given interface, or wraps a class which does.
 SqlValidatorNamespace lookupChild(String name)
          Looks up a child namespace of a given name.
 void makeNullable()
          Makes all fields in this namespace nullable (typically because it is on the outer side of an outer join.
 void setRowType(RelDataType rowType)
          Allows RowType for the namespace to be explicitly set.
 String translate(String name)
          Translates a field name to the name in the underlying namespace.
<T> T
unwrap(Class<T> clazz)
          Returns this namespace, or a wrapped namespace, cast to a particular class.
 void validate()
          Validates this namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namespace

protected final SqlValidatorNamespace namespace
Constructor Detail

DelegatingNamespace

protected DelegatingNamespace(SqlValidatorNamespace namespace)
Creates a DelegatingNamespace.

Parameters:
namespace - Underlying namespace, to delegate to
Method Detail

getValidator

public SqlValidator getValidator()
Description copied from interface: SqlValidatorNamespace
Returns the validator.

Specified by:
getValidator in interface SqlValidatorNamespace
Returns:
validator

getTable

public SqlValidatorTable getTable()
Description copied from interface: SqlValidatorNamespace
Returns the underlying table, or null if there is none.

Specified by:
getTable in interface SqlValidatorNamespace

getRowType

public RelDataType getRowType()
Description copied from interface: SqlValidatorNamespace
Returns the row type of this namespace, which comprises a list of names and types of the output columns. If the scope's type has not yet been derived, derives it. Never returns null.

Specified by:
getRowType in interface SqlValidatorNamespace

setRowType

public void setRowType(RelDataType rowType)
Description copied from interface: SqlValidatorNamespace
Allows RowType for the namespace to be explicitly set.

Specified by:
setRowType in interface SqlValidatorNamespace

getRowTypeSansSystemColumns

public RelDataType getRowTypeSansSystemColumns()
Description copied from interface: SqlValidatorNamespace
Returns the row type of this namespace, sans any system columns.

Specified by:
getRowTypeSansSystemColumns in interface SqlValidatorNamespace
Returns:
Row type sans system columns

validate

public void validate()
Description copied from interface: SqlValidatorNamespace
Validates this namespace.

If the scope has already been validated, does nothing.

Please call SqlValidatorImpl.validateNamespace(org.eigenbase.sql.validate.SqlValidatorNamespace) rather than calling this method directly.

Specified by:
validate in interface SqlValidatorNamespace

getNode

public SqlNode getNode()
Description copied from interface: SqlValidatorNamespace
Returns the parse tree node at the root of this namespace.

Specified by:
getNode in interface SqlValidatorNamespace
Returns:
parse tree node

getEnclosingNode

public SqlNode getEnclosingNode()
Description copied from interface: SqlValidatorNamespace
Returns the parse tree node that at is at the root of this namespace and includes all decorations. If there are no decorations, returns the same as SqlValidatorNamespace.getNode().

Specified by:
getEnclosingNode in interface SqlValidatorNamespace

lookupChild

public SqlValidatorNamespace lookupChild(String name)
Description copied from interface: SqlValidatorNamespace
Looks up a child namespace of a given name.

For example, in the query select e.name from emps as e, e is an IdentifierNamespace which has a child name which is a FieldNamespace.

Specified by:
lookupChild in interface SqlValidatorNamespace
Parameters:
name - Name of namespace
Returns:
Namespace

fieldExists

public boolean fieldExists(String name)
Description copied from interface: SqlValidatorNamespace
Returns whether this namespace has a field of a given name.

Specified by:
fieldExists in interface SqlValidatorNamespace
Parameters:
name - Field name
Returns:
Whether field exists

getMonotonicExprs

public List<Pair<SqlNode,SqlMonotonicity>> getMonotonicExprs()
Description copied from interface: SqlValidatorNamespace
Returns a list of expressions which are monotonic in this namespace. For example, if the namespace represents a relation ordered by a column called "TIMESTAMP", then the list would contain a SqlIdentifier called "TIMESTAMP".

Specified by:
getMonotonicExprs in interface SqlValidatorNamespace

getMonotonicity

public SqlMonotonicity getMonotonicity(String columnName)
Description copied from interface: SqlValidatorNamespace
Returns whether and how a given column is sorted.

Specified by:
getMonotonicity in interface SqlValidatorNamespace

makeNullable

public void makeNullable()
Description copied from interface: SqlValidatorNamespace
Makes all fields in this namespace nullable (typically because it is on the outer side of an outer join.

Specified by:
makeNullable in interface SqlValidatorNamespace

translate

public String translate(String name)
Description copied from interface: SqlValidatorNamespace
Translates a field name to the name in the underlying namespace.

Specified by:
translate in interface SqlValidatorNamespace

unwrap

public <T> T unwrap(Class<T> clazz)
Description copied from interface: SqlValidatorNamespace
Returns this namespace, or a wrapped namespace, cast to a particular class.

Specified by:
unwrap in interface SqlValidatorNamespace
Parameters:
clazz - Desired type
Returns:
This namespace cast to desired type

isWrapperFor

public boolean isWrapperFor(Class<?> clazz)
Description copied from interface: SqlValidatorNamespace
Returns whether this namespace implements a given interface, or wraps a class which does.

Specified by:
isWrapperFor in interface SqlValidatorNamespace
Parameters:
clazz - Interface
Returns:
Whether namespace implements given interface