X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2FContentUtils.java;h=facb5933bf3ebe743ce99eeed8e57c300d0cb11b;hb=8afcdd215960582369e8f7d1d1f47b42d80b3fa6;hp=2e101a0d6f51b825c7d2a1bf9f19f713deb33107;hpb=b6de3c9320472e5da1414f11fe4556942c09a97d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/acr/ContentUtils.java b/org.argeo.cms/src/org/argeo/cms/acr/ContentUtils.java index 2e101a0d6..facb5933b 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/ContentUtils.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/ContentUtils.java @@ -128,6 +128,16 @@ public class ContentUtils { throw new IllegalArgumentException("Path " + path + " contains //"); } + /** The last element of a path. */ + public static String lastPathElement(String path) { + if (path.charAt(path.length() - 1) == '/') + throw new IllegalArgumentException("Path " + path + " cannot end with '/'"); + int index = path.lastIndexOf('/'); + if (index < 0) + return path; + return path.substring(index + 1); + } + /* * DIRECTORY */