org.eclipse.datatools.connectivity.oda.spec.util
Class ValidatorUtil

java.lang.Object
  extended by org.eclipse.datatools.connectivity.oda.spec.util.ValidatorUtil

public class ValidatorUtil
extends java.lang.Object

Utility class for use by implementation of IValidator.

Since:
3.3 (DTP 1.8)

Constructor Summary
ValidatorUtil()
           
 
Method Summary
static OdaException addException(OdaException rootEx, OdaException newEx)
          Adds the new OdaException object to the end of the OdaException chain.
static boolean isInvalidAggregateExpression(AggregateExpression aggrExpr, OdaException rootEx)
          Indicates whether the specified aggregate expression is one of the cause(s) in the specified OdaException chain.
static boolean isInvalidFilterExpression(FilterExpression filterExpr, OdaException rootEx)
          Indicates whether the specified FilterExpression is one of the cause(s) in the specified OdaException chain.
static boolean isInvalidResultProjection(ResultProjection resultProj, OdaException rootEx)
          Indicates whether the specified result projection is one of the cause(s) in the specified OdaException chain.
static boolean isInvalidResultSetSpec(ResultSetSpecification resultSetSpec, OdaException rootEx)
          Indicates whether the specified result set specification is one of the cause(s) in the specified OdaException chain.
static boolean isInvalidSortKey(int sortKeySequenceOrder, OdaException rootEx)
          Indicates whether the specified sort key is one of the cause(s) in the specified OdaException chain.
static boolean isInvalidSortSpec(SortSpecification sortSpec, OdaException rootEx)
          Indicates whether the specified sort specification is one of the cause(s) in the specified OdaException chain.
static boolean isInvalidValueExpression(ValueExpression valueExpr, OdaException rootEx)
          Indicates whether the specified value expression is one of the cause(s) in the specified OdaException chain.
static OdaException newAggregateException(AggregateExpression invalidAggrExpr, OdaException driverEx)
          Creates and returns a top-level OdaException to indicate that the specified aggregate expression is the cause of the specified driverEx exception.
static OdaException newAggregateException(java.lang.String message, AggregateExpression invalidAggrExpr)
          Creates and returns an OdaException with the specified AggregateExpression identified as the cause.
static OdaException newFilterExprException(FilterExpression invalidFilterExpr, OdaException driverEx)
          Creates and returns a top-level OdaException to indicate that the specified FilterExpression is the cause of the specified driverEx exception.
static OdaException newFilterExprException(java.lang.String message, FilterExpression invalidFilterExpr)
          Creates and returns an OdaException with the specified FilterExpression identified as the cause.
static OdaException newOdaException(java.lang.String message, java.lang.String causeIdentifier)
          Creates and returns an OdaException with the specified message and an IllegalArgumentException cause with the specified causeIdentifier.
static OdaException newResultProjectionException(ResultProjection resultProj, OdaException driverEx)
          Creates and returns a top-level OdaException to indicate that the specified result projection is the cause of the specified driverEx exception.
static OdaException newResultProjectionException(java.lang.String message, ResultProjection resultProj)
          Creates and returns a top-level OdaException to indicate that the specified result projection is the cause of the specified driverEx exception.
static OdaException newResultSetSpecException(java.lang.String message, ResultSetSpecification resultSetSpec, OdaException chainedEx)
          Creates and returns a top-level OdaException to indicate that the specified result set specification is the cause of the specified driverEx exception.
static OdaException newSortKeyException(int sortKeySequenceOrder, OdaException driverEx)
          Creates and returns a top-level OdaException to indicate that the specified sort key is the cause of the specified driverEx exception.
static OdaException newSortKeyException(java.lang.String message, int sortKeySequenceOrder)
          Creates and returns a top-level OdaException to indicate that the specified sort key is the cause of the specified driverEx exception.
static OdaException newSortSpecException(SortSpecification sortSpec, OdaException driverEx)
          Creates and returns a top-level OdaException to indicate that the specified sort specification is the cause of the specified driverEx exception.
static OdaException newSortSpecException(java.lang.String message, SortSpecification sortSpec)
          Creates and returns a top-level OdaException to indicate that the specified sort specification is the cause of the specified driverEx exception.
static OdaException newValueExprException(java.lang.String message, ValueExpression invalidValueExpr)
          Creates and returns an OdaException with the specified value expression identified as the cause.
