kdl.prox.monet
Class ResultSet

java.lang.Object
  extended by kdl.prox.monet.ResultSet

public class ResultSet
extends java.lang.Object

A ResultSet derived from a query. Provides next() and getColumn(i) methods, and getRowCount()

Reads the entire resultSet into memory first, and them users can retrieve each column with calls to next() and getColumn(i) and its derivatives. Passing data from the Monet server to Java is time-consuming, and reading large result sets into memory will consume lots of memory, so users should keep resultSets are small as possible.


Field Summary
protected  java.util.ArrayList<java.lang.String> columnValueList
          The list of column values (as strings) for the current row First set by processcolumnNames, and then updated in every call to next()
protected  java.lang.String currentLine
          The last line read - returned by getLine() next() sets currentLine to the next line, and processes it
protected  MonetStream monetStream
          IVs.
protected  java.lang.String queryText
           
protected  java.util.List<java.lang.String> resultSetLines
          Stores all the lines returned by the resultSet.
protected  int rowCount
          The number of rows in the resultSet.
protected  int rowNum
          The current row Starts with 0 when the resultSet is created Advances with each call to next() Is set to -1 when next() goes past the last row
 
Constructor Summary
ResultSet()
          Default constructor
ResultSet(MonetStream monetStream, java.lang.String query)
          Full-arg constructor.
 
Method Summary
 boolean getBoolean(int columnIndex)
          Returns a column in the current row as a boolean
 boolean getBoolean(java.lang.String col)
           
 char getChar(int columnIndex)
          Returns a column in the current row as a char
 char getChar(java.lang.String col)
           
 java.lang.String getColumn(int i)
          Returns the content of the ith column, as a string.
 java.lang.String getColumn(java.lang.String col)
           
 int getColumnCount()
          Returns the number of columns in the resultSet columnValueList is first initialized by processcolumnNames
 java.util.List getColumnList()
          Returns the current line, as a list of strings, one for each column
 double getDouble(int columnIndex)
          Returns a column in the current row as a double
 double getDouble(java.lang.String col)
           
 float getFloat(int columnIndex)
          Returns a column in the current row as a float
 float getFloat(java.lang.String col)
           
 int getInt(int columnIndex)
          Returns a column in the current row as an int
 int getInt(java.lang.String col)
           
 java.lang.String getLine()
          Returns the current line, as read from the Monet server
 int getOID(int columnIndex)
          getInt() variation that is called when the desired column is known to be an OID.
 int getOID(java.lang.String col)
           
 java.lang.String getQueryText()
          Returns the text of the query that created this resultSet
 int getRowCount()
          Returns the number of rows in this resultSet Rows go from 0 - (rowCount-1)
 java.lang.String getString(int columnIndex)
          Returns a column in the current row as a string
 java.lang.String getString(java.lang.String col)
           
 boolean isColumnNil(int columnIndex)
          Returns true if the ith column was the Monet nil value.
 boolean isColumnNil(java.lang.String col)
           
 boolean next()
          Advances the pointer
 ResultSet setColumnNames(java.lang.String[] colNames)
          Sets names for the columns in the resultSet, so you can used named get'ers
 int size()
          For compatibility with JDBC
 java.util.List<java.lang.Double> toDoubleList(java.lang.String col)
           
 java.util.List<java.lang.Integer> toIntList(int columnIndex)
          Returns a List of Integers for columnIndex, starting from the current row to the end.
 java.util.List<java.lang.Integer> toIntList(java.lang.String col)
           
 java.util.List<java.lang.Integer> toOIDList(int columnIndex)
          Returns a List of Integers (OIDs) for columnIndex, starting from the current row to the end.
 java.util.List<java.lang.Integer> toOIDList(java.lang.String col)
           
 java.util.List<java.lang.String> toStringList(int columnIndex)
          Returns a List of StringS for columnIndex, starting from the current row to the end.
 java.util.List<java.lang.String> toStringList(java.lang.String col)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

monetStream

protected MonetStream monetStream
IVs. Set by constructor


queryText

protected java.lang.String queryText

rowNum

protected int rowNum
The current row Starts with 0 when the resultSet is created Advances with each call to next() Is set to -1 when next() goes past the last row


rowCount

protected int rowCount
The number of rows in the resultSet. Set by constructor


currentLine

protected java.lang.String currentLine
The last line read - returned by getLine() next() sets currentLine to the next line, and processes it


