jcs.xml.resultset
Class ResultSetVector

java.lang.Object
  |
  +--jcs.xml.resultset.ResultSetVector

public class ResultSetVector
extends java.lang.Object
implements java.io.Serializable

A class to contain a Java Vector with the values of an SQL result set.

See Also:
Serialized Form

Constructor Summary
ResultSetVector(java.lang.String query, java.lang.String server)
          Constructs a ResultSetVector from the SQL result set returned by the argument query.
ResultSetVector(java.util.Vector arg)
          Constructs a ResultSetVector from a plain Vector.
 
Method Summary
 java.lang.Boolean allString(int columnNumber, java.lang.String compOp, java.lang.String comparand)
          Returns the universal quantification of a given comparison to a given column of the ResultSetVector.
static java.lang.String checkSquare(java.util.Vector arg)
          Checks that the arg vector has the shape of an SQL result set.
 java.lang.String[] columnArray(int j)
          Returns the j-th column as a String array.
 int columnCount()
          Returns the number of columns.
 java.util.Vector columnVector(int j)
          Returns the j-th column as a Vector.
 java.util.Vector content()
          Returns the content field.
 java.lang.String getColumn(int i, int j)
          Returns the value of row i column j as a String
 java.lang.String[] rowArray(int i)
          Returns the i-th row as a String array.
 int rowCount()
          Returns the number of rows.
 java.util.Vector rowVector(int i)
          Returns the i-th row as a Vector.
 java.lang.Boolean someString(int columnNumber, java.lang.String compOp, java.lang.String comparand)
          Returns the existential quantification of a given comparison to a given column of the ResultSetVector.
 java.lang.String toString()
          Overrides the Object.toString method.
 java.lang.String toStringColumn(int j, java.lang.String columnSeparator)
          Returns a string representation of a given column of the result set.
 java.lang.String toStringRow(int i, java.lang.String columnSeparator)
          Returns a string representation of a given row of the result set.
 java.lang.String toStringTable(java.lang.String rowSeparator, java.lang.String columnSeparator)
          A 'toString' method for the entire result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultSetVector

public ResultSetVector(java.util.Vector arg)
                throws java.lang.Exception
Constructs a ResultSetVector from a plain Vector.
Parameters:
arg - a Vector that has the characteristics of an SQL result set. It must be a Vector of Vectors, with each sub-Vector having the same number of elements.
Throws:
java.lang.Exception - Thrown if the Vector does not have the required characteristics.

ResultSetVector

public ResultSetVector(java.lang.String query,
                       java.lang.String server)
                throws java.lang.ClassNotFoundException,
                       java.sql.SQLException,
                       java.lang.Exception
Constructs a ResultSetVector from the SQL result set returned by the argument query.

Example Java code:

 
  ResultSetVector rsv     //  A client-side call
     = new ResultSetVector("select * from systypes", "antibes:4000?user=sa");
  ResultSetVector rsv2    //  A server-side call
     = new ResultSetVector("select * from emp, dept where emp.dno=dept.dno", "");
  
Parameters:
query - a string that is the SQL query whose result set is to be returned as a ResultSetVector
server - a string that identifies the SQL server in which to execute the query. See the connectTo method for a description of this parameter.
Throws:
java.lang.ClassNotFoundException - Thrown when the XML parser class cannot be loaded.
java.sql.SQLException - Thrown for any exceptions raised during execution of the SQL statement
java.lang.Exception - Thrown for invalid parameters and other conditions
Method Detail

content

public java.util.Vector content()
Returns the content field.
Returns:
the contained Vector.

checkSquare

public static java.lang.String checkSquare(java.util.Vector arg)
                                    throws java.lang.Exception
Checks that the arg vector has the shape of an SQL result set.
Parameters:
arg - a Vector that has the characteristics of an SQL result set.
Returns:
a string that is empty if the parameter is OK, and is otherwise a string that will be included in the exception
Throws:
java.lang.Exception - To be added