static OdaException newValueExprException(ValueExpression invalidValueExpr, OdaException driverEx)
          Creates and returns a top-level OdaException to indicate that the specified value expression is the cause of the specified driverEx exception.
static void validateAllCustomExprType(FilterExpression expr, java.lang.Class<?> expectedExprClass)
          Validates each and every CustomExpression nested in the specified FilterExpression to be an instance of the specified class.
static void validateCustomExprExtension(CustomAggregate customAggrExpr, java.lang.String expectedExtensionId)
          Validates that the specified CustomAggregate is contributed by the specified dynamicResultSet extension id.
static void validateCustomExprExtension(CustomExpression customExpr, java.lang.String expectedExtensionId)
          Validates that the specified CustomExpression is contributed by the specified dynamicResultSet extension id.
static void validateCustomExprExtension(CustomFunction customFuncExpr, java.lang.String expectedExtensionId)
          Validates that the specified CustomFunction is contributed by the specified dynamicResultSet extension id.
static void validateCustomExprType(CustomAggregate customExpr, java.lang.Class<?> expectedExprClass)
          Validates the specified CustomAggregate to be an instance of the specified class.
static void validateCustomExprType(CustomExpression customExpr, java.lang.Class<?> expectedExprClass)
          Validates the specified CustomExpression to be an instance of the specified class.
static void validateCustomExprType(CustomFunction customExpr, java.lang.Class<?> expectedExprClass)
          Validates the specified CustomFunction to be an instance of the specified class.
static void validateHasExprVariable(AtomicExpression expr)
          Validates that the specified AtomicExpression has an associated ExpressionVariable.
static void validateHasNoNullOrderingSpec(SortSpecification sortSpec)
          Validates that null ordering is not specified in the given sortSpec.
static void validateSupportedVariableDataTypes(ExpressionVariable exprVar, VariableRestrictions varRestrictions, java.lang.String odaDataSourceId, java.lang.String dataSetType)
          Validates that the data type of the specified expression variable is one of the supported data types listed in the VariableRestrictions.
static void validateSupportedVariableDataTypes(ValueExpression valueExpr, VariableRestrictions varRestrictions, java.lang.String odaDataSourceId, java.lang.String dataSetType)
          Validates that the data type of the specified value expression is one of the supported data types listed in the VariableRestrictions.
static void validateSupportedVariableTypes(AtomicExpression expr, ExpressionVariable.VariableType[] supportedVarTypes)
          Validates that the expression variable of the specified filter expression is one of the specified variable types.
static void validateSupportedVariableTypes(CustomAggregate expr, ExpressionVariable.VariableType[] supportedVarTypes)
          Validates that the input expression variable of the specified aggregate expression is one of the specified variable types.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorUtil

public ValidatorUtil()
Method Detail

validateCustomExprType

public static void validateCustomExprType(CustomExpression customExpr,
                                          java.lang.Class<?> expectedExprClass)
                                   throws OdaException
Validates the specified CustomExpression to be an instance of the specified class.

Parameters:
customExpr - a custom filter expression instance
expectedExprClass - the expected class of the custom expression
Throws:
OdaException - if validation fails

validateCustomExprType

public static void validateCustomExprType(CustomAggregate customExpr,
                                          java.lang.Class<?> expectedExprClass)
                                   throws OdaException
Validates the specified CustomAggregate to be an instance of the specified class.

Parameters:
customExpr - a custom aggregate expression instance
expectedExprClass - the expected class of the custom expression
Throws:
OdaException - if validation fails

validateCustomExprType

public static void validateCustomExprType(CustomFunction customExpr,
                                          java.lang.Class<?> expectedExprClass)
                                   throws OdaException
Validates the specified CustomFunction to be an instance of the specified class.

Parameters:
customExpr - a custom function value expression instance
expectedExprClass - the expected class of the custom function value expression
Throws:
OdaException - if validation fails
Since:
3.2.3

validateAllCustomExprType

public static void validateAllCustomExprType(FilterExpression expr,
                                             java.lang.Class<?> expectedExprClass)
                                      throws OdaException
Validates each and every CustomExpression nested in the specified FilterExpression to be an instance of the specified class.

Parameters:
customExpr - a custom filter expression instance
expectedExprClass - the expected class of the custom expression
Throws:
OdaException - if validation fails

validateCustomExprExtension

public static void validateCustomExprExtension(CustomExpression customExpr,
                                               java.lang.String expectedExtensionId)
                                        throws OdaException
Validates that the specified CustomExpression is contributed by the specified dynamicResultSet extension id.

