## org.eclipse.datatools.sqltools.result
Class ResultSetObject

    java.lang.Object
      org.eclipse.datatools.sqltools.result.ResultSetObject

All Implemented Interfaces:
  java.io.Serializable, IResultSetObject

    public class ResultSetObject

extends java.lang.Object
implements IResultSetObject

A standard implementation of `IResultSetObject` with cache mechanism. The consumer can use constructor `ResultSetObject(List rows, String[] columnNames, int[] columnTypes, int[] columnDisplaySizes)` to construct an instance of `IResultSetObject` given meta data and row data. An usage example is given below:

     IResultSetRow row1 = new ResultSetRow(new String[]
     {
         "1", "21", "Jack"
     });
     IResultSetRow row2 = new ResultSetRow(new String[]
     {
         "2", "23", "Micheal"
     });
     ArrayList rows = new ArrayList();
     rows.add(row1);
     rows.add(row2);
     IResultSetObject rs = new ResultSetObject(rows,
     new String[]
     {
         "Id", "Age", "Name"
     },
     new int[]
     {
         Types.CHAR, Types.CHAR, Types.CHAR
     },
     new int[]
     {
         8, 8, 21
     });

Author:
  Dafan Yang
See Also:
  `ResultSetRow`, Serialized Form

Constructor Summary
`ResultSetObject(java.util.List rows, java.lang.String[] columnNames, int[] columnTypes, int[] columnDisplaySizes)` Constructs a ResultSetObject instance using a list of ResultSetRow instances.
`ResultSetObject(java.util.List rows, java.lang.String[] columnNames, int[] columnTypes, int[] columnDisplaySizes, java.lang.String[] typeNames, int maxDisplayRows)` Constructs a ResultSetObject instance using a list of ResultSetRow instances.
`ResultSetObject(java.sql.ResultSet resultset, int maxRowCount, int maxDisplayRowCount)` Constructs a ResultSetObject instance from a JDBC ResultSet object
`ResultSetObject(java.sql.ResultSet resultset, int maxRowCount, int maxDisplayRowCount, boolean showLabels)` Constructs a ResultSetObject instance from a JDBC ResultSet object

Method Summary
`void` `dispose()` Disposes resource after resultset is closed;
`java.util.Iterator` `getAllRecords()` Returns all result (In memory and file), each element's type should be `IResultSetRow`
`int` `getColumnCount()` Returns the column count
`int` `getColumnDisplaySize(int index)` Returns column display size at the given column (based on 1 --- follows the JDBC convention)
`int[]` `getColumnDisplaySizes()` Returns display size of all columns
`java.lang.String` `getColumnName(int index)` Returns the column name at given index (based on 1 --- follows the JDBC convention)
`java.lang.String[]` `getColumnNames()` Returns the column names
`int` `getColumnSQLType(int index)` Returns column SQL data type at the given column (based on 1 --- follows the JDBC convention)
`int[]` `getColumnSQLTypes()` Returns column SQL types.
`java.lang.String[]` `getColumnTypeNames()` Should be called before result set is closed, otherwise there is no guarantee that correct type names can be returned
`java.util.Iterator` `getDisplayRecords()` Returns the records to display (Loaded in memory), each element's type should be `IResultSetRow`
`int` `getRowCount()` Returns number of rows in result (Loaded in memory)
`IResultSetRow` `getRowData(int row)` Returns row data of given row index (based on 0)
`int` `getTotalRowCount()` Returns total row count (Include cached rows)
`boolean` `isAllResultLoaded()` Checks if some result rows are stored into a temporary file

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

Constructor Detail

### ResultSetObject

    public ResultSetObject(java.sql.ResultSet resultset,
                           int maxRowCount,
                           int maxDisplayRowCount)
                    throws java.sql.SQLException

  Constructs a ResultSetObject instance from a JDBC ResultSet object

  Parameters:
    `resultset` - the JDBC result set object
    `maxRowCount` - to limit the max row count
    `maxDisplayRowCount` - to limit the max display row count
  Throws:
    `java.sql.SQLException` - - if a database access error occurs

### ResultSetObject

    public ResultSetObject(java.sql.ResultSet resultset,
                           int maxRowCount,
                           int maxDisplayRowCount,
                           boolean showLabels)
                    throws java.sql.SQLException

  Constructs a ResultSetObject instance from a JDBC ResultSet object

  Parameters:
    `resultset` - the JDBC result set object
    `maxRowCount` - to limit the max row count
    `maxDisplayRowCount` - to limit the max display row count
    `showLabels` - to check if label is required to display as column heading
  Throws:
    `java.sql.SQLException` - - if a database access error occurs

### ResultSetObject

    public ResultSetObject(java.util.List rows,
                           java.lang.String[] columnNames,
                           int[] columnTypes,
                           int[] columnDisplaySizes)

  Constructs a ResultSetObject instance using a list of ResultSetRow instances. Notice that we will perform restrict validation during the construction:
  - All the parameters should not be null
  - The length of each array should be the same
  - The row object should not be null and must be an instance of IResultSetRow

  Parameters:
    `rows` - a list of IResultSetRow objects
    `columnNames` - column name array
    `columnTypes` - column type array (refer java.sql.Types)
    `columnDisplaySizes` - column display size array

### ResultSetObject

    public ResultSetObject(java.util.List rows,
                           java.lang.String[] columnNames,
                           int[] columnTypes,
                           int[] columnDisplaySizes,
                           java.lang.String[] typeNames,
                           int maxDisplayRows)

  Constructs a ResultSetObject instance using a list of ResultSetRow instances. Notice that we will perform restrict validation during the construction:
  - All the parameters should not be null
  - The length of each array should be the same
  - The row object should not be null and must be an instance of IResultSetRow

  Parameters:
    `rows` - a list of IResultSetRow objects
    `columnNames` - column name array
    `columnTypes` - column type array (refer java.sql.Types)
    `columnDisplaySizes` - column display size array
    `typeNames` - the column type names array
    `maxDisplayRows` - the maximum number of rows to display, 0 means display all rows in the list

Method Detail

### getColumnCount

    public int getColumnCount()

  Description copied from interface: `IResultSetObject`
  Returns the column count

  Specified by:
    `getColumnCount` in interface `IResultSetObject`
  Returns:
    column count

### getColumnNames

    public java.lang.String[] getColumnNames()

  Description copied from interface: `IResultSetObject`
  Returns the column names

  Specified by:
    `getColumnNames` in interface `IResultSetObject`
  Returns:
    column names

### getColumnTypeNames

    public java.lang.String[] getColumnTypeNames()

  Should be called before result set is closed, otherwise there is no guarantee that correct type names can be returned

  Returns:
    type name of all the columns

### getColumnName

    public java.lang.String getColumnName(int index)

  Description copied from interface: `IResultSetObject`
  Returns the column name at given index (based on 1 --- follows the JDBC convention)

  Specified by:
    `getColumnName` in interface `IResultSetObject`
  Parameters:
    `index` - the column index
  Returns:
    column name

### getColumnDisplaySizes

    public int[] getColumnDisplaySizes()

  Description copied from interface: `IResultSetObject`
  Returns display size of all columns

  Specified by:
    `getColumnDisplaySizes` in interface `IResultSetObject`
  Returns:
    columns display sizes

### getColumnDisplaySize

    public int getColumnDisplaySize(int index)

  Description copied from interface: `IResultSetObject`
  Returns column display size at the given column (based on 1 --- follows the JDBC convention)

  Specified by:
    `getColumnDisplaySize` in interface `IResultSetObject`
  Returns:
    column display size

### getColumnSQLTypes

    public int[] getColumnSQLTypes()

  Description copied from interface: `IResultSetObject`
  Returns column SQL types.

  Specified by:
    `getColumnSQLTypes` in interface `IResultSetObject`
  Returns:
    column types

### getColumnSQLType

    public int getColumnSQLType(int index)

  Description copied from interface: `IResultSetObject`
  Returns column SQL data type at the given column (based on 1 --- follows the JDBC convention)

  Specified by:
    `getColumnSQLType` in interface `IResultSetObject`
  Parameters:
    `index` - column index
  Returns:
    column type

### getRowCount

    public int getRowCount()

  Description copied from interface: `IResultSetObject`
  Returns number of rows in result (Loaded in memory)

  Specified by:
    `getRowCount` in interface `IResultSetObject`
  Returns:
    row count

### getTotalRowCount

    public int getTotalRowCount()

  Description copied from interface: `IResultSetObject`
  Returns total row count (Include cached rows)

  Specified by:
    `getTotalRowCount` in interface `IResultSetObject`
  Returns:
    total row count

### getRowData

    public IResultSetRow getRowData(int row)

  Description copied from interface: `IResultSetObject`
  Returns row data of given row index (based on 0)

  Specified by:
    `getRowData` in interface `IResultSetObject`
  Parameters:
    `row` - the row index
  Returns:
    the row data at the given row index

### getAllRecords

    public java.util.Iterator getAllRecords()

  Description copied from interface: `IResultSetObject`
  Returns all result (In memory and file), each element's type should be `IResultSetRow`

  Specified by:
    `getAllRecords` in interface `IResultSetObject`
  Returns:
    an `Iterator` instance over all records
  See Also:
    `IResultSetRow`

### getDisplayRecords

    public java.util.Iterator getDisplayRecords()

  Description copied from interface: `IResultSetObject`
  Returns the records to display (Loaded in memory), each element's type should be `IResultSetRow`

  Specified by:
    `getDisplayRecords` in interface `IResultSetObject`
  Returns:
    an `Iterator` instance over all display record
  See Also:
    `IResultSetRow`

### isAllResultLoaded

    public boolean isAllResultLoaded()

  Description copied from interface: `IResultSetObject`
  Checks if some result rows are stored into a temporary file

  Specified by:
    `isAllResultLoaded` in interface `IResultSetObject`
  Returns:
    `true` if there are no cached rows

### dispose

    public void dispose()

  Description copied from interface: `IResultSetObject`
  Disposes resource after resultset is closed;

  Specified by:
    `dispose` in interface `IResultSetObject`