@Test public void testParent() { assertEquals("/", PathNormalizer.parent("/p", '/')); assertEquals("/p", PathNormalizer.parent("/p/n", '/')); assertNull(PathNormalizer.parent("/", '/')); }
public static String parent(final String absolute, final char delimiter) { if(String.valueOf(delimiter).equals(absolute)) { return null; } int index = absolute.length() - 1; if(absolute.charAt(index) == delimiter) { if(index > 0) { index--; } } int cut = absolute.lastIndexOf(delimiter, index); if(cut > 0) { return UNICODE_NORMALIZER.normalize(absolute.substring(0, cut)).toString(); } return String.valueOf(delimiter); }
PathNormalizer { public static String parent(final String absolute, final char delimiter) { if(String.valueOf(delimiter).equals(absolute)) { return null; } int index = absolute.length() - 1; if(absolute.charAt(index) == delimiter) { if(index > 0) { index--; } } int cut = absolute.lastIndexOf(delimiter, index); if(cut > 0) { return UNICODE_NORMALIZER.normalize(absolute.substring(0, cut)).toString(); } return String.valueOf(delimiter); } }
PathNormalizer { public static String parent(final String absolute, final char delimiter) { if(String.valueOf(delimiter).equals(absolute)) { return null; } int index = absolute.length() - 1; if(absolute.charAt(index) == delimiter) { if(index > 0) { index--; } } int cut = absolute.lastIndexOf(delimiter, index); if(cut > 0) { return UNICODE_NORMALIZER.normalize(absolute.substring(0, cut)).toString(); } return String.valueOf(delimiter); } private  PathNormalizer(); }
PathNormalizer { public static String parent(final String absolute, final char delimiter) { if(String.valueOf(delimiter).equals(absolute)) { return null; } int index = absolute.length() - 1; if(absolute.charAt(index) == delimiter) { if(index > 0) { index--; } } int cut = absolute.lastIndexOf(delimiter, index); if(cut > 0) { return UNICODE_NORMALIZER.normalize(absolute.substring(0, cut)).toString(); } return String.valueOf(delimiter); } private  PathNormalizer(); static String name(final String path); static String parent(final String absolute, final char delimiter); static String normalize(final String path); static String normalize(final String path, final boolean absolute); static List<Path> normalize(final List<Path> selected); }
PathNormalizer { public static String parent(final String absolute, final char delimiter) { if(String.valueOf(delimiter).equals(absolute)) { return null; } int index = absolute.length() - 1; if(absolute.charAt(index) == delimiter) { if(index > 0) { index--; } } int cut = absolute.lastIndexOf(delimiter, index); if(cut > 0) { return UNICODE_NORMALIZER.normalize(absolute.substring(0, cut)).toString(); } return String.valueOf(delimiter); } private  PathNormalizer(); static String name(final String path); static String parent(final String absolute, final char delimiter); static String normalize(final String path); static String normalize(final String path, final boolean absolute); static List<Path> normalize(final List<Path> selected);  }