chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r938158 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/cli...
Date Mon, 26 Apr 2010 18:00:23 GMT
Author: dcaruana
Date: Mon Apr 26 18:00:22 2010
New Revision: 938158

URL: http://svn.apache.org/viewvc?rev=938158&view=rev
Log:
Paging updates:
- remove getIterator() from PagingIterable (added by mistake)
- added getPageNumItems() to PagingIterable
- updated tests

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterator.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java?rev=938158&r1=938157&r2=938158&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterable.java
Mon Apr 26 18:00:22 2010
@@ -45,12 +45,4 @@ public interface PagingIterable<T> exten
      * @see java.lang.Iterable#iterator()
      */
     PagingIterator<T> iterator();
-
-    /**
-     * Getter version of iterator()
-     *
-     * @see java.lang.Iterable#iterator()
-     * @return iterator
-     */
-    PagingIterator<T> getIterator();
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterator.java?rev=938158&r1=938157&r2=938158&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterator.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/PagingIterator.java
Mon Apr 26 18:00:22 2010
@@ -35,6 +35,13 @@ public interface PagingIterator<T> exten
     long getPosition();
 
     /**
+     * Returns the number of items fetched for the current page.
+     * 
+     * @return number of items for currently fetched page
+     */
+    long getPageNumItems();
+    
+    /**
      * Returns whether the repository contains additional items beyond the page of
      * items already fetched.
      * 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java?rev=938158&r1=938157&r2=938158&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterator.java
Mon Apr 26 18:00:22 2010
@@ -18,9 +18,12 @@
  */
 package org.apache.chemistry.opencmis.client.runtime.util;
 
+import java.util.List;
+
 import org.apache.chemistry.opencmis.client.api.PagingIterator;
 import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch.PageFetchResult;
 
+
 /**
  * Abstract <code>PagingIterator</code> implementation.
  * 
@@ -50,8 +53,7 @@ public abstract class AbstractIterator<T
     /*
      * (non-Javadoc)
      * 
-     * @see
-     * org.apache.chemistry.opencmis.client.api.util.PagingIterator#getPosition
+     * @see org.apache.chemistry.opencmis.client.api.util.PagingIterator#getPosition
      * ()
      */
     public long getPosition() {
@@ -60,6 +62,21 @@ public abstract class AbstractIterator<T
 
     /*
      * (non-Javadoc)
+     * @see org.apache.chemistry.opencmis.client.api.PagingIterator#getPageNumItems()
+     */
+    public long getPageNumItems() {
+        PageFetchResult<T> page = getCurrentPage();
+        if (page != null) {
+            List<T> items = page.getPage();
+            if (items != null) {
+                return items.size();
+            }
+        }
+        return 0L;
+    }
+    
+    /*
+     * (non-Javadoc)
      * @see org.apache.chemistry.opencmis.client.api.PagingIterator#getTotalNumItems()
      */
     public long getTotalNumItems() {
@@ -95,7 +112,6 @@ public abstract class AbstractIterator<T
 
     /*
      * (non-Javadoc)
-     * 
      * @see java.util.Iterator#remove()
      */
     public void remove() {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java?rev=938158&r1=938157&r2=938158&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionIterable.java
Mon Apr 26 18:00:22 2010
@@ -61,15 +61,6 @@ public class CollectionIterable<T> imple
     /*
      * (non-Javadoc)
      * 
-     * @see org.apache.chemistry.opencmis.client.api.PagingIterable#getIterator()
-     */
-    public PagingIterator<T> getIterator() {
-        return iterator();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
      * @see org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
      */
     public PagingIterable<T> skipTo(long position) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java?rev=938158&r1=938157&r2=938158&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/PageIterable.java
Mon Apr 26 18:00:22 2010
@@ -61,15 +61,6 @@ public class PageIterable<T> implements 
     /*
      * (non-Javadoc)
      * 
-     * @see org.apache.chemistry.opencmis.client.api.PagingIterable#getIterator()
-     */
-    public PagingIterator<T> getIterator() {
-        return iterator();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
      * @see org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
      */
     public PagingIterable<T> skipTo(long position) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java?rev=938158&r1=938157&r2=938158&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/PagingListTest.java
Mon Apr 26 18:00:22 2010
@@ -179,6 +179,23 @@ public class PagingListTest {
         assertEquals(false, i.getHasMoreItems());
     }
 
+    @Test
+    public void totalPageNumItems() {
+        System.out.println("\ntotalPageNumItems");
+        
+        int pageSize = 7;
+        PagingIterable<String> p = this.getIterable(this.data10, pageSize);
+        assertNotNull(p);
+        PagingIterator<String> i = (PagingIterator<String>) p.iterator();
+        assertNotNull(i);
+        assertEquals(pageSize, i.getPageNumItems());
+        for (int idx = 0; i.hasNext() && idx < (pageSize + 1); idx++) {
+            i.next();
+        }
+        assertEquals(pageSize + 1, i.getPosition());
+        assertEquals(this.data10.length - pageSize, i.getPageNumItems());
+    }
+
     private void loopSkip(String[] data, int skipCount, int pageSize) {
         System.out.println("\nloopSkip (" + skipCount + ", " + pageSize + ")");
 



Mime
View raw message