: Class Aggregate_MinMax

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ModSQL
Class Aggregate_MinMax

    java.lang.Object
      |
      +--ModSQL.AbstractFunction
            |
            +--ModSQL.AbstractAggregate
                  |
                  +--ModSQL.Aggregate_MinMax

All Implemented Interfaces:
  Aggregate, Function

final class Aggregate_MinMax
extends AbstractAggregate

Implementation of SQL aggregate functions MIN() and MAX().

Author:
  chris.studholme@utoronto.ca

Field Summary
`private boolean` | `max` Function type: true for MAX(), false for MIN().
`private Object` | `minmax` Current minimum/maximum value.

Fields inherited from class ModSQL.AbstractAggregate
`distinct, distinct_set`

Fields inherited from class ModSQL.AbstractFunction
`all_constant, constant_non_null, evaluate_order, evaluate_order_array, out_of_order, parameter_constant, parameter_value, parameters, parameters_array`

Fields inherited from interface ModSQL.Function
`MATCH_BEGINS, MATCH_EQU, MATCH_GT, MATCH_GTE, MATCH_LT, MATCH_LTE, MATCH_NE`

Constructor Summary
`Aggregate_MinMax(boolean max)` Constructor.

Method Summary
`Object` | `evaluate(boolean aggregate)` Evaluate parameter and check for new minimum/maximum.
`static Function` | `forName(String name)` Returns a new instance of this class if name is "min" or "max".
`String` | `functionName()` Returns "MIN" or "MAX" depending on how this instances was initialized.
`int` | `getMaxResultSize()` Return value is the same as for the parameter, or -1 if there is no parameter.
`int` | `getSQLType()` This method returns the SQL type of the parameter, or NULL if there is no parameter.
`void` | `optimize()` Prepare the function for use.
`void` | `reset()` Reset the minimum/maximum object to NULL.

Methods inherited from class ModSQL.AbstractAggregate
`addDistinctValue, getDistinctSetSize, isAggregate, isConstant, prefixParameters, registerWith, setDistinct`

Methods inherited from class ModSQL.AbstractFunction
`addParameter, convertToSQLType, evaluate, evaluateConstantParameters, evaluateOrder, evaluateParameters, evaluateParameters, getCompatableType, getObjectSQLType, getParameter, getParameterCount, postfixParameters, toString`

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

Methods inherited from interface ModSQL.Function
`addParameter, evaluate, evaluateOrder, getParameter, getParameterCount`

Field Detail

### max

    private boolean max

  Function type: true for MAX(), false for MIN().

### minmax

    private Object minmax

  Current minimum/maximum value.

Constructor Detail

### Aggregate_MinMax

    public Aggregate_MinMax(boolean max)

  Constructor.
  Parameters:
    `max` - true for MAX(), false for MIN()

Method Detail

### forName

    public static Function forName(String name)

  Returns a new instance of this class if name is "min" or "max". The instance is initialized as needed to represent the desired function.
  Parameters:
    `name` - name of function to find
  Returns:
    instance of this class or null if name does not match

### optimize

    public void optimize()
                  throws SQLException

  Prepare the function for use. MIN/MAX accepts at most one parameter and requires a parameter if DISTINCT is requested.

  Overrides:
    `optimize` in class `AbstractFunction`
  Throws:
    `SQLException` - if the parameters are invalid

### functionName

    public String functionName()

  Returns "MIN" or "MAX" depending on how this instances was initialized.
  Overrides:
    `functionName` in class `AbstractFunction`
  Returns:
    name of function

### getSQLType

    public int getSQLType()
                   throws SQLException

  This method returns the SQL type of the parameter, or NULL if there is no parameter.
  Returns:
    SQL type of data to be returned
  Throws:
    `SQLException` - if a database-access error occurs

### getMaxResultSize

    public int getMaxResultSize()
                         throws SQLException

  Return value is the same as for the parameter, or -1 if there is no parameter.
  Returns:
    maximum size of String returned or -1 if unknown
  Throws:
    `SQLException` - if a database-access error occurs

### reset

    public void reset()
               throws SQLException

  Reset the minimum/maximum object to NULL.
  Overrides:
    `reset` in class `AbstractAggregate`
  Throws:
    `SQLException` - if a database error occurs

### evaluate

    public Object evaluate(boolean aggregate)
                    throws SQLException,
                           EndOfTable

  Evaluate parameter and check for new minimum/maximum. This method always returns the current/new minimum/maximum value, regardless of aggregate. If aggregate is true, the parameter is not evaluated.

  Parameters:
    `aggregate` - true to return final aggregate value
  Returns:
    current minimum/maximum object
  Throws:
    `SQLException` - if a database-access error occurs
    `EndOfTable` - if thrown by a parameter

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD