class StringUtils {

	public static String quoteMetacharacters(String str) {
		if (str == null) {
			return null;
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			if (UNSAFE_CHARS.contains(c)) {
				sb.append(ESCAPE_CHAR);
			}
			sb.append(c);
		}

		return sb.toString();
	}

}