## org.eclipse.datatools.sqltools.sqlbuilder.model
Class FunctionHelper

    java.lang.Object
      org.eclipse.datatools.sqltools.sqlbuilder.model.FunctionHelper

Direct Known Subclasses:
  FunctionHelperDB2

    public class FunctionHelper

extends java.lang.Object

This class provides helpful services for dealing with SQL functions. The fields and methods in this class are generic for databases. Subclasses provide database-specific services.

Author:
  bpayton

Field Summary
`static int` `ALL_LOCATION_BOTTOM` "All functions" label should appear at bottom of category list.
`static int` `ALL_LOCATION_OMITTED` "All functions" label should be omitted from category list.
`static int` `ALL_LOCATION_SORTED` "All functions" label should appear sorted with other category labels in the category list.
`static int` `ALL_LOCATION_TOP` "All functions" label should appear at top of category list.
`static java.lang.String` `CAT_LABEL_AGGREGATE_FUNCTIONS` Aggregate (AKA column, grouping, summary) functions category label.
`static java.lang.String` `CAT_LABEL_ALL_FUNCTIONS` All functions category label.
`static java.lang.String` `CAT_LABEL_CONVERSION_FUNCTIONS` Conversion functions category label.
`static java.lang.String` `CAT_LABEL_DATETIME_FUNCTIONS` Date, time, timestamp functions category label.
`static java.lang.String` `CAT_LABEL_NUMERIC_FUNCTIONS` Math functions category label.
`static java.lang.String` `CAT_LABEL_SCALAR_FUNCTIONS` Scalar functions category label.
`static java.lang.String` `CAT_LABEL_SPECIAL_REGISTERS` Special Registers category label.
`static java.lang.String` `CAT_LABEL_STRING_FUNCTIONS` Text functions category label.
`static java.lang.String` `CAT_LABEL_USER_DEFINED_FUNCTIONS` User-Defined Functions (UDF) category label.

Constructor Summary
`FunctionHelper(Database db)` Constructs an instance of this class with an association to the given database.

Method Summary
`java.util.List` `getAggregateFunctionNames()` Gets a list of names of the aggregate (AKA column, grouping, summary) functions supported by the database.
`java.util.List` `getAllBuiltinFunctionNames()` Gets a list of names of all the built-in functions supported by the database.
`java.util.List` `getConversionFunctionNames()` Gets a list of names of the conversion (cast) functions supported by the database.
`Database` `getDatabase()` Gets the `Database` object with which this helper is associated.
`java.util.List` `getDatetimeFunctionNames()` Gets a list of the names of datetime (date, time, timestamp) functions supported by the database.
`java.util.List` `getFunctionCategories(int allCatLocation)` Gets a list of all function categories supported by the database.
`java.util.List` `getFunctionNames(java.lang.String category)` Gets a list of function names supported by the associated database in the given function category.
`java.lang.String[][]` `getFunctionSignatures(java.lang.String functionName)` Gets an array of arrays (ie, a table) containing the function signatures specified by the given named function.
`static FunctionHelper` `getInstance(Database db)` Gets an instance of `FunctionHelper` that is the best match for the database represented by the given `Database` object.
`boolean` `getIsFunctionAllowingStar(java.lang.String funcName)` Gets whether or not the given function allows "*" as a parameter (ie, COUNT(*) ).
`java.util.List` `getNumericFunctionNames()` Gets a list of the names of numeric (math) functions supported by the database.
`java.util.List` `getScalarFunctionNames()` Gets a list of names of scalar functions supported by the database.
`java.util.List` `getSpecialRegisterNames()` Gets a list of special registers supported by the database.
`java.util.List` `getStringFunctionNames()` Gets a list of string (text) functions supported by the database.
`java.util.List` `getUserDefinedFunctionNames()` Gets a list of user-defined functions supported by the database.

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

Field Detail

### CAT_LABEL_ALL_FUNCTIONS

    public static final java.lang.String CAT_LABEL_ALL_FUNCTIONS

  All functions category label.

### CAT_LABEL_AGGREGATE_FUNCTIONS

    public static final java.lang.String CAT_LABEL_AGGREGATE_FUNCTIONS

  Aggregate (AKA column, grouping, summary) functions category label.

### CAT_LABEL_CONVERSION_FUNCTIONS

    public static final java.lang.String CAT_LABEL_CONVERSION_FUNCTIONS

  Conversion functions category label.

### CAT_LABEL_DATETIME_FUNCTIONS

    public static final java.lang.String CAT_LABEL_DATETIME_FUNCTIONS

  Date, time, timestamp functions category label.

### CAT_LABEL_NUMERIC_FUNCTIONS

    public static final java.lang.String CAT_LABEL_NUMERIC_FUNCTIONS

  Math functions category label.

### CAT_LABEL_SCALAR_FUNCTIONS

    public static final java.lang.String CAT_LABEL_SCALAR_FUNCTIONS

  Scalar functions category label.

### CAT_LABEL_SPECIAL_REGISTERS

    public static final java.lang.String CAT_LABEL_SPECIAL_REGISTERS

  Special Registers category label.

