## org.eclipse.datatools.modelbase.sql.query.helper
Class ValueExpressionHelper

    java.lang.Object
      org.eclipse.datatools.modelbase.sql.query.helper.ValueExpressionHelper

    public class ValueExpressionHelper

extends java.lang.Object

This class provides a set of utility methods for dealing with Value Expression objects.

Constructor Summary
`ValueExpressionHelper()`

Method Summary
`static void` `addExpressionsToList(java.util.List columnList, QueryValueExpression aValueExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Determines whether a given value expression is already a column expression and if so, adds it to the passed in list.
`static QueryValueExpression` `cloneQueryValueExpression(QueryValueExpression valueExpr)` Returns a copy of the given `valueExpr` using `EcoreUtil#copy(org.eclipse.emf.ecore.EObject)`.
`static DataType` `copyDataType(DataType dataType)` Returns a copy of the given `datatype` using `EcoreUtil#copy(org.eclipse.emf.ecore.EObject)`.
`static void` `copyDataType(QueryValueExpression aSourceExpr, QueryValueExpression aTargetExpr)` Attempts to copy the datatype from one given value expression to another using `EcoreUtil#copy(org.eclipse.emf.ecore.EObject)`.
`static java.util.List` `getColumnsFromSearchCondition(QuerySearchCondition aSearchCond)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a SearchCondition
`static java.util.List` `getColumnsFromValueExpression(QueryValueExpression valueExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a generic ValueExpression Note that only the value expressions listed below can contain columns within them.
`static java.util.List` `getTableNamesFromExpression(QueryValueExpression valueExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the string table name/s from a ValueExpression
`static java.util.List` `getTableRefsFromExpression(QueryValueExpression valueExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the table references from a ValueExpression
`static java.util.List` `getVECaseColumns(ValueExpressionCase aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Extracts and returns a list of column reference objects from the given ValueExpressionCase object.
`static java.util.List` `getVECastColumns(ValueExpressionCast aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionCast
`static java.util.List` `getVECombinedColumns(ValueExpressionCombined combined)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionCombined
`static java.util.List` `getVEFunctionColumns(ValueExpressionFunction funcExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionFunction
`static java.util.List` `getVELabeledDurationColumns(ValueExpressionLabeledDuration labeledDurExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionLabeledDuration
`static DataType` `numericDataTypePromotion(DataType left, DataType right)` Do the numeric data type promotion
`static Column` `resolveColumnFromValueExpression(ValueExpressionColumn aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Determine the Column that corresponds to this column expression if there is one that the given columnExpr is derived from.
`static DataType` `resolveCombinedDataType(DataType aDataType, DataType anotherDataType)` CHANGE IMPLEMENTATION! CODE INCORRECT! returns the given `aDataType`, if not `null`, or the given `anotherDataType`.
`static void` `resolveTablesInValueExpression(QueryValueExpression valExpr, java.util.List tables)` CHECK IMPLEMENTATION! CODE UNTESTED! Substitutes the tables in the given table list into the given Value Expression in place of the one it currently has.
`static void` `resolveValueExpressionCaseDatatype(ValueExpressionCase aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given Case value expression.
`static void` `resolveValueExpressionColumnDatatype(ValueExpressionColumn aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given column value expression.
`static void` `resolveValueExpressionCombined(ValueExpressionCombined aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given "Combined" value expression.
`static void` `resolveValueExpressionConcatDatatype(QueryValueExpression aValExpr, QueryValueExpression aLeftValExpr, QueryValueExpression aRightValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype (DataType) of the given "concatenated" value expression.
`static void` `resolveValueExpressionDatatype(QueryValueExpression valExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype (DataType) of the given value expression.
`static void` `resolveValueExpressionDatatypeRecursively(QueryValueExpression aValueExpr)` Tries to recursively determine and set the datatype (DataType) of the given value expression.
`static void` `resolveValueExpressionDefaultValueDatatype(ValueExpressionDefaultValue aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given "default" value expression.
`static void` `resolveValueExpressionFunctionDatatype(ValueExpressionFunction aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given function value expression.
`static void` `resolveValueExpressionLabeledDurationDatatype(ValueExpressionLabeledDuration aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given labeled duration value expression.
`static void` `resolveValueExpressionListDatatypes(java.util.List aValExprList)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype (DataType) of each of the ValueExpressions in the given list of value expression objects.
`static void` `resolveValueExpressionNullValueDatatype(ValueExpressionNullValue aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given "null" value expression.
`static void` `resolveValueExpressionSimpleDatatype(ValueExpressionSimple aValExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given simple value expression.
`static void` `resolveValueExpressionVariableDatatype(ValueExpressionVariable aVarExpr)` CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given variable value expression, using the given list of table references.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ValueExpressionHelper

    public ValueExpressionHelper()

Method Detail

### addExpressionsToList

    public static void addExpressionsToList(java.util.List columnList,
                                            QueryValueExpression aValueExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Determines whether a given value expression is already a column expression and if so, adds it to the passed in list. Otherwise, get the columns and addAll to the list

  Parameters:
    `List` - list of columns
    `aValueExpr` - QueryValueExpression whose columns will be added to the list

### cloneQueryValueExpression

    public static QueryValueExpression cloneQueryValueExpression(QueryValueExpression valueExpr)

  Returns a copy of the given `valueExpr` using `EcoreUtil#copy(org.eclipse.emf.ecore.EObject)`.

  Parameters:
    `valueExpr` -
  Returns:
    a copy of the given `valueExpr`

### copyDataType

    public static DataType copyDataType(DataType dataType)

  Returns a copy of the given `datatype` using `EcoreUtil#copy(org.eclipse.emf.ecore.EObject)`.

  Parameters:
    `dataType` -
  Returns:
    a copy of the given `datatype`

### copyDataType

    public static void copyDataType(QueryValueExpression aSourceExpr,
                                    QueryValueExpression aTargetExpr)

  Attempts to copy the datatype from one given value expression to another using `EcoreUtil#copy(org.eclipse.emf.ecore.EObject)`. The type is not copied if the source expression does not exist or its datatype is not set.

  Parameters:
    `aSourceExpr` - the value expression whose datatype we want to copy
    `aTargetExpr` - the value expression whose datatype we want to set

### getColumnsFromSearchCondition

    public static java.util.List getColumnsFromSearchCondition(QuerySearchCondition aSearchCond)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a SearchCondition

  Parameters:
    `aSearchCond` - QuerySearchCondition whose columns we need to get
  Returns:
    List list of ValueExpressionColumns

### getColumnsFromValueExpression

    public static java.util.List getColumnsFromValueExpression(QueryValueExpression valueExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a generic ValueExpression Note that only the value expressions listed below can contain columns within them. All other value expressions should return an empty list.

  Parameters:
    `valueExpr` - QueryValueExpression whose columns we need to get
  Returns:
    List list of ValueExpressionColumns

### getTableNamesFromExpression

    public static java.util.List getTableNamesFromExpression(QueryValueExpression valueExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the string table name/s from a ValueExpression

### getTableRefsFromExpression

    public static java.util.List getTableRefsFromExpression(QueryValueExpression valueExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the table references from a ValueExpression

### getVECaseColumns

    public static java.util.List getVECaseColumns(ValueExpressionCase aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Extracts and returns a list of column reference objects from the given ValueExpressionCase object.

  Parameters:
    `aValExpr` - the CASE expression to process
  Returns:
    a list of ValueExpressionColumn objects

### getVECastColumns

    public static java.util.List getVECastColumns(ValueExpressionCast aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionCast

### getVECombinedColumns

    public static java.util.List getVECombinedColumns(ValueExpressionCombined combined)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionCombined

### getVEFunctionColumns

    public static java.util.List getVEFunctionColumns(ValueExpressionFunction funcExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionFunction

### getVELabeledDurationColumns

    public static java.util.List getVELabeledDurationColumns(ValueExpressionLabeledDuration labeledDurExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Method to obtain the column expressions from a ValueExpressionLabeledDuration

### numericDataTypePromotion

    public static DataType numericDataTypePromotion(DataType left,
                                                    DataType right)

  Do the numeric data type promotion

  Parameters:
    `left` -
    `right` -
  Returns:

### resolveColumnFromValueExpression

    public static Column resolveColumnFromValueExpression(ValueExpressionColumn aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Determine the Column that corresponds to this column expression if there is one that the given columnExpr is derived from.

### resolveCombinedDataType

    public static DataType resolveCombinedDataType(DataType aDataType,
                                                   DataType anotherDataType)

  CHANGE IMPLEMENTATION! CODE INCORRECT! returns the given `aDataType`, if not `null`, or the given `anotherDataType`.

  Tries to determine the datatype that can contain values of both given `DataType`s `aDataType` and `anotherDataType`, useful for example for the result columns of a `com.ibm.db.models.sql.query.QueryCombined`

  Parameters:
    `aDataType` - one `DataType`
    `anotherDataType` - another `DataType`
  Returns:
    the inclusive `DataType`

### resolveTablesInValueExpression

    public static void resolveTablesInValueExpression(QueryValueExpression valExpr,
                                                      java.util.List tables)

  CHECK IMPLEMENTATION! CODE UNTESTED! Substitutes the tables in the given table list into the given Value Expression in place of the one it currently has.

  Parameters:
    `valExpr` - the QueryValueExpression whose table need to be resolved
    `tables` - List of TableReference tables

### resolveValueExpressionCaseDatatype

    public static void resolveValueExpressionCaseDatatype(ValueExpressionCase aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given Case value expression.

  Parameters:
    `aValExpr` - a value expression to resolve
    `aTableRefList` - the current list of From clause table references
    `aDB` - a RDBDatabase object containing datatype information
    `aDBVersion` - an object containing database version information

### resolveValueExpressionColumnDatatype

    public static void resolveValueExpressionColumnDatatype(ValueExpressionColumn aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given column value expression.

  Parameters:
    `aValExpr` - a value expression to resolve

### resolveValueExpressionCombined

    public static void resolveValueExpressionCombined(ValueExpressionCombined aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given "Combined" value expression.

  Parameters:
    `aValExpr` - a value expression to resolve

### resolveValueExpressionConcatDatatype

    public static void resolveValueExpressionConcatDatatype(QueryValueExpression aValExpr,
                                                            QueryValueExpression aLeftValExpr,
                                                            QueryValueExpression aRightValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype (DataType) of the given "concatenated" value expression. This may either be a CONCAT function or a "combined" value expression with a CONCAT operator.

  Parameters:
    `aValueExpr` - a value expression to resolve
    `aLeftValueExpr` - the LHS value expression involved in the CONCAT
    `aRightValueExpr` - the RHS value expression involved in the CONCAT

### resolveValueExpressionDatatype

    public static void resolveValueExpressionDatatype(QueryValueExpression valExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype (DataType) of the given value expression. The datatype may be determined through information inherent in this object (for example, by examining the content of a simple value expression), or by checking the datatype of objects that this object is associated with (for example, by getting the datatype of a column to which the value expression is compared).

  Parameters:
    `aValueExpr` - a value expression to resolve

### resolveValueExpressionDatatypeRecursively

    public static void resolveValueExpressionDatatypeRecursively(QueryValueExpression aValueExpr)

  Tries to recursively determine and set the datatype (DataType) of the given value expression. The datatype may be determined through information inherent in this object (for example, by examining the content of a simple value expression), or by checking the datatype of objects that this object is associated with (for example, by getting the datatype of a column to which the value expression is compared).

  Parameters:
    `aValueExpr` - a value expression to resolve

### resolveValueExpressionDefaultValueDatatype

    public static void resolveValueExpressionDefaultValueDatatype(ValueExpressionDefaultValue aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given "default" value expression. Note: this value expression type comes from the DEFAULT keyword in , which is used in Insert and Update statements. It's not a default value expression in the usual sense.

  Parameters:
    `aValExpr` - a value expression to resolve
    `aTableRefList` - the current list of From clause table references
    `aDB` - a RDBDatabase object containing datatype information
    `aDBVersion` - an object containing database version information

### resolveValueExpressionFunctionDatatype

    public static void resolveValueExpressionFunctionDatatype(ValueExpressionFunction aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given function value expression.

  Parameters:
    `aValExpr` - a value expression to resolve
    `aTableRefList` - the current list of From clause table references
    `aDB` - a RDBDatabase object containing datatype information
    `aDBVersion` - an object containing database version information

### resolveValueExpressionLabeledDurationDatatype

    public static void resolveValueExpressionLabeledDurationDatatype(ValueExpressionLabeledDuration aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given labeled duration value expression.

  Parameters:
    `aValExpr` - a value expression to resolve
    `aTableRefList` - the current list of From clause table references
    `aDB` - a RDBDatabase object containing datatype information
    `aDBVersion` - an object containing database version information

### resolveValueExpressionListDatatypes

    public static void resolveValueExpressionListDatatypes(java.util.List aValExprList)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype (DataType) of each of the ValueExpressions in the given list of value expression objects. This is done by either examing the literal value of the expression and determining the datatype from that (if it's a literal value), finding the datatype of the associated Column datatype (if it's a column expression), or locating a "neighboring" value expressions that can determine the datatype of the current value expression.

  Parameters:
    `aValueExprList` - a list of value expressions to resolve
    `aTableRefList` - the current list of From clause table references
    `aDB` - a RDBDatabase object containing datatype information
    `aDBVersion` - an object containing database version information

### resolveValueExpressionNullValueDatatype

    public static void resolveValueExpressionNullValueDatatype(ValueExpressionNullValue aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given "null" value expression. Note: this value expression type comes from the NULL keyword in , which is used in Insert and Update statements. It's not a null value expression in the usual sense.

  Parameters:
    `aValExpr` - a value expression to resolve
    `aTableRefList` - the current list of From clause table references
    `aDB` - a RDBDatabase object containing datatype information
    `aDBVersion` - an object containing database version information

### resolveValueExpressionSimpleDatatype

    public static void resolveValueExpressionSimpleDatatype(ValueExpressionSimple aValExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given simple value expression.

  Parameters:
    `aValExpr` - a value expression to resolve

### resolveValueExpressionVariableDatatype

    public static void resolveValueExpressionVariableDatatype(ValueExpressionVariable aVarExpr)

  CHECK IMPLEMENTATION! CODE UNTESTED! Tries to determine and set the datatype of the given variable value expression, using the given list of table references.

  Parameters:
    `aVarExpr` - a value expression to resolve

Copyright © 2006 -- 2008 Actuate, IBM Corporation, Sybase, Inc. and others. All rights reserved.