You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2009/04/30 17:39:59 UTC
svn commit: r770292 - in /openjpa/branches/1.0.x/openjpa-lib/src:
main/java/org/apache/openjpa/lib/rop/ test/java/org/apache/openjpa/lib/rop/
Author: mikedd
Date: Thu Apr 30 15:39:59 2009
New Revision: 770292
URL: http://svn.apache.org/viewvc?rev=770292&view=rev
Log:
OPENJPA-1025 Implementing subList in subclasses of AbstractResultList, based on patch provided by B.J. Reed
Modified:
openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java Thu Apr 30 15:39:59 2009
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
@@ -145,6 +146,10 @@
return list.toArray(a);
}
+ public List subList(int fromIndex, int toIndex) {
+ throw new UnsupportedOperationException();
+ }
+
private class Itr extends AbstractListIterator {
private int _idx = 0;
Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java Thu Apr 30 15:39:59 2009
@@ -152,6 +152,11 @@
return other == this;
}
+ public List subList(int fromIndex, int toIndex) {
+ assertOpen();
+ return _list.subList(fromIndex, toIndex);
+ }
+
private class Itr extends AbstractListIterator {
private int _idx = 0;
Modified: openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java Thu Apr 30 15:39:59 2009
@@ -120,4 +120,9 @@
public Object writeReplace() {
return _list;
}
+
+ public List subList(int fromIndex, int toIndex) {
+ assertOpen();
+ return _list.subList(fromIndex, toIndex);
+ }
}
Modified: openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java Thu Apr 30 15:39:59 2009
@@ -37,9 +37,16 @@
private ResultList[] _lists = null;
+ protected boolean subListSupported = false;
+
public ResultListTest(String test) {
super(test);
}
+
+ public ResultListTest(String test, boolean supportSubList) {
+ super(test);
+ subListSupported = supportSubList;
+ }
/**
* Return a result list to use with the given provider.
@@ -269,4 +276,20 @@
assertTrue(list.isEmpty());
}
}
+
+ public void testSubList() {
+ ResultObjectProvider[] rops = getResultObjectProviders
+ (Collections.EMPTY_LIST);
+ for (int i = 0; i < rops.length; i++) {
+ ResultList list = getResultList(rops[i]);
+ try {
+ List subList = list.subList(0, 0);
+ if (subListSupported == false)
+ fail("Should not support subList.");
+ } catch (UnsupportedOperationException e) {
+ if (subListSupported == true)
+ fail("Should support subList.");
+ }
+ }
+ }
}
Modified: openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java Thu Apr 30 15:39:59 2009
@@ -26,7 +26,7 @@
public class TestEagerResultList extends ResultListTest {
public TestEagerResultList(String test) {
- super(test);
+ super(test, true);
}
protected ResultList getResultList(ResultObjectProvider provider) {
Modified: openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java Thu Apr 30 15:39:59 2009
@@ -26,7 +26,7 @@
public class TestLazyForwardResultList extends ResultListTest {
public TestLazyForwardResultList(String test) {
- super(test);
+ super(test, true);
}
protected ResultList getResultList(ResultObjectProvider provider) {
Modified: openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java?rev=770292&r1=770291&r2=770292&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java (original)
+++ openjpa/branches/1.0.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java Thu Apr 30 15:39:59 2009
@@ -26,7 +26,7 @@
public class TestListResultList extends ResultListTest {
public TestListResultList(String test) {
- super(test);
+ super(test, true);
}
protected ResultList getResultList(ResultObjectProvider provider) {