Package javax.servlet.jsp.jstl.sql
Class ResultImpl
- java.lang.Object
-
- javax.servlet.jsp.jstl.sql.ResultImpl
-
- All Implemented Interfaces:
java.io.Serializable
,Result
class ResultImpl extends java.lang.Object implements Result, java.io.Serializable
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. It is not part of the JSTL API; it serves merely as a back-end to ResultSupport's static methods. Thus, we scope its access to the package.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]
columnNames
private boolean
isLimited
private java.util.List
rowByIndex
private java.util.List
rowMap
-
Constructor Summary
Constructors Constructor Description ResultImpl(java.sql.ResultSet rs, int startRow, int maxRows)
This constructor reads the ResultSet and saves a cached copy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
getColumnNames()
Returns an array of String objects.int
getRowCount()
Returns the number of rows in the cached ResultSetjava.util.SortedMap[]
getRows()
Returns an array of SortedMap objects.java.lang.Object[][]
getRowsByIndex()
Returns an array of Object[] objects.boolean
isLimitedByMaxRows()
Returns true if the query was limited by a maximum row setting
-
-
-
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. It's important to note that this object will be serializable only if the objects returned by the ResultSet are serializable too.- Parameters:
rs
- an open ResultSet, positioned before the first rowstartRow
- beginning row to be cachedmaxRows
- query maximum rows limit- Throws:
java.sql.SQLException
- if a database error occurs
-
-
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.
-
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 interfaceResult
- 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 interfaceResult
- Returns:
- an array of String[]
-
getRowCount
public int getRowCount()
Returns the number of rows in the cached ResultSet- Specified by:
getRowCount
in interfaceResult
- Returns:
- the number of cached rows, or -1 if the Result could not be initialized due to SQLExceptions
-
isLimitedByMaxRows
public boolean isLimitedByMaxRows()
Returns true if the query was limited by a maximum row setting- Specified by:
isLimitedByMaxRows
in interfaceResult
- Returns:
- true if the query was limited by a MaxRows attribute
-
-