Parameters:
customExpr - a custom filter expression instance
expectedExtensionId - id of the expected oda dynamicResultSet extension
Throws:
OdaException - if validation fails

validateCustomExprExtension

public static void validateCustomExprExtension(CustomAggregate customAggrExpr,
                                               java.lang.String expectedExtensionId)
                                        throws OdaException
Validates that the specified CustomAggregate is contributed by the specified dynamicResultSet extension id.

Parameters:
customAggrExpr - a custom aggregate expression instance
expectedExtensionId - id of the expected oda dynamicResultSet extension
Throws:
OdaException - if validation fails

validateCustomExprExtension

public static void validateCustomExprExtension(CustomFunction customFuncExpr,
                                               java.lang.String expectedExtensionId)
                                        throws OdaException
Validates that the specified CustomFunction is contributed by the specified dynamicResultSet extension id.

Parameters:
customFuncExpr - a custom function value expression instance
expectedExtensionId - id of the expected oda dynamicResultSet extension
Throws:
OdaException - if validation fails
Since:
3.2.3

validateHasExprVariable

public static void validateHasExprVariable(AtomicExpression expr)
                                    throws OdaException
Validates that the specified AtomicExpression has an associated ExpressionVariable.

Parameters:
expr - an atomic filter expression instance
Throws:
OdaException - if validation fails

validateSupportedVariableTypes

public static void validateSupportedVariableTypes(AtomicExpression expr,
                                                  ExpressionVariable.VariableType[] supportedVarTypes)
                                           throws OdaException
Validates that the expression variable of the specified filter expression is one of the specified variable types.

Parameters:
expr - an atomic filter expression instance
supportedVarTypes - array of supported types of expression variable
Throws:
OdaException - if validation fails

validateSupportedVariableTypes

public static void validateSupportedVariableTypes(CustomAggregate expr,
                                                  ExpressionVariable.VariableType[] supportedVarTypes)
                                           throws OdaException
Validates that the input expression variable of the specified aggregate expression is one of the specified variable types.

Parameters:
expr - a custom aggregate expression instance
supportedVarTypes - array of supported types of expression variable
Throws:
OdaException - if validation fails

validateSupportedVariableDataTypes

public static void validateSupportedVariableDataTypes(ExpressionVariable exprVar,
                                                      VariableRestrictions varRestrictions,
                                                      java.lang.String odaDataSourceId,
                                                      java.lang.String dataSetType)
                                               throws OdaException
Validates that the data type of the specified expression variable is one of the supported data types listed in the VariableRestrictions.

Parameters:
exprVar - an expression variable
varRestrictions - supported data types defined by an oda dynamicResultSet extension
odaDataSourceId - the id of an oda.dataSource extension
dataSetType - the id of a data set type defined by an oda.dataSource extension; used to map native data type to corresponding ODA data type
Throws:
OdaException - if validation fails

validateSupportedVariableDataTypes

public static void validateSupportedVariableDataTypes(ValueExpression valueExpr,
                                                      VariableRestrictions varRestrictions,
                                                      java.lang.String odaDataSourceId,
                                                      java.lang.String dataSetType)
                                               throws OdaException
Validates that the data type of the specified value expression is one of the supported data types listed in the VariableRestrictions.

Parameters:
valueExpr - a value expression
varRestrictions - supported data types defined by an oda dynamicResultSet extension
odaDataSourceId - the id of an oda.dataSource extension
dataSetType - the id of a data set type defined by an oda.dataSource extension; used to map native data type to corresponding ODA data type
Throws:
OdaException - if validation fails

validateHasNoNullOrderingSpec

public static void validateHasNoNullOrderingSpec(SortSpecification sortSpec)
                                          throws OdaException
Validates that null ordering is not specified in the given sortSpec. This utility method can be used by the custom validator of an ODA driver that does not support null ordering.

Parameters:
sortSpec - the sort specification found in a query spec
Throws:
OdaException - if validation fails

newOdaException

public static OdaException newOdaException(java.lang.String message,
                                           java.lang.String causeIdentifier)
Creates and returns an OdaException with the specified message and an IllegalArgumentException cause with the specified causeIdentifier.

Parameters:
message -
causeIdentifier -
Returns:
a new OdaException

addException

public static OdaException addException(OdaException rootEx,
                                        OdaException newEx)
Adds the new OdaException object to the end of the OdaException chain.

Parameters:
rootEx - the root of an OdaException chain
newEx - a new OdaException to append to the end of the chain
Returns:

newFilterExprException

public static OdaException newFilterExprException(FilterExpression invalidFilterExpr,
                                                  OdaException driverEx)
Creates and returns a top-level OdaException to indicate that the specified FilterExpression is the cause of the specified driverEx exception.

Parameters:
invalidFilterExpr - a top-level FilterExpression that is invalid
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid FilterExpression identified as the cause
See Also:
#isInvalidFilterExpression(FilterExpression, OdaException)}

newFilterExprException

public static OdaException newFilterExprException(java.lang.String message,
                                                  FilterExpression invalidFilterExpr)
Creates and returns an OdaException with the specified FilterExpression identified as the cause.

Parameters:
message - custom exception message
invalidFilterExpr - the invalid FilterExpression to set as the cause
Returns:
an OdaException with the specified message and invalid FilterExpression identified as the cause
See Also:
#isInvalidFilterExpression(FilterExpression, OdaException)}

isInvalidFilterExpression

public static boolean isInvalidFilterExpression(FilterExpression filterExpr,
                                                OdaException rootEx)
Indicates whether the specified FilterExpression is one of the cause(s) in the specified OdaException chain.

Parameters:
filterExpr - a filter expression whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the filter expression
Returns:
true if the specified FilterExpression is one of the cause(s) in the OdaException chain; false otherwise

newAggregateException

public static OdaException newAggregateException(AggregateExpression invalidAggrExpr,
                                                 OdaException driverEx)
Creates and returns a top-level OdaException to indicate that the specified aggregate expression is the cause of the specified driverEx exception.

Parameters:
invalidAggrExpr - the invalid AggregateExpression to set as the cause
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid aggregate expression identified as the cause
See Also:
#isInvalidAggregateExpression(AggregateExpression, OdaException)}

newAggregateException

public static OdaException newAggregateException(java.lang.String message,
                                                 AggregateExpression invalidAggrExpr)
Creates and returns an OdaException with the specified AggregateExpression identified as the cause.

Parameters:
message - custom exception message
invalidAggrExpr - the invalid AggregateExpression to set as the cause
Returns:
an OdaException with the specified message and invalid AggregateExpression identified as the cause
See Also:
#isInvalidAggregateExpression(AggregateExpression, OdaException)}

isInvalidAggregateExpression

public static boolean isInvalidAggregateExpression(AggregateExpression aggrExpr,
                                                   OdaException rootEx)
Indicates whether the specified aggregate expression is one of the cause(s) in the specified OdaException chain.

Parameters:
aggrExpr - an aggregate expression whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the aggregate expression
Returns:
true if the specified aggregate expression is one of the cause(s) in the OdaException chain; false otherwise

newValueExprException

public static OdaException newValueExprException(ValueExpression invalidValueExpr,
                                                 OdaException driverEx)
Creates and returns a top-level OdaException to indicate that the specified value expression is the cause of the specified driverEx exception.

Parameters:
invalidValueExpr - the invalid ValueExpression to set as the cause
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid value expression identified as the cause
See Also:
#isInvalidValueExpression(ValueExpression, OdaException)}

newValueExprException

public static OdaException newValueExprException(java.lang.String message,
                                                 ValueExpression invalidValueExpr)
Creates and returns an OdaException with the specified value expression identified as the cause.

Parameters:
message - custom exception message
invalidValueExpr - the invalid ValueExpression to set as the cause
Returns:
an OdaException with the specified message and invalid ValueExpression identified as the cause
See Also:
#isInvalidValueExpression(ValueExpression, OdaException)}

isInvalidValueExpression

public static boolean isInvalidValueExpression(ValueExpression valueExpr,
                                               OdaException rootEx)
Indicates whether the specified value expression is one of the cause(s) in the specified OdaException chain.

Parameters:
valueExpr - a value expression whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the value expression
Returns:
true if the specified value expression is one of the cause(s) in the OdaException chain; false otherwise

newResultProjectionException

public static OdaException newResultProjectionException(ResultProjection resultProj,
                                                        OdaException driverEx)
Creates and returns a top-level OdaException to indicate that the specified result projection is the cause of the specified driverEx exception.

Parameters:
resultProj - the invalid ResultProjection to set as the cause
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid result projection identified as the cause
See Also:
#isInvalidResultProjection(ResultProjection, OdaException)}

newResultProjectionException

public static OdaException newResultProjectionException(java.lang.String message,
                                                        ResultProjection resultProj)