columnValueList

protected java.util.ArrayList<java.lang.String> columnValueList
The list of column values (as strings) for the current row First set by processcolumnNames, and then updated in every call to next()


resultSetLines

protected java.util.List<java.lang.String> resultSetLines
Stores all the lines returned by the resultSet. Initialized by constructor, by going through the result and reading every row Then next() advances the lines.

Constructor Detail

ResultSet

public ResultSet()
Default constructor


ResultSet

public ResultSet(MonetStream monetStream,
                 java.lang.String query)
Full-arg constructor. Keeps the stream, reads first line to make sure there are no errors, and then reads everything into memory

Parameters:
monetStream - stream
query - query
Method Detail

getBoolean

public boolean getBoolean(int columnIndex)
Returns a column in the current row as a boolean

Parameters:
columnIndex -
Returns:

getBoolean

public boolean getBoolean(java.lang.String col)

getChar

public char getChar(int columnIndex)
Returns a column in the current row as a char

Parameters:
columnIndex -
Returns:

getChar

public char getChar(java.lang.String col)

getColumn

public java.lang.String getColumn(int i)
Returns the content of the ith column, as a string. NB: Does *not* un- delimit the string.

Parameters:
i -
Returns:

getColumn

public java.lang.String getColumn(java.lang.String col)

getColumnCount

public int getColumnCount()
Returns the number of columns in the resultSet columnValueList is first initialized by processcolumnNames


getColumnList

public java.util.List getColumnList()
Returns the current line, as a list of strings, one for each column

Returns:

getDouble

public double getDouble(int columnIndex)
Returns a column in the current row as a double

Parameters:
columnIndex -
Returns:

getDouble

public double getDouble(java.lang.String col)

getFloat

public float getFloat(int columnIndex)
Returns a column in the current row as a float

Parameters:
columnIndex -
Returns:

getFloat

public float getFloat(java.lang.String col)

getInt

public int getInt(int columnIndex)
Returns a column in the current row as an int

Parameters:
columnIndex -
Returns:

getInt

public int getInt(java.lang.String col)

getLine

public java.lang.String getLine()
Returns the current line, as read from the Monet server

Returns:

getQueryText

public java.lang.String getQueryText()
Returns the text of the query that created this resultSet

Returns:

getRowCount

public int getRowCount()
Returns the number of rows in this resultSet Rows go from 0 - (rowCount-1)

Returns:

getOID

public int getOID(int columnIndex)
getInt() variation that is called when the desired column is known to be an OID. Returns the column in the current row as an int.

Parameters:
columnIndex -
Returns:

getOID

public int getOID(java.lang.String col)

getString

public java.lang.String getString(int columnIndex)
Returns a column in the current row as a string

Parameters:
columnIndex -
Returns:

getString

public java.lang.String getString(java.lang.String col)

isColumnNil

public boolean isColumnNil(int columnIndex)
Returns true if the ith column was the Monet nil value.

Parameters:
columnIndex -
Returns:

isColumnNil

public boolean isColumnNil(java.lang.String col)

next

public boolean next()
Advances the pointer

Returns:
false if there are no more rows

setColumnNames

public ResultSet setColumnNames(java.lang.String[] colNames)
Sets names for the columns in the resultSet, so you can used named get'ers

Parameters:
colNames -

size

public int size()
For compatibility with JDBC

Returns:

toDoubleList

public java.util.List<java.lang.Double> toDoubleList(java.lang.String col)

toIntList

public java.util.List<java.lang.Integer> toIntList(int columnIndex)
Returns a List of Integers for columnIndex, starting from the current row to the end.

Parameters:
columnIndex -
Returns:

toIntList

public java.util.List<java.lang.Integer> toIntList(java.lang.String col)

toOIDList

public java.util.List<java.lang.Integer> toOIDList(int columnIndex)
Returns a List of Integers (OIDs) for columnIndex, starting from the current row to the end.

Parameters:
columnIndex -
Returns:

toOIDList

public java.util.List<java.lang.Integer> toOIDList(java.lang.String col)

toStringList

public java.util.List<java.lang.String> toStringList(int columnIndex)
Returns a List of StringS for columnIndex, starting from the current row to the end.

Parameters:
columnIndex -
Returns:

toStringList

public java.util.List<java.lang.String> toStringList(java.lang.String col)