You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2007/11/22 09:58:53 UTC

svn commit: r597341 - /incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIterator.java

Author: fmeschbe
Date: Thu Nov 22 00:58:53 2007
New Revision: 597341

URL: http://svn.apache.org/viewvc?rev=597341&view=rev
Log:
JavaDoc and logging

Modified:
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIterator.java

Modified: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIterator.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIterator.java?rev=597341&r1=597340&r2=597341&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIterator.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIterator.java Thu Nov 22 00:58:53 2007
@@ -22,20 +22,37 @@
 import java.util.NoSuchElementException;
 
 import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.jcr.resource.internal.JcrResourceManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+/**
+ * The <code>JcrNodeResourceIterator</code> class is a resource iterator,
+ * which returns resources for each node of an underlying
+ * <code>NodeIterator</code>. Nodes in the node iterator which cannot be
+ * accessed or for which a resource cannot be created are skipped.
+ */
 public class JcrNodeResourceIterator implements Iterator<Resource> {
 
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    /** resource manager used to create resources from nodes */
     private JcrResourceManager resourceManager;
+
+    /** underlying node iterator to be used for resources */
     private NodeIterator nodes;
 
-    private Resource nextResult = seek();
+    /** The prefetched next iterator entry, null at the end of iterating */
+    private Resource nextResult;
 
-    public JcrNodeResourceIterator(JcrResourceManager resourceManager, NodeIterator nodes) {
+    /**
+     * Creates an instance using the given resource manager and the nodes
+     * provided as a node iterator.
+     */
+    public JcrNodeResourceIterator(JcrResourceManager resourceManager,
+            NodeIterator nodes) {
         this.resourceManager = resourceManager;
         this.nodes = nodes;
         this.nextResult = seek();
@@ -55,6 +72,10 @@
         return result;
     }
 
+    /**
+     * Throws <code>UnsupportedOperationException</code> as this method is not
+     * supported by this implementation.
+     */
     public void remove() {
         throw new UnsupportedOperationException();
     }
@@ -63,17 +84,15 @@
         while (nodes.hasNext()) {
             try {
                 return new JcrNodeResource(resourceManager, nodes.nextNode());
-            } catch (RepositoryException re) {
-                // TODO: log this situation and continue mapping
-            } catch (ObjectContentManagerException ocme) {
-                // TODO: log this situation and continue mapping
             } catch (Throwable t) {
-                // TODO: log this situation and continue mapping
+                log.error(
+                    "seek: Problem creating Resource for next node, skipping",
+                    t);
             }
         }
 
         // no more results
+        log.debug("seek: No more nodes, iterator exhausted");
         return null;
     }
-
 }