Method from javax.faces.model.ResultSetDataModel Detail: |
public int getRowCount() {
return (-1);
}
Return -1, since ResultSet does not provide a
standard way to determine the number of available rows without
scrolling through the entire ResultSet , and this can
be very expensive if the number of rows is large.
|
public Map<String, Object> getRowData() {
if (resultSet == null) {
return (null);
} else if (!isRowAvailable()) {
throw new NoRowAvailableException();
}
try {
getMetaData();
return (new ResultSetMap(this, String.CASE_INSENSITIVE_ORDER));
} catch (SQLException e) {
throw new FacesException(e);
}
}
If row data is available, return a Map representing
the values of the columns for the row specified by rowIndex ,
keyed by the corresponding column names. If no wrapped data is
available, return null .
If a non-null Map is returned, its behavior
must correspond to the contract for a mutable Map as
described in the JavaDocs for AbstractMap , with the
following exceptions and specialized behavior:
- The
Map , and any supporting objects it returns,
must perform all column name comparisons in a
case-insensitive manner. This case-insensitivity must be
implemented using a case-insensitive Comparator ,
such as
String.CASE_INSENSITIVE_ORDER .
- The following methods must throw
UnsupportedOperationException : clear() ,
remove() .
- The
entrySet() method must return a Set
that has the following behavior:
- Throw
UnsupportedOperationException for any attempt
to add or remove entries from the Set , either
directly or indirectly through an Iterator
returned by the Set .
- Updates to the
value of an entry in this
set must write through to the corresponding
column value in the underlying ResultSet .
- The
keySet() method must return a Set
that throws UnsupportedOperationException on any
attempt to add or remove keys, either directly or through an
Iterator returned by the Set .
- The
put() method must throw
IllegalArgumentException if a key value for which
containsKey() returns false is
specified. However, if a key already present in the Map
is specified, the specified value must write through to the
corresponding column value in the underlying ResultSet .
- The
values() method must return a
Collection that throws
UnsupportedOperationException on any attempt to add
or remove values, either directly or through an Iterator
returned by the Collection .
|
public int getRowIndex() {
return (index);
}
|
public Object getWrappedData() {
return (this.resultSet);
}
|
public boolean isRowAvailable() {
if (resultSet == null) {
return (false);
} else if (index < 0) {
return (false);
}
try {
if (resultSet.absolute(index + 1)) {
return (true);
} else {
return (false);
}
} catch (SQLException e) {
throw new FacesException(e);
}
}
Return true if there is wrappedData
available, and the result of calling absolute() on the
underlying ResultSet , passing the current value of
rowIndex plus one (to account for the fact that
ResultSet uses one-relative indexing), returns
true . Otherwise, return false .
|
public void setRowIndex(int rowIndex) {
if (rowIndex < -1) {
throw new IllegalArgumentException();
}
// Tell the ResultSet that the previous row was updated if necessary
if (updated && (resultSet != null)) {
try {
if (!resultSet.rowDeleted()) {
resultSet.updateRow();
}
updated = false;
} catch (SQLException e) {
throw new FacesException(e);
}
}
int old = index;
index = rowIndex;
if (resultSet == null) {
return;
}
DataModelListener [] listeners = getDataModelListeners();
if ((old != index) && (listeners != null)) {
Object rowData = null;
if (isRowAvailable()) {
rowData = getRowData();
}
DataModelEvent event =
new DataModelEvent(this, index, rowData);
int n = listeners.length;
for (int i = 0; i < n; i++) {
if (null != listeners[i]) {
listeners[i].rowSelected(event);
}
}
}
}
|
public void setWrappedData(Object data) {
if (data == null) {
metadata = null;
resultSet = null;
setRowIndex(-1);
} else {
metadata = null;
resultSet = (ResultSet) data;
index = -1;
setRowIndex(0);
}
}
|