private static String escapeQuotes(String s)
	{
        if (s == null)
        {
            return null;
        }

		StringBuffer sb = new StringBuffer();
		int length = s.length();
		char prevChar = ' ';
		char prevPrevChar = ' ';
		for(int i = 0; i < length; i++)
		{
			char c = s.charAt(i);
			sb.append(c);
			if(c == '\''
				&& (prevChar != '\\' || (prevChar == '\\' && prevPrevChar == '\\')))
			{
				sb.append("'");
			}
			prevPrevChar = prevChar;
			prevChar = c;
		}
		return sb.toString();
	}