rowCount

public int rowCount()
Returns the number of rows.
Returns:
an int that is the number of rows

columnCount

public int columnCount()
Returns the number of columns.
Returns:
an int that is the number of columns

getColumn

public java.lang.String getColumn(int i,
                                  int j)
Returns the value of row i column j as a String
Parameters:
i - an int that is the number of a row of the result set Vector
j - an int that is the number of a column of the result set Vector
Returns:
a string that is the valud of the given column of the given row

toString

public java.lang.String toString()
Overrides the Object.toString method.
Returns:
a string that is a display of the result set Vector
Overrides:
toString in class java.lang.Object

toStringTable

public java.lang.String toStringTable(java.lang.String rowSeparator,
                                      java.lang.String columnSeparator)
A 'toString' method for the entire result set. The string parameters are separators to be placed between row or column elements.
Parameters:
rowSeparator - a string to be inserted between rows in the output
columnSeparator - a string to be inserted between columns in the output
Returns:
a String that is a display of the result set Vector

toStringRow

public java.lang.String toStringRow(int i,
                                    java.lang.String columnSeparator)
Returns a string representation of a given row of the result set. The string parameter is a separator to be placed between columns of the row.
Parameters:
i - an int that is the number of a row of the result set
columnSeparator - a string to be inserted between columns in the output
Returns:
a String that is a display of given row of the result set

toStringColumn

public java.lang.String toStringColumn(int j,
                                       java.lang.String columnSeparator)
Returns a string representation of a given column of the result set. The string parameter is a separator to be placed between the elements of the column.
Parameters:
j - an int that is the number of a column of the result set
columnSeparator - a string to be inserted between columns in the output
Returns:
a String that is a display of the given column of the result set

rowVector

public java.util.Vector rowVector(int i)
Returns the i-th row as a Vector.
Parameters:
i - an int that is the number of a row of the result set
Returns:
a Vector that is the given row of the result set

columnVector

public java.util.Vector columnVector(int j)
Returns the j-th column as a Vector.
Parameters:
j - an int that is the number of a column of the result set
Returns:
a Vector that is the given column of the result set

rowArray

public java.lang.String[] rowArray(int i)
Returns the i-th row as a String array.
Parameters:
i - an int that is the number of a row of the result set
Returns:
a String array that is the given row of the result set

columnArray

public java.lang.String[] columnArray(int j)
Returns the j-th column as a String array.
Parameters:
j - an int that is the number of a column of the result set
Returns:
a String array that is the given column of the result set

allString

public java.lang.Boolean allString(int columnNumber,
                                   java.lang.String compOp,
                                   java.lang.String comparand)
                            throws java.lang.Exception
Returns the universal quantification of a given comparison to a given column of the ResultSetVector.

Example Java code:

rsv.allString(i, "<=", "xxx")
returns true iff for all elements ci of column i of rsv,
ci <= "xxx"
The allString method performs only String comparisons.
Parameters:
columnNumber - the number of a column of the result set
compOp - a string that is one of "=,==,<,>,<>,!=, >=,<=".
comparand - a string that will be the second operand of the compares.
Returns:
a boolean indicating whether the universal quantification is true
Throws:
java.lang.Exception - To be added

someString

public java.lang.Boolean someString(int columnNumber,
                                    java.lang.String compOp,
                                    java.lang.String comparand)
                             throws java.lang.Exception
Returns the existential quantification of a given comparison to a given column of the ResultSetVector.

Example Java code:

rsv.someString(i, "<=", "xxx")
returns true iff for some element ci of column i of rsv,
ci <= "xxx"
The someString method performs only String comparisons.
Parameters:
columnNumber - the number of a column of the result set
compOp - a string that is one of "=,==,<,>,<>,!=, >=,<=".
comparand - a string that will be the second operand of the compares.
Returns:
a boolean indicating whether the existential quantification is true
Throws:
java.lang.Exception - To be added