Definition at line 11 of file DBUtil.java.
Static Public Member Functions | |
| final String | quote (final Object o) |
| final String | asSQLSet (Object[] list) |
| final String | asSQLSet (Collection list) |
|
|
Converted the provided array to the quote-enclosed, comma-separate format required by mysql set or enum commands.
Definition at line 59 of file DBUtil.java.
00060 {
00061 StringBuffer buf = new StringBuffer();
00062 for (Iterator it = list.iterator(); it.hasNext();)
00063 buf.append("'" + it.next() + "'" + (it.hasNext() ? "," : ""));
00064 return buf.toString();
00065 }
|
|
|
Converted the provided array to the quote-enclosed, comma-separate format required by mysql set or enum commands. Definition at line 44 of file DBUtil.java.
00045 {
00046 int l = list.length;
00047 StringBuffer buf = new StringBuffer();
00048 for (int i = 0; i < l; i++)
00049 buf.append("'" + list[i] + "'" + (i < l - 1 ? "," : ""));
00050 return buf.toString();
00051 }
|
|
|
Quote string according to MySQL conventions, to block one easy attack Definition at line 18 of file DBUtil.java.
00019 {
00020 if (o == null)
00021 return "\"null\"";
00022 final String s = o.toString();
00023 int n = 0;
00024 for (int i = 0; i < s.length(); i++)
00025 if (s.charAt(i) == '"')
00026 n++;
00027 if (n == 0)
00028 return "\"" + s + "\"";
00029
00030 StringBuffer buf = new StringBuffer(s.length() + n);
00031 for (int i = 0; i < s.length(); i++)
00032 {
00033 if (s.charAt(i) == '"')
00034 buf.append("\\\"");
00035 else
00036 buf.append(s.charAt(i));
00037 }
00038 return buf.toString();
00039 }
|