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

uk.co.stuffusell.api.client.util.QueryEscaper Maven / Gradle / Ivy

There is a newer version: 1.0.13
Show newest version
package uk.co.stuffusell.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