openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r769801 - in /openjpa/trunk/openjpa-lib/src: main/java/org/apache/openjpa/lib/rop/ test/java/org/apache/openjpa/lib/rop/
Date Wed, 29 Apr 2009 15:37:43 GMT
Author: mikedd
Date: Wed Apr 29 15:37:41 2009
New Revision: 769801

URL: http://svn.apache.org/viewvc?rev=769801&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/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
    openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractNonSequentialResultList.java
Wed Apr 29 15:37:41 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/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/AbstractResultList.java
Wed Apr 29 15:37:41 2009
@@ -82,10 +82,6 @@
         throw readOnly();
     }
 
-    public List<E> subList(int from, int to) {
-        throw new UnsupportedOperationException();
-    }
-
     protected void assertOpen() {
         if (isClosed())
             throw new NoSuchElementException(_loc.get("closed").getMessage());

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/LazyForwardResultList.java
Wed Apr 29 15:37:41 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/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/rop/ListResultList.java
Wed Apr 29 15:37:41 2009
@@ -124,4 +124,9 @@
     public String toString() {
     	return _list.toString();
     }
+
+    public List subList(int fromIndex, int toIndex) {
+        assertOpen();
+        return _list.subList(fromIndex, toIndex);
+    }
 }

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
(original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/ResultListTest.java
Wed Apr 29 15:37:41 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/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestEagerResultList.java
Wed Apr 29 15:37:41 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/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestLazyForwardResultList.java
Wed Apr 29 15:37:41 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/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java?rev=769801&r1=769800&r2=769801&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
(original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/rop/TestListResultList.java
Wed Apr 29 15:37:41 2009
@@ -26,7 +26,7 @@
 public class TestListResultList extends ResultListTest {
 
     public TestListResultList(String test) {
-        super(test);
+        super(test, true);
     }
 
     protected ResultList getResultList(ResultObjectProvider provider) {



Mime
View raw message