chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r941310 - 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 Wed, 05 May 2010 14:28:36 GMT
Author: dcaruana
Date: Wed May  5 14:28:36 2010
New Revision: 941310

URL: http://svn.apache.org/viewvc?rev=941310&view=rev
Log:
Restore getHasMoreItems() on ItemIterable
- consolidate implementations of Iterable
- rename ItemIterableImpl to CollectionPageIterable and ItemIteratorImpl to CollectionPageIterator
for consistency

Added:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterable.java
  (with props)
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterable.java
  (contents, props changed)
      - copied, changed from r941273, incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterator.java
  (contents, props changed)
      - copied, changed from r941273, incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIteratorImpl.java
Removed:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIteratorImpl.java
Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.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/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.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/ItemIterable.java?rev=941310&r1=941309&r2=941310&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ItemIterable.java
Wed May  5 14:28:36 2010
@@ -69,6 +69,14 @@ public interface ItemIterable<T> extends
     long getPageNumItems();
     
     /**
+     * Returns whether the repository contains additional items beyond the page of
+     * items already fetched.
+     * 
+     * @return true => further page requests will be made to the repository
+     */
+    boolean getHasMoreItems();
+    
+    /**
      * Returns the total number of items. If the repository knows the total
      * number of items in a result set, the repository SHOULD include the number
      * here. If the repository does not know the number of items in a result

Added: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterable.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/AbstractIterable.java?rev=941310&view=auto
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterable.java
(added)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterable.java
Wed May  5 14:28:36 2010
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.client.runtime.util;
+
+import java.util.Iterator;
+
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+
+/**
+ * Abstract <code>ItemIterable</code> implementation.
+ * 
+ * @param <T>
+ */
+public abstract class AbstractIterable<T> implements ItemIterable<T> {
+
+    private AbstractPageFetch<T> pageFetch;
+    private long skipCount;
+    private AbstractIterator<T> iterator;
+
+    /**
+     * Construct
+     * 
+     * @param pageFetch
+     */
+    public AbstractIterable(AbstractPageFetch<T> pageFetch) {
+        this(0, pageFetch);
+    }
+
+    /**
+     * Construct
+     * 
+     * @param position
+     * @param pageFetch
+     */
+    protected AbstractIterable(long position, AbstractPageFetch<T> pageFetch) {
+        this.pageFetch = pageFetch;
+        this.skipCount = position;
+    }
+
+    /**
+     * Gets skip count
+     * @return  skip count
+     */
+    protected long getSkipCount() {
+        return skipCount;
+    }
+    
+    /**
+     * Gets the page fetcher
+     * 
+     * @return  page fetcher
+     */
+    protected AbstractPageFetch<T> getPageFetch() {
+        return pageFetch;
+    }
+    
+    /**
+     * Construct Iterator
+     * 
+     * @return  iterator
+     */
+    protected abstract AbstractIterator<T> createIterator();
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Iterable#iterator()
+     */
+    public Iterator<T> iterator() {
+        return getIterator();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
+     */
+    public ItemIterable<T> skipTo(long position) {
+        return new CollectionIterable<T>(position, pageFetch);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPage()
+     */
+    public ItemIterable<T> getPage() {
+        return new CollectionPageIterable<T>(skipCount, pageFetch);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPage(int)
+     */
+    public ItemIterable<T> getPage(int maxNumItems) {
+        this.pageFetch.setMaxNumItems(maxNumItems);
+        return new CollectionPageIterable<T>(skipCount, pageFetch);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPageNumItems()
+     */
+    public long getPageNumItems() {
+        return getIterator().getPageNumItems();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getHasMoreItems()
+     */
+    public boolean getHasMoreItems() {
+        return getIterator().getHasMoreItems();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getTotalNumItems()
+     */
+    public long getTotalNumItems() {
+        return getIterator().getTotalNumItems();
+    }
+    
+    private AbstractIterator<T> getIterator() {
+        if (this.iterator == null) {
+            this.iterator = createIterator();
+        }
+        return this.iterator;
+    }
+}
+

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/AbstractIterable.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=941310&r1=941309&r2=941310&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
Wed May  5 14:28:36 2010
@@ -25,7 +25,7 @@ import org.apache.chemistry.opencmis.cli
 
 
 /**
- * Abstract <code>ItemIterator</code> implementation.
+ * Abstract <code>Iterator</code> implementation.
  * 
  * @param <T>
  */

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=941310&r1=941309&r2=941310&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
Wed May  5 14:28:36 2010
@@ -18,18 +18,11 @@
  */
 package org.apache.chemistry.opencmis.client.runtime.util;
 
-import java.util.Iterator;
-
-import org.apache.chemistry.opencmis.client.api.ItemIterable;
 
 /**
  * CMIS Collection Iterable
  */
-public class CollectionIterable<T> implements ItemIterable<T> {
-
-    private AbstractPageFetch<T> pageFetch;
-    private long skipCount;
-    private CollectionIterator<T> iterator;
+public class CollectionIterable<T> extends AbstractIterable<T> {
 
     /**
      * Construct
@@ -47,61 +40,11 @@ public class CollectionIterable<T> imple
      * @param pageFetch
      */
     protected CollectionIterable(long position, AbstractPageFetch<T> pageFetch) {
-        this.pageFetch = pageFetch;
-        this.skipCount = position;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Iterable#iterator()
-     */
-    public Iterator<T> iterator() {
-        if (this.iterator == null) {
-            this.iterator = new CollectionIterator<T>(skipCount, pageFetch);
-        }
-        return this.iterator;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
-     */
-    public ItemIterable<T> skipTo(long position) {
-        return new CollectionIterable<T>(position, pageFetch);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPage()
-     */
-    public ItemIterable<T> getPage() {
-        return new ItemIterableImpl<T>(skipCount, pageFetch);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPage(int)
-     */
-    public ItemIterable<T> getPage(int maxNumItems) {
-        this.pageFetch.setMaxNumItems(maxNumItems);
-        return new ItemIterableImpl<T>(skipCount, pageFetch);
-   }
-
-    public long getPageNumItems() {
-        if (this.iterator == null) {
-            this.iterator = new CollectionIterator<T>(skipCount, pageFetch);
-        }
-        return this.iterator.getPageNumItems();
+        super(position, pageFetch);
     }
 
-    public long getTotalNumItems() {
-        if (this.iterator == null) {
-            this.iterator = new CollectionIterator<T>(skipCount, pageFetch);
-        }
-        return this.iterator.getTotalNumItems();
+    @Override
+    protected AbstractIterator<T> createIterator() {
+        return new CollectionIterator<T>(getSkipCount(), getPageFetch());
     }
 }

Copied: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterable.java
(from r941273, incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.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/CollectionPageIterable.java?p2=incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterable.java&p1=incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java&r1=941273&r2=941310&rev=941310&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIterableImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterable.java
Wed May  5 14:28:36 2010
@@ -18,26 +18,18 @@
  */
 package org.apache.chemistry.opencmis.client.runtime.util;
 
-import java.util.Iterator;
-
-import org.apache.chemistry.opencmis.client.api.ItemIterable;
-import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetch.PageFetchResult;
 
 /**
  * Iterable for a CMIS Collection Page
  */
-public class ItemIterableImpl<T> implements ItemIterable<T> {
-
-    private AbstractPageFetch<T> pageFetch;
-    private long skipCount;
-    private ItemIteratorImpl<T> iterator;
+public class CollectionPageIterable<T> extends AbstractIterable<T> {
 
     /**
      * Construct
      * 
      * @param pageFetch
      */
-    public ItemIterableImpl(AbstractPageFetch<T> pageFetch) {
+    public CollectionPageIterable(AbstractPageFetch<T> pageFetch) {
         this(0, pageFetch);
     }
 
@@ -47,63 +39,12 @@ public class ItemIterableImpl<T> impleme
      * @param position
      * @param pageFetch
      */
-    protected ItemIterableImpl(long position, AbstractPageFetch<T> pageFetch) {
-        this.pageFetch = pageFetch;
-        this.skipCount = position;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Iterable#iterator()
-     */
-    public Iterator<T> iterator() {
-        if (this.iterator == null) {
-            this.iterator = new ItemIteratorImpl<T>(skipCount, pageFetch);
-        }
-        return this.iterator;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.chemistry.opencmis.client.api.util.PagingIterable#skipTo(long)
-     */
-    public ItemIterable<T> skipTo(long position) {
-        return new CollectionIterable<T>(position, pageFetch);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPage()
-     */
-    public ItemIterable<T> getPage() {
-        return new ItemIterableImpl<T>(skipCount, pageFetch);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.chemistry.opencmis.client.api.ItemIterable#getPage(int)
-     */
-    public ItemIterable<T> getPage(int maxNumItems) {
-        this.pageFetch.setMaxNumItems(maxNumItems);
-        return new ItemIterableImpl<T>(skipCount, pageFetch);
-    }
-
-    public long getPageNumItems() {
-        if (this.iterator == null) {
-            this.iterator = new ItemIteratorImpl<T>(skipCount, pageFetch);
-        }
-        return this.iterator.getPageNumItems();
+    protected CollectionPageIterable(long position, AbstractPageFetch<T> pageFetch)
{
+        super(position, pageFetch);
     }
 
-    public long getTotalNumItems() {
-        if (this.iterator == null) {
-            this.iterator = new ItemIteratorImpl<T>(skipCount, pageFetch);
-        }
-        return this.iterator.getTotalNumItems();
+    @Override
+    protected AbstractIterator<T> createIterator() {
+        return new CollectionPageIterator<T>(getSkipCount(), getPageFetch());
     }
 }

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterator.java
(from r941273, incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIteratorImpl.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/CollectionPageIterator.java?p2=incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterator.java&p1=incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIteratorImpl.java&r1=941273&r2=941310&rev=941310&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/ItemIteratorImpl.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterator.java
Wed May  5 14:28:36 2010
@@ -27,7 +27,7 @@ import org.apache.chemistry.opencmis.cli
  * 
  * @param <T>
  */
-public class ItemIteratorImpl<T> extends AbstractIterator<T> {
+public class CollectionPageIterator<T> extends AbstractIterator<T> {
 
     /**
      * Construct
@@ -35,7 +35,7 @@ public class ItemIteratorImpl<T> extends
      * @param skipCount
      * @param pageFetch
      */
-    public ItemIteratorImpl(long skipCount, AbstractPageFetch<T> pageFetch) {
+    public CollectionPageIterator(long skipCount, AbstractPageFetch<T> pageFetch) {
         super(skipCount, pageFetch);
     }
 

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/util/CollectionPageIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.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/ItemIterableTest.java?rev=941310&r1=941309&r2=941310&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/ItemIterableTest.java
Wed May  5 14:28:36 2010
@@ -198,9 +198,11 @@ public class ItemIterableTest {
         assertNotNull(p);
         Iterator<String> i = p.iterator();
         assertNotNull(i);
+        assertEquals(true, p.getHasMoreItems());
         for (int idx = 0; i.hasNext() && idx < (pageSize + 1); idx++) {
-            assertNotNull(i.next());
+            i.next();
         }
+        assertEquals(false, p.getHasMoreItems());
     }
 
     @Test



Mime
View raw message