incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r652801 - /incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Date Fri, 02 May 2008 16:29:05 GMT
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.
      *



Mime
View raw message