ModSQL
Interface RowConstructor

All Superinterfaces:
Function
All Known Implementing Classes:
Select, LiteralRow

public interface RowConstructor
extends Function

A row constructor (in SQL speak) is a single row of one or more columns. This interface extends Function by adding methods to access specific columns. The corresponding methods in the Function interface that do not have the column parameter should work as specified in the case of a single column, but should throw an exception in the case of two or more columns.

Author:
chris.studholme@utoronto.ca

Fields inherited from interface ModSQL.Function
MATCH_BEGINS, MATCH_EQU, MATCH_GT, MATCH_GTE, MATCH_LT, MATCH_LTE, MATCH_NE
 
Method Summary
 Object[] evaluateRow(boolean aggregate)
          Evaluate each column of the row and return the results as an array of length equal to the value returned by numColumns().
 int getColumnCount()
          Returns the number of columns the row has.
 int getMaxResultSize(int column)
          Return the maximum number of characters String values in the specified column will have.
 int getSQLType(int column)
          Return the SQL type of the value in the specified column.
 
Methods inherited from interface ModSQL.Function
addParameter, evaluate, evaluate, evaluateOrder, getMaxResultSize, getParameter, getParameterCount, getSQLType, isAggregate, isConstant, optimize, registerWith, reset
 

Method Detail

getColumnCount

public int getColumnCount()
                   throws SQLException

Returns the number of columns the row has. The row will always have at least one column.

This method can only be used after optimize() has been called.

Returns:
number of columns in row list
Throws:
SQLException - if a database-access error occurs

getSQLType

public int getSQLType(int column)
               throws SQLException

Return the SQL type of the value in the specified column.

Function.getSQLType() should work as specified if this row has only one column, but must throw an exception in the case of two or more columns.

This method can only be used after optimize() has been called.

Parameters:
column - column number (starting from zero)
Returns:
SQL type of data to be returned
Throws:
SQLException - if an error occurs
IndexOutOfBoundsException - if the column if out of range

getMaxResultSize

public int getMaxResultSize(int column)
                     throws SQLException

Return the maximum number of characters String values in the specified column will have. If the column is not of String type or if the maximum length is not known, -1 should be returned.

Function.getMaxResultSize() should work as specified if this row has only one column, but must throw an exception in the case of two or more columns.

This method can only be used after optimize() has been called.

Parameters:
column - column number (starting from zero)
Returns:
maximum size of String returned or -1 if unknown
Throws:
SQLException - if an error occurs
IndexOutOfBoundsException - if the column if out of range

evaluateRow

public Object[] evaluateRow(boolean aggregate)
                     throws SQLException,
                            EndOfTable

Evaluate each column of the row and return the results as an array of length equal to the value returned by numColumns(). If the row is the result of a subquery with no rows, the result will be an array of NULL values.

The evaluate() methods in Function should work as specified if this row has only one column, but must throw an exception in the case of two or more columns.

This method can only be used after optimize() has been called.

Parameters:
aggregate - final evaluation of aggregates
Returns:
array of objects
Throws:
SQLException - if an error occurs
EndOfTable - if a database was advanced beyond the end of the table