Creates and returns a top-level OdaException to indicate that the specified result projection is the cause of the specified driverEx exception.

Parameters:
message - custom exception message
resultProj - the invalid ResultProjection to set as the cause
Returns:
an OdaException with the specified message and invalid result projection identified as the cause
See Also:
#isInvalidResultProjection(ResultProjection, OdaException)}

isInvalidResultProjection

public static boolean isInvalidResultProjection(ResultProjection resultProj,
                                                OdaException rootEx)
Indicates whether the specified result projection is one of the cause(s) in the specified OdaException chain.

Parameters:
resultProj - a result projection whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the result projection
Returns:
true if the specified result projection is one of the cause(s) in the OdaException chain; false otherwise

newSortKeyException

public static OdaException newSortKeyException(int sortKeySequenceOrder,
                                               OdaException driverEx)
Creates and returns a top-level OdaException to indicate that the specified sort key is the cause of the specified driverEx exception.

Parameters:
sortKeySequenceOrder - the sequence ordering position of a sort key that is invalid
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid sort key identified as the cause
See Also:
#isInvalidSortKey(int, OdaException)}

newSortKeyException

public static OdaException newSortKeyException(java.lang.String message,
                                               int sortKeySequenceOrder)
Creates and returns a top-level OdaException to indicate that the specified sort key is the cause of the specified driverEx exception.

Parameters:
message - custom exception message
sortKeySequenceOrder - the sequence ordering position of a sort key that is invalid
Returns:
an OdaException with the specified message and invalid sort key identified as the cause
See Also:
#isInvalidSortKey(int, OdaException)}

isInvalidSortKey

public static boolean isInvalidSortKey(int sortKeySequenceOrder,
                                       OdaException rootEx)
Indicates whether the specified sort key is one of the cause(s) in the specified OdaException chain.

Parameters:
sortKeySequenceOrder - the sequence ordering position (1-based) of a sort key whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the sort key
Returns:
true if the specified sort key is one of the cause(s) in the OdaException chain; false otherwise

newSortSpecException

public static OdaException newSortSpecException(SortSpecification sortSpec,
                                                OdaException driverEx)
Creates and returns a top-level OdaException to indicate that the specified sort specification is the cause of the specified driverEx exception.

Parameters:
sortSpec - the invalid SortSpecification to set as the cause
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid sort key identified as the cause
See Also:
#isInvalidSortSpec(SortSpecification, OdaException)}

newSortSpecException

public static OdaException newSortSpecException(java.lang.String message,
                                                SortSpecification sortSpec)
Creates and returns a top-level OdaException to indicate that the specified sort specification is the cause of the specified driverEx exception.

Parameters:
message - custom exception message
sortSpec - the invalid SortSpecification to set as the cause
Returns:
an OdaException with the specified message and invalid sort key identified as the cause
See Also:
#isInvalidSortSpec(SortSpecification, OdaException)}

isInvalidSortSpec

public static boolean isInvalidSortSpec(SortSpecification sortSpec,
                                        OdaException rootEx)
Indicates whether the specified sort specification is one of the cause(s) in the specified OdaException chain.

Parameters:
sortSpec - a sort specification whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the sort specification
Returns:
true if the specified sort specification is one of the cause(s) in the OdaException chain; false otherwise

newResultSetSpecException

public static OdaException newResultSetSpecException(java.lang.String message,
                                                     ResultSetSpecification resultSetSpec,
                                                     OdaException chainedEx)
Creates and returns a top-level OdaException to indicate that the specified result set specification is the cause of the specified driverEx exception.

Parameters:
message - custom exception message
resultSetSpec - the invalid ResultSetSpecification to set as the cause
driverEx - optional detail OdaException thrown by an ODA driver that has detected the invalid state; may be null
Returns:
an OdaException chain with the specified invalid result set specification identified as the cause
See Also:
#isInvalidResultSetSpec(ResultSetSpecification, OdaException)}

isInvalidResultSetSpec

public static boolean isInvalidResultSetSpec(ResultSetSpecification resultSetSpec,
                                             OdaException rootEx)
Indicates whether the specified result set specification is one of the cause(s) in the specified OdaException chain.

Parameters:
resultSetSpec - a result set specification whose processing might have caused an OdaException
rootEx - the root of an OdaException chain caught while processing the result set specification
Returns:
true if the specified result set specification is one of the cause(s) in the OdaException chain; false otherwise