: Interface Table

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

## ModSQL
Interface Table

All Known Implementing Classes:
  Select, LiteralTable

public interface Table

A table is zero or more rows. Each row consists of one or more columns.

Author:
  chris.studholme@utoronto.ca

Method Summary
`void` | `beforeFirst()` Reset the table to before the first row.
`int` | `getColumnCount()` Returns the number of columns in the table.
`String` | `getColumnName(int column)` Get the name of a column.
`int` | `getMaxResultSize(int column)` Return the maximum number of characters String values in the specified column will have.
`Object` | `getObject(int column)` Get the value of a column in the current row as a Java object.
`Object[]` | `getRow()` Get the current row as an array of Objects.
`long` | `getRowCount()` Get count of number of rows, if known.
`int` | `getSQLType(int column)` Return the SQL type of the specified column.
`boolean` | `isConstant()` Determine if this table is constant.
`boolean` | `next()` The table is initially positioned before its first row; the first call to next makes the first row the current row; the second call makes the second row the current row, etc.
`void` | `optimize()` Prepare the table for use.
`void` | `registerWith(Object o)` Some functions (most notably IndirectValue) needs to register themselves before optimize() can be called.
`String` | `toString(boolean with_brackets)` Return human readable description of table.

Method Detail

### registerWith

    public void registerWith(Object o)
                      throws SQLException

  Some functions (most notably IndirectValue) needs to register themselves before optimize() can be called. This method must call the registerWith() method on all Function objects contained within. Most implementations will simply pass this call on to all contained Function objects.
  Parameters:
    `o` - object to register with
  Throws:
    `SQLException` - if an error occurs

### optimize

    public void optimize()
                  throws SQLException

  Prepare the table for use. This method should call optimize() for all Function objects contained within.
  Throws:
    `SQLException` - if an error occurs

### toString

    public String toString(boolean with_brackets)

  Return human readable description of table.
  Parameters:
    `with_brackets` - bracket the expression
  Returns:
    String representing table

### isConstant

    public boolean isConstant()
                       throws SQLException

  Determine if this table is constant.

  This method can only be called after optimize().

  Returns:
    true if the table is constant
  Throws:
    `SQLException` - if an error occurs

### getRowCount

    public long getRowCount()
                     throws SQLException

  Get count of number of rows, if known. This method is best called immediately after a call to beforeFirst(); however, it still might return -1 in that case too.

  This method can only be called after optimize().

  Returns:
    number of rows or -1 if count is not known
  Throws:
    `SQLException` - if an error occurs

### getColumnCount

    public int getColumnCount()
                       throws SQLException

  Returns the number of columns in the table. The returned value must be greater than zero.

  This method can only be called after optimize().

  Returns:
    number of columns in table
  Throws:
    `SQLException` - if an error occurs

### getColumnName

    public String getColumnName(int column)
                         throws SQLException

  Get the name of a column.

  This method can only be called after optimize().

  Parameters:
    `column` - column number (starting from zero)
  Returns:
    name of column (or null if column has no name)
  Throws:
    `SQLException` - if an error occurs

### getSQLType

    public int getSQLType(int column)
                   throws SQLException

  Return the SQL type of the specified column.

  This method can only be called after optimize().

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

### 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.

  This method can only be called after optimize().

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

### beforeFirst

    public void beforeFirst()
                     throws SQLException

  Reset the table to before the first row. After a call to this method, next() should advance to the first row in the table.

  This method can only be called after optimize().

  Throws:
    `SQLException` - if an error occurs

### next

    public boolean next()
                 throws SQLException,
                        EndOfTable

  The table is initially positioned before its first row; the first call to next makes the first row the current row; the second call makes the second row the current row, etc.

  This method can only be called after optimize().

  Returns:
    true if the new current row is valid; false if there are no more rows
  Throws:
    `SQLException` - if an error occurs
    `EndOfTable` - if the table is advanced beyond that last row

### getRow

    public Object[] getRow()
                    throws SQLException,
                           EndOfTable

  Get the current row as an array of Objects.

  This method can only be called after optimize().

  Returns:
    array of objects or null if current row is not valid
  Throws:
    `SQLException` - if an error occurs
    `EndOfTable` - if the table is advanced beyond that last row

### getObject

    public Object getObject(int column)
                     throws SQLException,
                            EndOfTable

  Get the value of a column in the current row as a Java object. This method will throw an exception if the current row is not valid.

  This method can only be called after optimize().

  Parameters:
    `column` - column number (starting from zero)
  Returns:
    an Object holding the column value
  Throws:
    `SQLException` - if an error occurs
    `EndOfTable` - if the table is advanced beyond that last row

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