net.sf.farrago.ddl
Class DdlSetParamStmt

java.lang.Object
  extended by net.sf.farrago.ddl.DdlStmt
      extended by net.sf.farrago.ddl.DdlSetParamStmt
All Implemented Interfaces:
FarragoSessionDdlStmt
Direct Known Subclasses:
DdlSetSystemParamStmt

public abstract class DdlSetParamStmt
extends DdlStmt

DdlSetParamStmt provides a common base class for DDL that alters configuration values on repository objects.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/ddl/DdlSetParamStmt.java#8 $
Author:
Stephan Zuercher

Field Summary
private  String paramName
           
private  SqlLiteral paramValue
           
 
Constructor Summary
DdlSetParamStmt(String paramName, SqlLiteral paramValue)
          Constructs a new DdlSetParamStmt.
 
Method Summary
 String getParamName()
           
 SqlLiteral getParamValue()
           
protected abstract  void handleImmutableParameter(FarragoSessionDdlValidator ddlValidator, InvalidNameException thrown)
          Handle immutable parameters.
protected abstract  void handleInvalidName(FarragoSessionDdlValidator ddlValidator, InvalidNameException thrown)
          Handle invalide name exception.
protected abstract  void handleReflectionException(FarragoSessionDdlValidator ddlValidator, Exception thrown)
          Handle reflection exception.
protected abstract  void handleTypeMismatch(FarragoSessionDdlValidator ddlValidator, TypeMismatchException thrown)
          Handle type mismatch.
protected  void preValidate(FarragoSessionDdlValidator ddlValidator, RefObject primaryConfig, RefObject alternateConfig)
          Prevalidates an "ALTER ...
 
Methods inherited from class net.sf.farrago.ddl.DdlStmt
getModelElement, isDropRestricted, postCommit, postExecute, preExecute, preValidate, requiresCommit, runsAsDml, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

paramName

private final String paramName

paramValue

private final SqlLiteral paramValue
Constructor Detail

DdlSetParamStmt

public DdlSetParamStmt(String paramName,
                       SqlLiteral paramValue)
Constructs a new DdlSetParamStmt.

Parameters:
paramName - name of parameter to set
paramValue - new value for parameter
Method Detail

getParamName

public String getParamName()
Returns:
name of the parameter set by this statement

getParamValue

public SqlLiteral getParamValue()
Returns:
value of the parameter set by this statement

preValidate

protected void preValidate(FarragoSessionDdlValidator ddlValidator,
                           RefObject primaryConfig,
                           RefObject alternateConfig)
Prevalidates an "ALTER ... SET "param" = 'value' statement.

First examines primaryConfig to see if the paramName is a valid name. If not, and if alternateConfig is not null, tests alternateConfig. If either succeeds, converts paramValue to the appropriate type and calls the RefFeatured.refSetValue(javax.jmi.reflect.RefObject, java.lang.Object) mutator is called on the the RefObject.

Calls the following functions in the event of errors:

Parameters:
ddlValidator - the DDL validator performing validation
primaryConfig - the primary RefObject to check for param names
alternateConfig - an alternate RefObject to use if primaryConfig doesn't contain the parameter.

handleInvalidName

protected abstract void handleInvalidName(FarragoSessionDdlValidator ddlValidator,
                                          InvalidNameException thrown)
Handle invalide name exception. Called when paramName is not recognized as a member of the RefObject passed to preValidate(FarragoSessionDdlValidator, RefObject, RefObject).

Parameters:
ddlValidator - the object passed to preValidate(net.sf.farrago.session.FarragoSessionDdlValidator, javax.jmi.reflect.RefObject, javax.jmi.reflect.RefObject).
thrown - the InvalidNameException generated

handleReflectionException

protected abstract void handleReflectionException(FarragoSessionDdlValidator ddlValidator,
                                                  Exception thrown)
Handle reflection exception. Called when a reflection error occurs while performing type conversion on paramValue.

Parameters:
ddlValidator - the object passed to preValidate(net.sf.farrago.session.FarragoSessionDdlValidator, javax.jmi.reflect.RefObject, javax.jmi.reflect.RefObject).
thrown - the Exception

handleImmutableParameter

protected abstract void handleImmutableParameter(FarragoSessionDdlValidator ddlValidator,
                                                 InvalidNameException thrown)
Handle immutable parameters. Called when paramName is an immutable parameter of the RefObject passed to preValidate(FarragoSessionDdlValidator, RefObject, RefObject).

Parameters:
ddlValidator - the object passed to preValidate(net.sf.farrago.session.FarragoSessionDdlValidator, javax.jmi.reflect.RefObject, javax.jmi.reflect.RefObject).
thrown - the InvalidNameException generated (which in this case indicates an immutable parameter)

handleTypeMismatch

protected abstract void handleTypeMismatch(FarragoSessionDdlValidator ddlValidator,
                                           TypeMismatchException thrown)
Handle type mismatch. Called when paramValue has successfully undergone type conversion but is not the expected type.

Parameters:
ddlValidator - the object passed to preValidate(net.sf.farrago.session.FarragoSessionDdlValidator, javax.jmi.reflect.RefObject, javax.jmi.reflect.RefObject).
thrown - the TypeMismatchException thrown