[DS-707] Generify List usage

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5602 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-24 17:37:57 +00:00
parent 77e834038b
commit aa4a35650c
8 changed files with 25 additions and 20 deletions

View File

@@ -516,9 +516,9 @@ public final class BitstreamInfoDAO extends DAOSupport
* @param itemId * @param itemId
* @return the list of bitstream ids for this item * @return the list of bitstream ids for this item
*/ */
public List getItemBitstreams(int itemId) public List<Integer> getItemBitstreams(int itemId)
{ {
List ids = new ArrayList(); List<Integer> ids = new ArrayList<Integer>();
Connection conn = null; Connection conn = null;
PreparedStatement ps = null; PreparedStatement ps = null;
@@ -559,9 +559,9 @@ public final class BitstreamInfoDAO extends DAOSupport
* @param collectionId The id of the collection * @param collectionId The id of the collection
* @return the list of bitstream ids for this item * @return the list of bitstream ids for this item
*/ */
public List getCollectionBitstreams(int collectionId) public List<Integer> getCollectionBitstreams(int collectionId)
{ {
List ids = new ArrayList(); List<Integer> ids = new ArrayList<Integer>();
Connection conn = null; Connection conn = null;
PreparedStatement ps = null; PreparedStatement ps = null;
@@ -602,9 +602,9 @@ public final class BitstreamInfoDAO extends DAOSupport
* @param communityId the community id * @param communityId the community id
* @return the list of bitstream ids for this item * @return the list of bitstream ids for this item
*/ */
public List getCommunityBitstreams(int communityId) public List<Integer> getCommunityBitstreams(int communityId)
{ {
List ids = new ArrayList(); List<Integer> ids = new ArrayList<Integer>();
Connection conn = null; Connection conn = null;
PreparedStatement ps = null; PreparedStatement ps = null;

View File

@@ -119,12 +119,12 @@ public final class ChecksumResultDAO extends DAOSupport
* *
* @return a list of all the result codes * @return a list of all the result codes
*/ */
public List listAllCodes() public List<String> listAllCodes()
{ {
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;
ResultSet rs = null; ResultSet rs = null;
List codes = new ArrayList(); List<String> codes = new ArrayList<String>();
try try
{ {
conn = DatabaseManager.getConnection(); conn = DatabaseManager.getConnection();

View File

@@ -127,7 +127,7 @@ public class HandleDispatcher implements BitstreamDispatcher
} }
} }
List ids = new ArrayList(); List<Integer> ids = new ArrayList<Integer>();
switch (dsoType) switch (dsoType)
{ {

View File

@@ -72,7 +72,7 @@ public class ItemIterator
private TableRowIterator itemRows; private TableRowIterator itemRows;
/** a real iterator which works over the item ids when present */ /** a real iterator which works over the item ids when present */
private Iterator iditr; private Iterator<Integer> iditr;
/** /**
* Construct an item iterator using a set of TableRow objects from * Construct an item iterator using a set of TableRow objects from
@@ -97,7 +97,7 @@ public class ItemIterator
* @param iids * @param iids
* the array list to be iterated over * the array list to be iterated over
*/ */
public ItemIterator(Context context, List iids) public ItemIterator(Context context, List<Integer> iids)
{ {
ourContext = context; ourContext = context;
iditr = iids.iterator(); iditr = iids.iterator();
@@ -155,7 +155,7 @@ public class ItemIterator
if (iditr.hasNext()) if (iditr.hasNext())
{ {
// get the id // get the id
int id = ((Integer) iditr.next()).intValue(); int id = iditr.next().intValue();
// Check cache // Check cache
Item fromCache = (Item) ourContext.fromCache(Item.class, id); Item fromCache = (Item) ourContext.fromCache(Item.class, id);
@@ -206,7 +206,7 @@ public class ItemIterator
if (iditr.hasNext()) if (iditr.hasNext())
{ {
// get the id // get the id
int id = ((Integer) iditr.next()).intValue(); int id = iditr.next().intValue();
return id; return id;
} }

View File

@@ -39,7 +39,8 @@ package org.dspace.content;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
@@ -363,7 +364,7 @@ public class MetadataValue
* @throws SQLException * @throws SQLException
* @throws AuthorizeException * @throws AuthorizeException
*/ */
public static java.util.Collection findByField(Context context, int fieldId) public static List<MetadataValue> findByField(Context context, int fieldId)
throws IOException, SQLException, AuthorizeException throws IOException, SQLException, AuthorizeException
{ {
// Grab rows from DB // Grab rows from DB
@@ -372,7 +373,7 @@ public class MetadataValue
fieldId); fieldId);
TableRow row = null; TableRow row = null;
java.util.Collection ret = new ArrayList(); List<MetadataValue> ret = new ArrayList<MetadataValue>();
try try
{ {
while (tri.hasNext()) while (tri.hasNext())

View File

@@ -105,7 +105,7 @@ public class ItemIteratorTest extends AbstractUnitTest
iitr = Item.findAll(context); iitr = Item.findAll(context);
iitid = new ItemIterator(context, list); iitid = new ItemIterator(context, list);
iitnone = new ItemIterator(context, new ArrayList()); iitnone = new ItemIterator(context, new ArrayList<Integer>());
} }
catch (AuthorizeException ex) catch (AuthorizeException ex)
{ {

View File

@@ -38,6 +38,8 @@ import java.io.IOException;
import org.databene.contiperf.Required; import org.databene.contiperf.Required;
import org.databene.contiperf.PerfTest; import org.databene.contiperf.PerfTest;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.AbstractIntegrationTest; import org.dspace.AbstractIntegrationTest;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
@@ -137,10 +139,10 @@ public class MetadataIntegrationTest extends AbstractIntegrationTest
} }
assertTrue("testCreateSchema 4", exist); assertTrue("testCreateSchema 4", exist);
java.util.Collection col1 = MetadataValue.findByField(context, field1.getFieldID()); List<MetadataValue> col1 = MetadataValue.findByField(context, field1.getFieldID());
assertTrue("testCreateSchema 5", col1.contains(value1)); assertTrue("testCreateSchema 5", col1.contains(value1));
java.util.Collection col2 = MetadataValue.findByField(context, field2.getFieldID()); List<MetadataValue> col2 = MetadataValue.findByField(context, field2.getFieldID());
assertTrue("testCreateSchema 6", col2.contains(value2)); assertTrue("testCreateSchema 6", col2.contains(value2));
//clean database //clean database

View File

@@ -36,6 +36,8 @@ package org.dspace.content;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import org.dspace.AbstractUnitTest; import org.dspace.AbstractUnitTest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
@@ -305,7 +307,7 @@ public class MetadataValueTest extends AbstractUnitTest
{ {
mv.create(context); mv.create(context);
int fieldId = mv.getFieldId(); int fieldId = mv.getFieldId();
Collection found = MetadataValue.findByField(context, fieldId); List<MetadataValue> found = MetadataValue.findByField(context, fieldId);
assertThat("testFind 0",found, notNullValue()); assertThat("testFind 0",found, notNullValue());
assertTrue("testFind 1",found.size() >= 1); assertTrue("testFind 1",found.size() >= 1);
} }