org.apache.commons.jelly.tags.sql
Class ResultImpl

java.lang.Object
  extended byorg.apache.commons.jelly.tags.sql.ResultImpl
All Implemented Interfaces:
javax.servlet.jsp.jstl.sql.Result

public class ResultImpl
extends java.lang.Object
implements javax.servlet.jsp.jstl.sql.Result

This class creates a cached version of a ResultSet. It's represented as a Result implementation, capable of returing an array of Row objects containing a Column instance for each column in the row.

Note -- this is a private copy for the RI to avoid making the corresponding class in javax.servlet.* public.

Author:
Hans Bergsten, Justyna Horwat

Constructor Summary
ResultImpl(java.util.List listOfMaps)
          This constructor is given a List of Maps where each Map represents a Row of data.
ResultImpl(java.sql.ResultSet rs, int startRow, int maxRows)
          This constructor reads the ResultSet and saves a cached copy.
 
Method Summary
 java.lang.String[] getColumnNames()
          Returns an array of String objects.
 int getRowCount()
          Returns the number of rows in the cached ResultSet
 java.util.SortedMap[] getRows()
          Returns an array of SortedMap objects.
 java.lang.Object[][] getRowsByIndex()
          Returns an array of Object[] objects.
 boolean isLimitedByMaxRows()
          Returns true of the query was limited by a maximum row setting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultImpl

public ResultImpl(java.sql.ResultSet rs,
                  int startRow,
                  int maxRows)
           throws java.sql.SQLException
This constructor reads the ResultSet and saves a cached copy.

Parameters:
rs - an open ResultSet, positioned before the first row
Throws:
if - a database error occurs
java.sql.SQLException

ResultImpl

public ResultImpl(java.util.List listOfMaps)
This constructor is given a List of Maps where each Map represents a Row of data. This constructor is typically used to create a Mock Object representing a result set.

Parameters:
listOfMaps - is a list of Maps where a Map represents a Row keyed by the column name
Method Detail

getRows

public java.util.SortedMap[] getRows()
Returns an array of SortedMap objects. The SortedMap object key is the ColumnName and the value is the ColumnValue. SortedMap was created using the CASE_INSENSITIVE_ORDER Comparator so the key is the case insensitive representation of the ColumnName.

Specified by:
getRows in interface javax.servlet.jsp.jstl.sql.Result
Returns:
an array of Map, or null if there are no rows

getRowsByIndex

public java.lang.Object[][] getRowsByIndex()
Returns an array of Object[] objects. The first index designates the Row, the second the Column. The array stores the value at the specified row and column.

Specified by:
getRowsByIndex in interface javax.servlet.jsp.jstl.sql.Result
Returns:
an array of Object[], or null if there are no rows

getColumnNames

public java.lang.String[] getColumnNames()
Returns an array of String objects. The array represents the names of the columns arranged in the same order as in the getRowsByIndex() method.

Specified by:
getColumnNames in interface javax.servlet.jsp.jstl.sql.Result
Returns:
an array of String[]

getRowCount

public int getRowCount()
Returns the number of rows in the cached ResultSet

Specified by:
getRowCount in interface javax.servlet.jsp.jstl.sql.Result
Returns:
the number of cached rows, or -1 if the Result could not be initialized due to SQLExceptions

isLimitedByMaxRows

public boolean isLimitedByMaxRows()
Returns true of the query was limited by a maximum row setting

Specified by:
isLimitedByMaxRows in interface javax.servlet.jsp.jstl.sql.Result
Returns:
true if the query was limited by a MaxRows attribute


Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.