### CAT_LABEL_STRING_FUNCTIONS

    public static final java.lang.String CAT_LABEL_STRING_FUNCTIONS

  Text functions category label.

### CAT_LABEL_USER_DEFINED_FUNCTIONS

    public static final java.lang.String CAT_LABEL_USER_DEFINED_FUNCTIONS

  User-Defined Functions (UDF) category label.

### ALL_LOCATION_OMITTED

    public static final int ALL_LOCATION_OMITTED

  "All functions" label should be omitted from category list.

  See Also:
    Constant Field Values

### ALL_LOCATION_TOP

    public static final int ALL_LOCATION_TOP

  "All functions" label should appear at top of category list.

  See Also:
    Constant Field Values

### ALL_LOCATION_BOTTOM

    public static final int ALL_LOCATION_BOTTOM

  "All functions" label should appear at bottom of category list.

  See Also:
    Constant Field Values

### ALL_LOCATION_SORTED

    public static final int ALL_LOCATION_SORTED

  "All functions" label should appear sorted with other category labels in the category list.

  See Also:
    Constant Field Values

Constructor Detail

### FunctionHelper

    public FunctionHelper(Database db)

  Constructs an instance of this class with an association to the given database.

  Parameters:
    `db` - the `Database` for which function help is needed

Method Detail

### getInstance

    public static FunctionHelper getInstance(Database db)

  Gets an instance of `FunctionHelper` that is the best match for the database represented by the given `Database` object.

  Returns:
    the function helper appropriate for the given database or null if an appropriate function helper can't be found

### getDatabase

    public Database getDatabase()

  Gets the `Database` object with which this helper is associated.

  Returns:
    the database for which function help is needed

### getFunctionCategories

    public java.util.List getFunctionCategories(int allCatLocation)

  Gets a list of all function categories supported by the database. The list is sorted so it will look better when the labels are translated. A special category label "All Categories" can optionally be added to the list, at one of three positions in the list (top, bottom, or sorted). See ALL_LOCATION_xxx constants defined in this class.

  Parameters:
    `allCatLocation` - indicates if, and where, the "All categories" category label should appear in the category list
  Returns:
    the list of category labels

### getFunctionNames

    public java.util.List getFunctionNames(java.lang.String category)

  Gets a list of function names supported by the associated database in the given function category. Subclasses can override this method to support additional categories.

  Parameters:
    `category` - the function category for which functions are needed
  Returns:
    the list of the function names, or an empty list if the category is not supported by the database

### getAllBuiltinFunctionNames

    public java.util.List getAllBuiltinFunctionNames()

  Gets a list of names of all the built-in functions supported by the database. The list is sorted with no duplicates.

  Returns:
    the list of all built-in functions

### getAggregateFunctionNames

    public java.util.List getAggregateFunctionNames()

  Gets a list of names of the aggregate (AKA column, grouping, summary) functions supported by the database.

  Returns:
    the list of aggregate functions

### getConversionFunctionNames

    public java.util.List getConversionFunctionNames()

  Gets a list of names of the conversion (cast) functions supported by the database.

  Returns:
    the list of conversion functions

### getDatetimeFunctionNames

    public java.util.List getDatetimeFunctionNames()

  Gets a list of the names of datetime (date, time, timestamp) functions supported by the database.

  Returns:
    the list of datetime functions

### getNumericFunctionNames

    public java.util.List getNumericFunctionNames()

  Gets a list of the names of numeric (math) functions supported by the database.

  Returns:
    the list of numeric functions

### getScalarFunctionNames

    public java.util.List getScalarFunctionNames()

  Gets a list of names of scalar functions supported by the database. The scalar functions are all the functions in the conversion, datetime, numeric, and string categories. The list is sorted with no duplicates.

  Returns:
    the list of scalar functions

### getSpecialRegisterNames

    public java.util.List getSpecialRegisterNames()

  Gets a list of special registers supported by the database.

  Returns:
    the list of special registers

### getStringFunctionNames

    public java.util.List getStringFunctionNames()

  Gets a list of string (text) functions supported by the database.

  Returns:
    the list of string functions

### getUserDefinedFunctionNames

    public java.util.List getUserDefinedFunctionNames()

  Gets a list of user-defined functions supported by the database.

  Returns:
    the list

### getFunctionSignatures

    public java.lang.String[][] getFunctionSignatures(java.lang.String functionName)

  Gets an array of arrays (ie, a table) containing the function signatures specified by the given named function. Each "row" in the "table" describes a function signature. In each row, the first "column" contains the return type, and the remaning columns describe the input parameter types. It shouldn't be necessary for subclasses to override this method.

  Parameters:
    `functionName` - the name of the function for which the parameter formats are wanted
  Returns:
    the table of function signatures

### getIsFunctionAllowingStar

    public boolean getIsFunctionAllowingStar(java.lang.String funcName)

  Gets whether or not the given function allows "*" as a parameter (ie, COUNT(*) ).

  Parameters:
    `funcName` - the name of the function to check
  Returns:
    true when the function supports the "*" parameter format, otherwise false