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

sherpa.partner.api.client.util.QueryEscaper Maven / Gradle / Ivy

The newest version!
package sherpa.partner.api.client.util;

public final class QueryEscaper {
    private static final String ESCAPABLE_CHARS = "([+-=!()\\{\\}\\[\\]^\\\\\"~*?:\\/]|&&|\\|\\|)";
    private static final String INVALID_CHARS = "([\\<\\>])";

    private QueryEscaper() {

    }

    public static String escape(String query) {
        if (query == null) {
            return null;
        }

        return query.replaceAll(INVALID_CHARS, "").replaceAll(ESCAPABLE_CHARS, "\\\\$1");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy