You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2008/05/02 18:29:05 UTC

svn commit: r652801 - /incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java

Author: cziegeler
Date: Fri May  2 09:29:05 2008
New Revision: 652801

URL: http://svn.apache.org/viewvc?rev=652801&view=rev
Log:
SLING-410: Add more utility methods.

Modified:
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=652801&r1=652800&r2=652801&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java Fri May  2 09:29:05 2008
@@ -141,6 +141,28 @@
     }
 
     /**
+     * Utility method returns the parent resource of the resource.
+     * @throws NullPointerException If <code>rsrc</code> is <code>null</code>.
+     * @return The parent resource or null if the rsrc is the root.
+     */
+    public static Resource getParent(Resource rsrc) {
+        final String parentPath = getParent(rsrc.getPath());
+        if ( parentPath == null ) {
+            return null;
+        }
+        return rsrc.getResourceResolver().resolve(parentPath);
+    }
+
+    /**
+     * Utility method returns the parent resource of the resource.
+     * @throws NullPointerException If <code>rsrc</code> is <code>null</code>.
+     */
+    public static String getName(Resource rsrc) {
+        final String name = getName(rsrc.getPath());
+        return name;
+    }
+
+    /**
      * Utility method returns the name of the given <code>path</code>, which
      * is normalized by {@link #normalize(String)} before resolving the name.
      *