[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
* @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;
PreparedStatement ps = null;
@@ -559,9 +559,9 @@ public final class BitstreamInfoDAO extends DAOSupport
* @param collectionId The id of the collection
* @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;
PreparedStatement ps = null;
@@ -602,9 +602,9 @@ public final class BitstreamInfoDAO extends DAOSupport
* @param communityId the community id
* @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;
PreparedStatement ps = null;

View File

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

View File

@@ -72,7 +72,7 @@ public class ItemIterator
private TableRowIterator itemRows;
/** 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
@@ -97,7 +97,7 @@ public class ItemIterator
* @param iids
* the array list to be iterated over
*/
public ItemIterator(Context context, List iids)
public ItemIterator(Context context, List<Integer> iids)
{
ourContext = context;
iditr = iids.iterator();
@@ -155,7 +155,7 @@ public class ItemIterator
if (iditr.hasNext())
{
// get the id
int id = ((Integer) iditr.next()).intValue();
int id = iditr.next().intValue();
// Check cache
Item fromCache = (Item) ourContext.fromCache(Item.class, id);
@@ -206,7 +206,7 @@ public class ItemIterator
if (iditr.hasNext())
{
// get the id
int id = ((Integer) iditr.next()).intValue();
int id = iditr.next().intValue();
return id;
}

View File

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

View File

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

View File

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

View File

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