X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.api.acr%2Fsrc%2Forg%2Fargeo%2Fapi%2Facr%2FContentUtils.java;h=5d1f599204860fa20ba1d47ce13286e64d84be26;hb=c615307d7b87bcb260d8a9f402c6e0a880862f38;hp=2036c86229ee3c2749fae93ba1c968f23c1b52ca;hpb=da848d7b6bcf3e509890bdd42c3c59fba1adbe14;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.api.acr/src/org/argeo/api/acr/ContentUtils.java b/org.argeo.api.acr/src/org/argeo/api/acr/ContentUtils.java index 2036c8622..5d1f59920 100644 --- a/org.argeo.api.acr/src/org/argeo/api/acr/ContentUtils.java +++ b/org.argeo.api.acr/src/org/argeo/api/acr/ContentUtils.java @@ -66,12 +66,25 @@ public class ContentUtils { } - public static boolean isString(T t) { - return t instanceof String; +// public static 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() { } + }