@Test public void simplifyForUrl() { assertEquals("changes-for-1-0-x-code-name-wheatley-xl", Util.simplifyForUrl("Changes For 1.0.x: Code Name \"Wheatley\" (XL)")); }
public static String simplifyForUrl(String text) { PagePathValidator validator = new PagePathValidator(); StringBuilder buf = new StringBuilder(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (StringUtils.contains(CHARS_TO_DASH, c)) { buf.append("-"); } else { buf.append(c); if (!validator.isValid(buf.toString(), null)) { buf.deleteCharAt(buf.length() - 1); } } } String name = buf.toString() .replaceAll("--", "-") .replaceAll("^-", StringUtils.EMPTY) .replaceAll("-$", StringUtils.EMPTY) .toLowerCase(); return name; }
Util { public static String simplifyForUrl(String text) { PagePathValidator validator = new PagePathValidator(); StringBuilder buf = new StringBuilder(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (StringUtils.contains(CHARS_TO_DASH, c)) { buf.append("-"); } else { buf.append(c); if (!validator.isValid(buf.toString(), null)) { buf.deleteCharAt(buf.length() - 1); } } } String name = buf.toString() .replaceAll("--", "-") .replaceAll("^-", StringUtils.EMPTY) .replaceAll("-$", StringUtils.EMPTY) .toLowerCase(); return name; } }
Util { public static String simplifyForUrl(String text) { PagePathValidator validator = new PagePathValidator(); StringBuilder buf = new StringBuilder(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (StringUtils.contains(CHARS_TO_DASH, c)) { buf.append("-"); } else { buf.append(c); if (!validator.isValid(buf.toString(), null)) { buf.deleteCharAt(buf.length() - 1); } } } String name = buf.toString() .replaceAll("--", "-") .replaceAll("^-", StringUtils.EMPTY) .replaceAll("-$", StringUtils.EMPTY) .toLowerCase(); return name; } private  Util(); }
Util { public static String simplifyForUrl(String text) { PagePathValidator validator = new PagePathValidator(); StringBuilder buf = new StringBuilder(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (StringUtils.contains(CHARS_TO_DASH, c)) { buf.append("-"); } else { buf.append(c); if (!validator.isValid(buf.toString(), null)) { buf.deleteCharAt(buf.length() - 1); } } } String name = buf.toString() .replaceAll("--", "-") .replaceAll("^-", StringUtils.EMPTY) .replaceAll("-$", StringUtils.EMPTY) .toLowerCase(); return name; } private  Util(); static String toRealPagePath(String pagePath); static String toUrlPagePath(String pagePath); static String simplifyForUrl(String text); static String join(Object o, String delimiter); static void deleteQuietly(File f); static RuntimeException toRuntimeException(Throwable t); static File toFile(File baseDir, String path); static void closeQuietly(Closeable c); static Map<String, String> parseParameters(String params); static String serialize(Serializable s); static T deserialize(String s, Class<T> clazz); }
Util { public static String simplifyForUrl(String text) { PagePathValidator validator = new PagePathValidator(); StringBuilder buf = new StringBuilder(); int len = text.length(); for (int i = 0; i < len; i++) { char c = text.charAt(i); if (StringUtils.contains(CHARS_TO_DASH, c)) { buf.append("-"); } else { buf.append(c); if (!validator.isValid(buf.toString(), null)) { buf.deleteCharAt(buf.length() - 1); } } } String name = buf.toString() .replaceAll("--", "-") .replaceAll("^-", StringUtils.EMPTY) .replaceAll("-$", StringUtils.EMPTY) .toLowerCase(); return name; } private  Util(); static String toRealPagePath(String pagePath); static String toUrlPagePath(String pagePath); static String simplifyForUrl(String text); static String join(Object o, String delimiter); static void deleteQuietly(File f); static RuntimeException toRuntimeException(Throwable t); static File toFile(File baseDir, String path); static void closeQuietly(Closeable c); static Map<String, String> parseParameters(String params); static String serialize(Serializable s); static T deserialize(String s, Class<T> clazz);  }