001package com.identityworksllc.iiq.common;
002
003import org.apache.commons.lang.StringEscapeUtils;
004
005import java.io.UnsupportedEncodingException;
006import java.net.URLEncoder;
007
008/**
009 * Velocity has its own 'escape tools' package, but it is not included with
010 * Sailpoint. We will make our own.
011 */
012public class VelocityEscapeTools {
013    /**
014     * @see StringEscapeUtils#escapeCsv(String)
015     */
016    public String csv(String input) {
017        return StringEscapeUtils.escapeCsv(input);
018    }
019
020    /**
021     * @see StringEscapeUtils#escapeHtml(String)
022     */
023    public String html(String input) {
024        return StringEscapeUtils.escapeHtml(input);
025    }
026
027    /**
028     * @see StringEscapeUtils#escapeJava(String)
029     */
030    public String java(String input) {
031        return StringEscapeUtils.escapeJava(input);
032    }
033
034    /**
035     * @see StringEscapeUtils#escapeSql(String) 
036     */
037    public String sql(String input) {
038        return StringEscapeUtils.escapeSql(input);
039    }
040
041    /**
042     * @see URLEncoder#encode(String, String) 
043     */
044    public String url(String input) throws UnsupportedEncodingException {
045        return URLEncoder.encode(input, "UTF-8");
046    }
047
048    /**
049     * @see StringEscapeUtils#escapeXml(String)
050     */
051    public String xml(String input) {
052        return StringEscapeUtils.escapeXml(input);
053    }
054
055}