All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grails.doc.internal.StringEscapeCategory Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy