You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2008/01/05 13:35:24 UTC
svn commit: r609130 - in
/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access:
ResultIterator.java jdbc/JDBCResultIterator.java
jdbc/SQLTemplateResourceManager.java
Author: aadamchik
Date: Sat Jan 5 04:34:44 2008
New Revision: 609130
URL: http://svn.apache.org/viewvc?rev=609130&view=rev
Log:
generics
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateResourceManager.java
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java?rev=609130&r1=609129&r2=609130&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java Sat Jan 5 04:34:44 2008
@@ -23,64 +23,60 @@
import java.util.Map;
import org.apache.cayenne.CayenneException;
+import org.apache.cayenne.DataRow;
import org.apache.cayenne.map.DbEntity;
/**
- * Defines API of an iterator over the records returned as a result
- * of SelectQuery execution. Usually a ResultIterator is supported by
- * an open java.sql.ResultSet, therefore most of the methods would throw
- * checked exceptions. ResultIterators must be explicitly closed when the
- * user is done working with them.
- *
- * <p><i>For more information see <a href="../../../../../../userguide/index.html"
- * target="_top">Cayenne User Guide.</a></i></p>
+ * Defines API of an iterator over the records returned as a result of SelectQuery
+ * execution. Usually a ResultIterator is supported by an open java.sql.ResultSet,
+ * therefore most of the methods would throw checked exceptions. ResultIterators must be
+ * explicitly closed when the user is done working with them.
*
* @author Andrus Adamchik
*/
public interface ResultIterator {
-
+
+ /**
+ * Returns all unread data rows from ResultSet and closes this iterator if asked to do
+ * so.
+ */
+ List<DataRow> dataRows(boolean close) throws CayenneException;
+
/**
- * Returns all unread data rows from ResultSet and closes this iterator
- * if asked to do so.
+ * Returns true if there is at least one more record that can be read from the
+ * iterator.
*/
- public List dataRows(boolean close) throws CayenneException;
-
- /**
- * Returns true if there is at least one more record
- * that can be read from the iterator.
- */
- public boolean hasNextRow() throws CayenneException;
-
- /**
- * Returns the next result row as a Map.
- */
- public Map nextDataRow() throws CayenneException;
-
+ boolean hasNextRow() throws CayenneException;
+
/**
- * Returns a map of ObjectId values from the next result row.
- * Primary key columns are determined from the provided DbEntity.
+ * Returns the next result row as a Map.
+ */
+ Map<String, Object> nextDataRow() throws CayenneException;
+
+ /**
+ * Returns a map of ObjectId values from the next result row. Primary key columns are
+ * determined from the provided DbEntity.
*
* @since 1.1
*/
- public Map nextObjectId(DbEntity entity) throws CayenneException;
-
+ Map<String, Object> nextObjectId(DbEntity entity) throws CayenneException;
+
/**
* Skips current data row instead of reading it.
*/
- public void skipDataRow() throws CayenneException;
-
- /**
- * Closes ResultIterator and associated ResultSet. This method must be
- * called explicitly when the user is finished processing the records.
- * Otherwise unused database resources will not be released properly.
- */
- public void close() throws CayenneException;
-
+ void skipDataRow() throws CayenneException;
+
+ /**
+ * Closes ResultIterator and associated ResultSet. This method must be called
+ * explicitly when the user is finished processing the records. Otherwise unused
+ * database resources will not be released properly.
+ */
+ void close() throws CayenneException;
+
/**
* Returns the number of columns in the result row.
*
* @since 1.0.6
*/
- public int getDataRowWidth();
+ int getDataRowWidth();
}
-
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java?rev=609130&r1=609129&r2=609130&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java Sat Jan 5 04:34:44 2008
@@ -69,7 +69,7 @@
protected boolean nextRow;
protected int fetchedSoFar;
protected int fetchLimit;
-
+
private String[] labels;
private int[] types;
@@ -89,15 +89,15 @@
this.mapCapacity = (int) Math.ceil((descriptor.getWidth()) / 0.75);
checkNextRow();
-
- if(nextRow) {
+
+ if (nextRow) {
// extract column parameters to speed up processing...
ColumnDescriptor[] columns = descriptor.getColumns();
int width = columns.length;
labels = new String[width];
types = new int[width];
-
- for(int i = 0; i < width; i++) {
+
+ for (int i = 0; i < width; i++) {
labels[i] = columns[i].getLabel();
types[i] = columns[i].getJdbcType();
}
@@ -107,12 +107,12 @@
/**
* Returns all unread data rows from ResultSet, closing this iterator if needed.
*/
- public List dataRows(boolean close) throws CayenneException {
- List list = new ArrayList();
+ public List<DataRow> dataRows(boolean close) throws CayenneException {
+ List<DataRow> list = new ArrayList<DataRow>();
try {
- while (this.hasNextRow()) {
- list.add(this.nextDataRow());
+ while (hasNextRow()) {
+ list.add((DataRow) nextDataRow());
}
}
finally {
@@ -135,14 +135,14 @@
/**
* Returns the next result row as a Map.
*/
- public Map nextDataRow() throws CayenneException {
+ public Map<String, Object> nextDataRow() throws CayenneException {
if (!hasNextRow()) {
throw new CayenneException(
"An attempt to read uninitialized row or past the end of the iterator.");
}
// read
- Map row = readDataRow();
+ Map<String, Object> row = readDataRow();
// rewind
checkNextRow();
@@ -154,7 +154,7 @@
* Returns a map of ObjectId values from the next result row. Primary key columns are
* determined from the provided DbEntity.
*/
- public Map nextObjectId(DbEntity entity) throws CayenneException {
+ public Map<String, Object> nextObjectId(DbEntity entity) throws CayenneException {
if (!hasNextRow()) {
throw new CayenneException(
"An attempt to read uninitialized row or past the end of the iterator.");
@@ -169,7 +169,7 @@
// read ...
// TODO: note a mismatch with 1.1 API - ID positions are preset and are
// not affected by the entity specified (think of deprecating/replacing this)
- Map row = readIdRow();
+ Map<String, Object> row = readIdRow();
// rewind
checkNextRow();
@@ -220,7 +220,7 @@
// TODO: andrus, 5/8/2006 - closing connection within JDBCResultIterator is
// obsolete as this is bound to transaction closing in DataContext. Deprecate
// this after 1.2
-
+
// close connection, if this object was explicitly configured to be
// responsible for doing it
if (connection != null && isClosingConnection()) {
@@ -278,7 +278,7 @@
/**
* Reads a row from the internal ResultSet at the current cursor position.
*/
- protected Map readDataRow() throws CayenneException {
+ protected Map<String, Object> readDataRow() throws CayenneException {
try {
DataRow dataRow = new DataRow(mapCapacity);
ExtendedType[] converters = rowDescriptor.getConverters();
@@ -312,7 +312,7 @@
* Reads a row from the internal ResultSet at the current cursor position, processing
* only columns that are part of the ObjectId of a target class.
*/
- protected Map readIdRow() throws CayenneException {
+ protected Map<String, Object> readIdRow() throws CayenneException {
try {
DataRow idRow = new DataRow(2);
ExtendedType[] converters = rowDescriptor.getConverters();
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateResourceManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateResourceManager.java?rev=609130&r1=609129&r2=609130&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateResourceManager.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateResourceManager.java Sat Jan 5 04:34:44 2008
@@ -45,7 +45,7 @@
extends ResourceLoader
implements ResourceManager {
- protected Map templateCache;
+ protected Map<String, Template> templateCache;
public void initialize(RuntimeServices rs) throws Exception {
super.rsvc = rs;
@@ -63,7 +63,7 @@
throws ResourceNotFoundException, ParseErrorException, Exception {
synchronized (templateCache) {
- Template resource = (Template) templateCache.get(resourceName);
+ Template resource = templateCache.get(resourceName);
if (resource == null) {
resource = new Template();