FileDocCategorySizeDatePackage
SQLFilter.javaAPI DocAndroid 1.5 API1522Wed May 06 22:41:06 BST 2009org.bouncycastle.i18n.filter

SQLFilter

public class SQLFilter extends Object implements Filter
Filter for strings to store in a SQL table. escapes ' " = - / \ ; \r \n

Fields Summary
Constructors Summary
Methods Summary
public java.lang.StringdoFilter(java.lang.String input)

        StringBuffer buf = new StringBuffer(input);
        int i = 0;
        while (i < buf.length()) 
        {
            char ch = buf.charAt(i);
            switch (ch) 
            {
            case '\'":
                buf.replace(i,i+1,"\\\'");
                i += 1;
                break;
            case '\"":
                buf.replace(i,i+1,"\\\"");
                i += 1;
                break;
            case '=":
                buf.replace(i,i+1,"\\=");
                i += 1;
                break;
            case '-":
                buf.replace(i,i+1,"\\-");
                i += 1;
                break;
            case '/":
                buf.replace(i,i+1,"\\/");
                i += 1;
                break;
            case '\\":
                buf.replace(i,i+1,"\\\\");
                i += 1;
                break;
            case ';":
                buf.replace(i,i+1,"\\;");
                i += 1;
                break;
            case '\r":
                buf.replace(i,i+1,"\\r");
                i += 1;
                break;
            case '\n":
                buf.replace(i,i+1,"\\n");
                i += 1;
                break;
            default:
            }
            i++;
        }
        return buf.toString();