Author: cziegeler
Date: Fri Aug 1 05:16:39 2008
New Revision: 681668
URL: http://svn.apache.org/viewvc?rev=681668&view=rev
Log:
Remove redundant null check
Modified:
incubator/sling/trunk/samples/fsresource/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
Modified:
incubator/sling/trunk/samples/fsresource/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/samples/fsresource/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java?rev=681668&r1=681667&r2=681668&view=diff
==============================================================================
---
incubator/sling/trunk/samples/fsresource/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
(original)
+++
incubator/sling/trunk/samples/fsresource/src/main/java/org/apache/sling/fsprovider/FsResourceProvider.java
Fri Aug 1 05:16:39 2008
@@ -44,7 +44,7 @@
* resource tree where resources are provided ([EMAIL PROTECTED]
ResourceProvider#ROOTS})
* and the file system path from where files and folders are mapped into the
* resource ([EMAIL PROTECTED] #PROP_PROVIDER_FILE}).
- *
+ *
* @scr.component label="%resource.resolver.name"
* description="%resource.resolver.description"
*
factory="org.apache.sling.fsprovider.FsResourceProviderFactory"
@@ -76,7 +76,7 @@
/**
* Same as [EMAIL PROTECTED] #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 @@
}
}
- 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