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

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

The newest version!
package grails.doc.internal;

import java.net.URI;
import java.net.URISyntaxException;

import org.apache.commons.lang.StringEscapeUtils;

public class StringEscapeCategory {
    private 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