|
| WhereClause () |
|
| WhereClause (String prefix) |
|
Map< String, Object > | getAttributes () |
|
void | addClause (String clause) |
|
void | addClauseIfNotExists (String clause) |
|
void | addInRange (String operator, String startField, String endField, String attribute, Date date) |
|
void | addValue (Object value) |
|
void | addNamedValue (String name, Object value) |
|
void | addLikeFields (String[] fields, String value) |
|
Map< String, Object > | getNamedValues () |
|
List< Object > | getNamedValues (String ... name) |
|
int | getValueCount () |
|
Object | getValue (int index) |
|
String | getClause () |
|
void | setClause (String clause) |
|
void | setOrderByClause (String orderByClause) |
|
void | setGroupByClause (String groupByClause) |
|
boolean | isUseNative () |
|
void | setUseNative (boolean useNative) |
|
Class | getResultClass () |
|
void | setResultClass (Class resultClass) |
|
int | getUniqueSuffix () |
|
Object[] | getValues () |
|
void | setParameters (Query q, int start) |
|
void | setNamedParameters (Query q) |
|
String | getFieldOcurrence () |
|
void | setFieldOcurrence (String fieldOcurrence) |
|
String | getPrefix () |
|
void | setPrefix (String prefix) |
|
void | addNotIn (String operator, String field, List values) |
|
void | addIn (String operator, String field, List values) |
|
String | getUniqueVariable (String prefix) |
|
- Author
- Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g
Definition at line 32 of file WhereClause.java.
◆ WhereClause() [1/2]
org.turro.elephant.db.WhereClause.WhereClause |
( |
| ) |
|
◆ WhereClause() [2/2]
org.turro.elephant.db.WhereClause.WhereClause |
( |
String |
prefix | ) |
|
◆ addClause()
void org.turro.elephant.db.WhereClause.addClause |
( |
String |
clause | ) |
|
◆ addClauseIfNotExists()
void org.turro.elephant.db.WhereClause.addClauseIfNotExists |
( |
String |
clause | ) |
|
Definition at line 60 of file WhereClause.java.
61 if(this.clause ==
null || !this.clause.contains(clause)) {
62 this.clause +=
" " + clause;
◆ addIn()
void org.turro.elephant.db.WhereClause.addIn |
( |
String |
operator, |
|
|
String |
field, |
|
|
List |
values |
|
) |
| |
Definition at line 204 of file WhereClause.java.
205 if(values ==
null || values.isEmpty()) {
206 addClause((
operator !=
null ?
operator +
" 1=2" :
"1=2"));
208 int listSize = values.size();
209 if(listSize <= IN_LIMIT) {
211 addClause((
operator !=
null ?
operator +
" " :
"") + field +
" in (:"+ var +
")");
214 addClause((
operator !=
null ?
operator +
" (" :
"("));
216 for (
int i = 0; i < listSize; i += IN_LIMIT) {
218 List subList = (listSize > i + IN_LIMIT) ?
219 values.subList(i, (i + IN_LIMIT)) :
220 values.subList(i, listSize);
221 addClause(sep + field +
" in (:" + var +
")");
String getUniqueVariable(String prefix)
void addClause(String clause)
void addNamedValue(String name, Object value)
◆ addInRange()
void org.turro.elephant.db.WhereClause.addInRange |
( |
String |
operator, |
|
|
String |
startField, |
|
|
String |
endField, |
|
|
String |
attribute, |
|
|
Date |
date |
|
) |
| |
Definition at line 66 of file WhereClause.java.
68 addClause(
"(" + startField +
" is null or " + startField +
" >= :" + attribute +
")");
69 addClause(
"and (" + endField +
" is null or " + endField +
" <= :" + attribute +
")");
◆ addLikeFields()
void org.turro.elephant.db.WhereClause.addLikeFields |
( |
String[] |
fields, |
|
|
String |
value |
|
) |
| |
Definition at line 82 of file WhereClause.java.
83 if(value ==
null)
return;
84 if(value.startsWith(
"=") || value.startsWith(
"?")) {
85 SQLHelper.getWhereClause(
this, fields, value);
86 }
else if(value.startsWith(
"\"") && value.endsWith(
"\"")) {
87 value = value.substring(1, value.length() - 1);
88 SQLHelper.getWhereClause(
this, fields,
89 (value ==
null ?
"" : value.replaceAll(
"\\*",
"%").replaceAll(
"\\?",
"_")),
null);
91 SQLHelper.getWhereClause(
this, fields,
92 (value ==
null ?
"" : value.replaceAll(
"\\*",
"%").replaceAll(
"\\?",
"_")),
" +");
◆ addNamedValue()
void org.turro.elephant.db.WhereClause.addNamedValue |
( |
String |
name, |
|
|
Object |
value |
|
) |
| |
◆ addNotIn()
void org.turro.elephant.db.WhereClause.addNotIn |
( |
String |
operator, |
|
|
String |
field, |
|
|
List |
values |
|
) |
| |
Definition at line 200 of file WhereClause.java.
201 addIn(
operator, field +
" not", values);
void addIn(String operator, String field, List values)
◆ addValue()
void org.turro.elephant.db.WhereClause.addValue |
( |
Object |
value | ) |
|
◆ getAttributes()
Map<String, Object> org.turro.elephant.db.WhereClause.getAttributes |
( |
| ) |
|
◆ getClause()
String org.turro.elephant.db.WhereClause.getClause |
( |
| ) |
|
Definition at line 116 of file WhereClause.java.
117 if(!Strings.isBlank(clause)) {
118 if(!Strings.isBlank(groupByClause) && clause.toLowerCase().contains(
"group by")) {
119 clause +=
" " + groupByClause;
121 if(!Strings.isBlank(orderByClause) && clause.toLowerCase().contains(
"order by")) {
122 clause +=
" " + orderByClause;
125 if(clause.matches(
".*\\{[^\\}]+\\}.*")) {
126 clause = clause.replaceAll(
"\\{([^\\}]+)\\}", useNative ?
"*" :
"$1");
◆ getFieldOcurrence()
String org.turro.elephant.db.WhereClause.getFieldOcurrence |
( |
| ) |
|
◆ getFromClause()
static WhereClause org.turro.elephant.db.WhereClause.getFromClause |
( |
String |
clause | ) |
|
|
static |
◆ getNamedValues() [1/2]
Map<String, Object> org.turro.elephant.db.WhereClause.getNamedValues |
( |
| ) |
|
◆ getNamedValues() [2/2]
List<Object> org.turro.elephant.db.WhereClause.getNamedValues |
( |
String ... |
name | ) |
|
Definition at line 100 of file WhereClause.java.
101 ArrayList<Object> list =
new ArrayList<>();
102 for(String n : name) {
103 if(namedValues.containsKey(n)) list.add(namedValues.get(n));
◆ getPrefix()
String org.turro.elephant.db.WhereClause.getPrefix |
( |
| ) |
|
◆ getResultClass()
Class org.turro.elephant.db.WhereClause.getResultClass |
( |
| ) |
|
◆ getUniqueSuffix()
int org.turro.elephant.db.WhereClause.getUniqueSuffix |
( |
| ) |
|
◆ getUniqueVariable()
String org.turro.elephant.db.WhereClause.getUniqueVariable |
( |
String |
prefix | ) |
|
◆ getValue()
Object org.turro.elephant.db.WhereClause.getValue |
( |
int |
index | ) |
|
◆ getValueCount()
int org.turro.elephant.db.WhereClause.getValueCount |
( |
| ) |
|
◆ getValues()
Object [] org.turro.elephant.db.WhereClause.getValues |
( |
| ) |
|
◆ isUseNative()
boolean org.turro.elephant.db.WhereClause.isUseNative |
( |
| ) |
|
◆ setClause()
void org.turro.elephant.db.WhereClause.setClause |
( |
String |
clause | ) |
|
◆ setFieldOcurrence()
void org.turro.elephant.db.WhereClause.setFieldOcurrence |
( |
String |
fieldOcurrence | ) |
|
Definition at line 184 of file WhereClause.java.
185 if(fieldOcurrence ==
null) fieldOcurrence =
"and";
186 this.fieldOcurrence = fieldOcurrence;
◆ setGroupByClause()
void org.turro.elephant.db.WhereClause.setGroupByClause |
( |
String |
groupByClause | ) |
|
◆ setNamedParameters()
void org.turro.elephant.db.WhereClause.setNamedParameters |
( |
Query |
q | ) |
|
Definition at line 174 of file WhereClause.java.
175 for (Map.Entry<String, Object> e : namedValues.entrySet()) {
176 q.setParameter(e.getKey(), e.getValue());
◆ setOrderByClause()
void org.turro.elephant.db.WhereClause.setOrderByClause |
( |
String |
orderByClause | ) |
|
◆ setParameters()
void org.turro.elephant.db.WhereClause.setParameters |
( |
Query |
q, |
|
|
int |
start |
|
) |
| |
◆ setPrefix()
void org.turro.elephant.db.WhereClause.setPrefix |
( |
String |
prefix | ) |
|
Definition at line 193 of file WhereClause.java.
194 if(prefix ==
null) prefix =
"and";
195 this.prefix = prefix;
◆ setResultClass()
void org.turro.elephant.db.WhereClause.setResultClass |
( |
Class |
resultClass | ) |
|
◆ setUseNative()
void org.turro.elephant.db.WhereClause.setUseNative |
( |
boolean |
useNative | ) |
|
The documentation for this class was generated from the following file: