net.sf.farrago.ddl
Class DdlHandler

java.lang.Object
  extended by net.sf.farrago.ddl.DdlHandler
All Implemented Interfaces:
ReflectiveVisitor
Direct Known Subclasses:
DdlMedHandler, DdlRelationalHandler, DdlRoutineHandler, DdlSecurityHandler, FarragoRngDdlHandler

public abstract class DdlHandler
extends Object
implements ReflectiveVisitor

DdlHandler is an abstract base for classes which provide implementations for the actions taken by DdlValidator on individual objects. See FarragoSessionDdlHandler for an explanation.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/ddl/DdlHandler.java#41 $
Author:
John V. Sichi

Field Summary
protected  FarragoRepos repos
           
protected  FarragoResource res
          An instance of FarragoResource for use in throwing validation errors.
protected static Logger tracer
           
protected  FarragoSessionDdlValidator validator
           
 
Constructor Summary
DdlHandler(FarragoSessionDdlValidator validator)
           
 
Method Summary
 Throwable adjustExceptionParserPosition(CwmModelElement modelElement, Throwable ex)
           
 void convertFieldToCwmColumn(RelDataTypeField field, CwmColumn column, CwmNamespace owner)
          Initializes a CwmColumn definition based on a RelDataTypeField.
private  void convertSqlToCatalogType(SqlDataTypeSpec dataType, FemSqltypedElement element)
           
private  void convertTypeToCwmColumn(RelDataType type, CwmColumn column, CwmNamespace owner)
          Populates a CwmColumn object with type information.
 FarragoSessionDdlValidator getValidator()
           
private  RuntimeException newContextException(CwmModelElement element, Exception e)
          Adds position information to an exception.
 void validateAttribute(FemAbstractAttribute attribute)
           
 void validateAttributeSet(CwmClass cwmClass)
           
 void validateBaseColumnSet(FemBaseColumnSet columnSet)
           
private  void validateDefaultClause(FemAbstractAttribute attribute, FarragoSession session, String defaultExpression)
           
 void validateTypedElement(FemAbstractTypedElement abstractElement, CwmNamespace cwmNamespace)
           
private  void validateTypedElement(FemSqltypedElement element, CwmNamespace cwmNamespace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tracer

protected static final Logger tracer

validator

protected final FarragoSessionDdlValidator validator

repos

protected final FarragoRepos repos

res

protected final FarragoResource res
An instance of FarragoResource for use in throwing validation errors. The name is intentionally short to keep line length under control.

Constructor Detail

DdlHandler

public DdlHandler(FarragoSessionDdlValidator validator)
Method Detail

getValidator

public FarragoSessionDdlValidator getValidator()

validateAttributeSet

public void validateAttributeSet(CwmClass cwmClass)

validateBaseColumnSet

public void validateBaseColumnSet(FemBaseColumnSet columnSet)

validateAttribute

public void validateAttribute(FemAbstractAttribute attribute)

convertSqlToCatalogType

private void convertSqlToCatalogType(SqlDataTypeSpec dataType,
                                     FemSqltypedElement element)

validateTypedElement

public void validateTypedElement(FemAbstractTypedElement abstractElement,
                                 CwmNamespace cwmNamespace)

validateTypedElement

private void validateTypedElement(FemSqltypedElement element,
                                  CwmNamespace cwmNamespace)

newContextException

private RuntimeException newContextException(CwmModelElement element,
                                             Exception e)
Adds position information to an exception.

This method is similar to SqlValidator.newValidationError(SqlNode, SqlValidatorException) and should be unified with it, if only we could figure out how.

Parameters:
element - Element which had the error, and is therefore the locus of the exception
e - Exception raised
Returns:
Exception with position information

convertFieldToCwmColumn

public void convertFieldToCwmColumn(RelDataTypeField field,
                                    CwmColumn column,
                                    CwmNamespace owner)
Initializes a CwmColumn definition based on a RelDataTypeField.

As well as calling CwmStructuralFeature.setType(CwmClassifier), also calls CwmColumn.setPrecision(Integer), CwmColumn.setScale(Integer) and CwmColumn.setIsNullable(NullableType).

If the column has no name, the name is initialized from the field name; otherwise, the existing name is left unmodified.

Parameters:
field - input field
column - on input, contains unintialized CwmColumn instance;
owner - The object which is to own any anonymous datatypes created; typically, the table which this column belongs to
"Precondition:"
field != null && column != null && owner != null

convertTypeToCwmColumn

private void convertTypeToCwmColumn(RelDataType type,
                                    CwmColumn column,
                                    CwmNamespace owner)
Populates a CwmColumn object with type information.

As well as calling CwmStructuralFeature.setType(CwmClassifier), also calls CwmColumn.setPrecision(Integer), CwmColumn.setScale(Integer) and CwmColumn.setIsNullable(NullableType).

If the type is structured or a multiset, the implementation is recursive.

Parameters:
type - Type to convert
column - Column to populate with type information
owner - The object which is to own any anonymous datatypes created; typically, the table which this column belongs to

adjustExceptionParserPosition

public Throwable adjustExceptionParserPosition(CwmModelElement modelElement,
                                               Throwable ex)

validateDefaultClause

private void validateDefaultClause(FemAbstractAttribute attribute,
                                   FarragoSession session,
                                   String defaultExpression)