You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:00:12 UTC

[sling-org-apache-sling-resourceresolver] 42/47: SLING-2641 : Make listChildren() Iterable

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

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

commit 7fcd9e33eef475ae040ffda29641a7be34ced250
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Nov 7 19:32:47 2012 +0000

    SLING-2641 :  Make listChildren() Iterable
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/resourceresolver@1406767 13f79535-47bb-0310-9956-ffa450edef68
---
 .../resourceresolver/impl/ResourceResolverImpl.java   | 12 ++++++++++++
 .../impl/tree/ResourceProviderEntryTest.java          | 19 ++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
index 9eddf6b..02293b7 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
@@ -618,6 +618,18 @@ public class ResourceResolverImpl extends SlingAdaptable implements ResourceReso
                 new ResourceIterator(this.context, parent, this.factory.getRootProviderEntry()));
     }
 
+    /**
+     * @see org.apache.sling.api.resource.Resource#getChildren()
+     */
+    public Iterable<Resource> getChildren(final Resource parent) {
+        return new Iterable<Resource>() {
+
+            public Iterator<Resource> iterator() {
+                return listChildren(parent);
+            }
+        };
+    }
+
     // ---------- Querying resources
 
     private static final String DEFAULT_QUERY_LANGUAGE = "xpath";
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java
index 9c01b2a..0b60d20 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderEntryTest.java
@@ -181,33 +181,33 @@ public class ResourceProviderEntryTest {
         assertEquals(first, root.getResource(null, null, "/rootel/html.js"));
         assertEquals(second, root.getResource(null, null, "/rootel/child/html.js"));
     }
-    
+
     @Test public void testRemoveTheOnlyProvider() {
         final ResourceProviderEntry e = new ResourceProviderEntry("/", null);
         long counter = 1;
-        
+
         for(String path : new String[] { "/foo", "/", "/foo/bar" }) {
             final ResourceProvider p = new TestResourceProvider(path);
             final Map<String, Object> props = new HashMap<String, Object>();
             props.put(Constants.SERVICE_ID, ++counter);
-            
+
             e.addResourceProvider(path, new ResourceProviderHandler(p, props));
             {
-                final Resource r = e.getResource(null, null, path); 
+                final Resource r = e.getResource(null, null, path);
                 assertEquals(p, r);
                 assertFalse(r instanceof SyntheticResource);
             }
-            
+
             e.removeResourceProvider(path, new ResourceProviderHandler(p, props));
             {
-                final Resource r = e.getResource(null, null, path); 
+                final Resource r = e.getResource(null, null, path);
                 // If our provider is indeed gone, we should get one of the following conditions
                 if(r == null) {
                     //fine
                 } else if(!p.equals(r.getResourceResolver())) {
                     //fine
                 } else {
-                    fail("Expecting inactive provider after removing it for " + path); 
+                    fail("Expecting inactive provider after removing it for " + path);
                 }
             }
         }
@@ -257,6 +257,10 @@ public class ResourceProviderEntryTest {
             return null;
         }
 
+        public Iterable<Resource> getChildren(Resource parent) {
+            return null;
+        }
+
         // just dummy implementation to mark our resources for the tests
         public Iterator<Resource> findResources(String query, String language) {
             return null;
@@ -388,6 +392,7 @@ public class ResourceProviderEntryTest {
             return null;
         }
 
+        @Override
         public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
             return null;
         }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.