JCR as an ACR backend
[lgpl/argeo-commons.git] / org.argeo.api.acr / src / org / argeo / api / acr / ContentUtils.java
index 2036c86229ee3c2749fae93ba1c968f23c1b52ca..5d1f599204860fa20ba1d47ce13286e64d84be26 100644 (file)
@@ -66,12 +66,25 @@ public class ContentUtils {
 
        }
 
-       public static <T> boolean isString(T t) {
-               return t instanceof String;
+//     public static <T> boolean isString(T t) {
+//             return t instanceof String;
+//     }
+
+       /**
+        * Split a path (with '/' separator) in an array of length 2, the first part
+        * being the parent path (which could be either absolute or relative), the
+        * second one being the last segment, (guaranteed to be with '/').
+        */
+       public static String[] getParentPath(String path) {
+               int parentIndex = path.lastIndexOf('/');
+               // TODO make it more robust
+               return new String[] { parentIndex != 0 ? path.substring(0, parentIndex) : "/",
+                               path.substring(parentIndex + 1) };
        }
 
        /** Singleton. */
        private ContentUtils() {
 
        }
+
 }