Author: mikedd
Date: Wed Apr 29 18:42:37 2009
New Revision: 769870
URL: http://svn.apache.org/viewvc?rev=769870&view=rev
Log:
OPENJPA-1025 committing patch provided by B.J. Reed. Removin subList method
from AbstractResultList forcing subclasses to override the method
Modified:
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
Modified:
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
Wed Apr 29 18:42:37 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.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
Wed Apr 29 18:42:37 2009
@@ -80,10 +80,6 @@
throw readOnly();
}
- public List subList(int from, int to) {
- throw new UnsupportedOperationException();
- }
-
protected void assertOpen() {
if (isClosed())
throw new NoSuchElementException(_loc.get("closed").getMessage());
Modified:
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
Wed Apr 29 18:42:37 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.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
Wed Apr 29 18:42:37 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.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
Wed Apr 29 18:42:37 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.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
Wed Apr 29 18:42:37 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.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
Wed Apr 29 18:42:37 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.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java?rev=769870&r1=769869&r2=769870&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
(original)
+++
openjpa/branches/1.3.x/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
Wed Apr 29 18:42:37 2009
@@ -26,7 +26,7 @@
public class TestListResultList extends ResultListTest {
public TestListResultList(String test) {
- super(test);
+ super(test, true);
}
protected ResultList getResultList(ResultObjectProvider provider) {