This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag 
org.apache.sling.fsresource-0.9.2-incubator
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git

commit a46c2848a1cbc093016680ae6ec628594aa2cf6f
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Aug 1 12:16:39 2008 +0000

    Remove redundant null check
    
    git-svn-id: 
https://svn.apache.org/repos/asf/incubator/sling/trunk/samples/fsresource@681668
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/fsprovider/FsResourceProvider.java       | 71 +++++++++++-----------
 1 file changed, 34 insertions(+), 37 deletions(-)

diff --git a/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java 
b/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
index 63c26ea..63d2948 100644
--- a/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
+++ b/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
@@ -44,7 +44,7 @@ import org.osgi.service.component.ComponentContext;
  * resource tree where resources are provided ({@link ResourceProvider#ROOTS})
  * and the file system path from where files and folders are mapped into the
  * resource ({@link #PROP_PROVIDER_FILE}).
- * 
+ *
  * @scr.component label="%resource.resolver.name"
  *                description="%resource.resolver.description"
  *                
factory="org.apache.sling.fsprovider.FsResourceProviderFactory"
@@ -76,7 +76,7 @@ public class FsResourceProvider implements ResourceProvider {
     /**
      * Same as {@link #getResource(ResourceResolver, String)}, i.e. the
      * <code>request</code> parameter is ignored.
-     * 
+     *
      * @see #getResource(ResourceResolver, String)
      */
     public Resource getResource(ResourceResolver resourceResolver,
@@ -133,51 +133,48 @@ public class FsResourceProvider implements 
ResourceProvider {
             }
         }
 
-        if (parentFile != null) {
+        final File[] children = parentFile.listFiles();
 
-            final File[] children = parentFile.listFiles();
+        if (children != null && children.length > 0) {
+            final ResourceResolver resolver = parent.getResourceResolver();
+            final String parentPath = parent.getPath();
+            return new Iterator<Resource>() {
+                int index = 0;
 
-            if (children != null && children.length > 0) {
-                final ResourceResolver resolver = parent.getResourceResolver();
-                final String parentPath = parent.getPath();
-                return new Iterator<Resource>() {
-                    int index = 0;
+                Resource next = seek();
 
-                    Resource next = seek();
+                public boolean hasNext() {
+                    return next != null;
+                }
 
-                    public boolean hasNext() {
-                        return next != null;
+                public Resource next() {
+                    if (!hasNext()) {
+                        throw new NoSuchElementException();
                     }
 
-                    public Resource next() {
-                        if (!hasNext()) {
-                            throw new NoSuchElementException();
-                        }
-
-                        Resource result = next;
-                        next = seek();
-                        return result;
-                    }
+                    Resource result = next;
+                    next = seek();
+                    return result;
+                }
 
-                    public void remove() {
-                        throw new UnsupportedOperationException("remove");
-                    }
+                public void remove() {
+                    throw new UnsupportedOperationException("remove");
+                }
 
-                    private Resource seek() {
-                        while (index < children.length) {
-                            File file = children[index++];
-                            String path = parentPath + "/" + file.getName();
-                            Resource result = getResource(resolver, path, 
file);
-                            if (result != null) {
-                                return result;
-                            }
+                private Resource seek() {
+                    while (index < children.length) {
+                        File file = children[index++];
+                        String path = parentPath + "/" + file.getName();
+                        Resource result = getResource(resolver, path, file);
+                        if (result != null) {
+                            return result;
                         }
-
-                        // nothing found any more
-                        return null;
                     }
-                };
-            }
+
+                    // nothing found any more
+                    return null;
+                }
+            };
         }
 
         // no children

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to