grails.doc.internal.StringEscapeCategory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grails-docs Show documentation
Show all versions of grails-docs Show documentation
Grails Web Application Framework
package grails.doc.internal;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.lang.StringEscapeUtils;
public class StringEscapeCategory {
public static String encodeAsUrlPath(String str) {
try {
String uri = new URI("http", "localhost", '/' + str, "").toASCIIString();
return uri.substring(17, uri.length() - 1);
}
catch (URISyntaxException ex) {
throw new RuntimeException(ex);
}
}
public static String encodeAsUrlFragment(String str) {
try {
String uri = new URI("http", "localhost", "/", str).toASCIIString();
return uri.substring(18, uri.length());
}
catch (URISyntaxException ex) {
throw new RuntimeException(ex);
}
}
public static String encodeAsHtml(String str) {
return StringEscapeUtils.escapeHtml(str);
}
}