18 package org.turro.elephant.db;
20 import java.util.Collection;
21 import org.turro.string.Strings;
34 if(value ==
null)
return null;
35 return value.replaceAll(
"\\*",
"%").replaceAll(
"\\?",
"_");
39 if(value ==
null)
return null;
40 return "%" + value.replaceAll(
"\\*",
"%").replaceAll(
"\\?",
"_") +
"%";
45 for(Object o : collection) {
46 if(o instanceof String) {
47 result = (result ==
null) ? (
"'" + o +
"'") : (result +
",'" + o +
"'");
49 result = (String) ((result ==
null) ? o +
"" : (result +
"," + o));
56 String[] tokens = inValue.split(
",");
58 for(String s : tokens) {
59 result = (result ==
null) ? (
"'" + s +
"'") : (result +
",'" + s +
"'");
71 if(value.startsWith(
"=")) {
73 value = value.substring(1);
75 }
else if(value.startsWith(
"?")) {
114 String result =
"", partial, param;
116 for(
int f = 0; f < fields.length; f++) {
118 for(
int v = 0; v < values.length; v++) {
119 if(!Strings.isBlank(values[v])) {
120 if(partial.length() > 0) {
125 partial +=
"UCASE(" + fields[f] +
") like :" + param;
126 if(
"%".equals(values[v])) {
129 wc.
addNamedValue(param,
"%" + values[v].toUpperCase() +
"%");
132 partial +=
"UCASE(" + fields[f] +
") like ?";
133 if(
"%".equals(values[v])) {
136 wc.
addValue(
"%" + values[v].toUpperCase() +
"%");
142 if(partial.length() > 0) {
143 if(result.length() > 0) {
146 result +=
"(" + partial +
")";
150 if(result.length() > 0) {
151 result = wc.
getPrefix() +
" (" + result +
") ";
static WhereClause getWhereClause(WhereClause wc, String[] fields, String value)
static WhereClause getWhereClause(String[] fields, String[] values, boolean namedValues)
static WhereClause getWhereClause(WhereClause wc, String[] fields, String[] values)
static WhereClause getWhereClause(WhereClause wc, String[] fields, String value, String regexp)
static WhereClause getWhereClause(String[] fields, String value, String regexp)
static String quoteTokensForIn(String inValue)
static WhereClause getWhereClause(String[] fields, String value)
static WhereClause getWhereClause(String[] fields, String[] values)
static WhereClause getWhereClause(WhereClause wc, String[] fields, String[] values, boolean namedValues)
static String convertToIn(Collection collection)
static String convertToPartialLike(String value)
static String convertToLike(String value)
void addValue(Object value)
void addClause(String clause)
void addNamedValue(String name, Object value)
String getFieldOcurrence()