|
1
|
|
package mobisnap.mobile_trx;
|
|
2
|
|
|
|
3
|
|
import java.sql.*;
|
|
4
|
|
import java.util.*;
|
|
5
|
|
import java.math.*;
|
|
6
|
|
import java.text.*;
|
|
7
|
|
|
|
8
|
|
public class MSQLTypeUtil
|
|
9
|
|
{
|
|
10
|
|
static DateFormat[] df;
|
|
11
|
|
|
|
12
|
|
static {
|
|
13
|
0
|
df = new DateFormat[12];
|
|
14
|
0
|
df[2] = new SimpleDateFormat( "dd-MMM-yy");
|
|
15
|
0
|
df[3] = new SimpleDateFormat( "dd-MMM-yyyy");
|
|
16
|
0
|
df[4] = new SimpleDateFormat( "dd-MM-yy");
|
|
17
|
0
|
df[5] = new SimpleDateFormat( "dd-MM-yyyy");
|
|
18
|
0
|
df[6] = new SimpleDateFormat( "yy-MM-dd");
|
|
19
|
0
|
df[7] = new SimpleDateFormat( "yyyy-MM-dd");
|
|
20
|
0
|
df[8] = new SimpleDateFormat( "dd-MM-yy HH:mm:ss");
|
|
21
|
0
|
df[9] = new SimpleDateFormat( "dd-MM-yyyy HH:mm:ss");
|
|
22
|
0
|
df[10] = new SimpleDateFormat( "yy-MM-dd HH:mm:ss");
|
|
23
|
0
|
df[11] = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
|
|
24
|
|
}
|
|
25
|
|
|
|
26
|
0
|
public static String date2String( java.util.Date d) {
|
|
27
|
0
|
for( int i = 0; i < df.length; i++)
|
|
28
|
0
|
if( df[i] != null)
|
|
29
|
0
|
return df[i].format( d);
|
|
30
|
0
|
return d.toString();
|
|
31
|
|
}
|
|
32
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
|
36
|
0
|
public static String value2String( Object value) {
|
|
37
|
0
|
if( value instanceof String)
|
|
38
|
0
|
return "'" + value + "'";
|
|
39
|
0
|
else if( value instanceof java.util.Date)
|
|
40
|
0
|
return date2String( (java.util.Date)value);
|
|
41
|
0
|
else if( value == null)
|
|
42
|
0
|
return "NULL";
|
|
43
|
|
else
|
|
44
|
0
|
return value.toString();
|
|
45
|
|
}
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
|
49
|
|
|
|
50
|
0
|
public static String value2StringDomain( Object value) {
|
|
51
|
0
|
if( value instanceof String)
|
|
52
|
0
|
return (String)value;
|
|
53
|
0
|
else if( value instanceof java.util.Date)
|
|
54
|
0
|
return date2String( (java.util.Date)value);
|
|
55
|
0
|
else if( value == null)
|
|
56
|
0
|
return "NULL";
|
|
57
|
|
else
|
|
58
|
0
|
return value.toString();
|
|
59
|
|
}
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
|
63
|
|
|
|
64
|
0
|
public static boolean isNull( Object obj) {
|
|
65
|
0
|
return obj == null || obj instanceof SQLNull;
|
|
66
|
|
}
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
|
71
|
0
|
public static boolean isDecimal( Object obj) {
|
|
72
|
0
|
return obj instanceof Integer || obj instanceof Double || obj instanceof BigDecimal;
|
|
73
|
|
}
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|
78
|
0
|
public static boolean mayBeDate( Object obj) {
|
|
79
|
0
|
if( obj instanceof java.sql.Date)
|
|
80
|
0
|
return true;
|
|
81
|
0
|
else if( obj instanceof String) {
|
|
82
|
0
|
try {
|
|
83
|
0
|
string2Date( (String)obj);
|
|
84
|
0
|
return true;
|
|
85
|
|
} catch( Exception e) {
|
|
86
|
0
|
return false;
|
|
87
|
|
}
|
|
88
|
|
} else
|
|
89
|
0
|
return false;
|
|
90
|
|
}
|
|
91
|
|
|
|
92
|
|
|
|
93
|
|
|
|
94
|
|
|
|
95
|
|
|
|
96
|
0
|
public static Object upgradeDecimal( Object objl, Object objr) throws Exception {
|
|
97
|
0
|
if( objl instanceof String)
|
|
98
|
0
|
return upgradeDecimal( string2Decimal( (String)objl), objr);
|
|
99
|
0
|
if( objr instanceof String)
|
|
100
|
0
|
return upgradeDecimal( objl, string2Decimal( (String)objr));
|
|
101
|
0
|
if( objl instanceof Integer) {
|
|
102
|
0
|
if( objr instanceof Double)
|
|
103
|
0
|
return new Double( ((Integer)objl).doubleValue());
|
|
104
|
0
|
else if( objr instanceof BigDecimal)
|
|
105
|
0
|
return new BigDecimal( ((Integer)objl).doubleValue());
|
|
106
|
0
|
} else if( objl instanceof Double && objr instanceof BigDecimal)
|
|
107
|
0
|
return new BigDecimal( ((Double)objl).doubleValue());
|
|
108
|
0
|
return objl;
|
|
109
|
|
}
|
|
110
|
|
|
|
111
|
|
|
|
112
|
|
|
|
113
|
|
|
|
114
|
0
|
public static Object string2Decimal( String str) throws Exception {
|
|
115
|
0
|
try {
|
|
116
|
0
|
if( str.indexOf( '.') == -1) {
|
|
117
|
0
|
try {
|
|
118
|
0
|
return new Integer( str);
|
|
119
|
|
} catch ( Exception e) {
|
|
120
|
0
|
return new BigDecimal( str);
|
|
121
|
|
}
|
|
122
|
|
} else {
|
|
123
|
0
|
Double d = new Double( str);
|
|
124
|
0
|
BigDecimal bd1 = null;
|
|
125
|
0
|
try {
|
|
126
|
0
|
bd1 = new BigDecimal( str);
|
|
127
|
|
} catch( Exception e) {
|
|
128
|
0
|
return d;
|
|
129
|
|
}
|
|
130
|
0
|
if( bd1.compareTo( new BigDecimal( d.doubleValue())) == 0)
|
|
131
|
0
|
return d;
|
|
132
|
|
else
|
|
133
|
0
|
return bd1;
|
|
134
|
|
}
|
|
135
|
|
} catch( Exception e) {
|
|
136
|
0
|
throw new mobisnap.MobisnapException( "Impossible string to decimal conversion");
|
|
137
|
|
}
|
|
138
|
|
}
|
|
139
|
|
|
|
140
|
|
|
|
141
|
|
|
|
142
|
|
|
|
143
|
0
|
public static java.sql.Date string2Date( String str) throws Exception {
|
|
144
|
0
|
try {
|
|
145
|
0
|
return java.sql.Date.valueOf( str);
|
|
146
|
|
} catch( Exception e) {
|
|
147
|
0
|
for( int i = 0; i < df.length; i++) {
|
|
148
|
0
|
try {
|
|
149
|
0
|
if( df[i] != null)
|
|
150
|
0
|
return new java.sql.Date( df[i].parse( str).getTime());
|
|
151
|
|
} catch( java.text.ParseException ex) {
|
|
152
|
|
|
|
153
|
|
}
|
|
154
|
|
}
|
|
155
|
0
|
throw new mobisnap.MobisnapException( "Impossible string to date conversion");
|
|
156
|
|
}
|
|
157
|
|
}
|
|
158
|
|
|
|
159
|
|
|
|
160
|
|
|
|
161
|
|
|
|
162
|
0
|
public static Object negate( Object obj)
|
|
163
|
|
throws Exception {
|
|
164
|
0
|
if( obj instanceof SQLNull)
|
|
165
|
0
|
return obj;
|
|
166
|
0
|
else if( obj instanceof Integer)
|
|
167
|
0
|
return new Integer( - ((Integer)obj).intValue());
|
|
168
|
0
|
else if( obj instanceof Double)
|
|
169
|
0
|
return new Double( - ((Double)obj).doubleValue());
|
|
170
|
0
|
else if( obj instanceof BigDecimal)
|
|
171
|
0
|
return ((BigDecimal)obj).negate();
|
|
172
|
0
|
else if( obj instanceof String)
|
|
173
|
0
|
return negate( string2Decimal((String)obj));
|
|
174
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for minus");
|
|
175
|
|
}
|
|
176
|
|
|
|
177
|
|
|
|
178
|
|
|
|
179
|
|
|
|
180
|
0
|
public static Object pow( Object objl, Object objr)
|
|
181
|
|
throws Exception {
|
|
182
|
0
|
if( objl instanceof SQLNull)
|
|
183
|
0
|
return objl;
|
|
184
|
0
|
if( objr instanceof SQLNull)
|
|
185
|
0
|
return objr;
|
|
186
|
0
|
if( ! isDecimal( objl)) {
|
|
187
|
0
|
if( objl instanceof String)
|
|
188
|
0
|
objl = string2Decimal( (String)objl);
|
|
189
|
|
else
|
|
190
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for expotent");
|
|
191
|
|
}
|
|
192
|
0
|
if( ! isDecimal( objr)) {
|
|
193
|
0
|
if( objr instanceof String)
|
|
194
|
0
|
objr = string2Decimal( (String)objr);
|
|
195
|
|
else
|
|
196
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for expotent");
|
|
197
|
|
}
|
|
198
|
0
|
return new Double( Math.pow( ((Number)objl).doubleValue(), ((Number)objr).doubleValue()));
|
|
199
|
|
}
|
|
200
|
|
|
|
201
|
|
|
|
202
|
|
|
|
203
|
|
|
|
204
|
0
|
public static Object multiply( Object objl, Object objr)
|
|
205
|
|
throws Exception {
|
|
206
|
0
|
if( objl instanceof SQLNull)
|
|
207
|
0
|
return objl;
|
|
208
|
0
|
if( objr instanceof SQLNull)
|
|
209
|
0
|
return objr;
|
|
210
|
0
|
if( ! isDecimal( objl)) {
|
|
211
|
0
|
if( objl instanceof String)
|
|
212
|
0
|
objl = string2Decimal( (String)objl);
|
|
213
|
|
else
|
|
214
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for multiply");
|
|
215
|
|
}
|
|
216
|
0
|
if( ! isDecimal( objr)) {
|
|
217
|
0
|
if( objr instanceof String)
|
|
218
|
0
|
objr = string2Decimal( (String)objr);
|
|
219
|
|
else
|
|
220
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for multiply");
|
|
221
|
|
}
|
|
222
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
223
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
224
|
0
|
if( objl instanceof Integer)
|
|
225
|
0
|
return new Integer( ((Integer)objl).intValue() * ((Integer)objr).intValue());
|
|
226
|
0
|
else if( objl instanceof Double)
|
|
227
|
0
|
return new Double( ((Double)objl).doubleValue() * ((Double)objr).doubleValue());
|
|
228
|
|
else
|
|
229
|
0
|
return ((BigDecimal)objl).multiply( (BigDecimal)objr);
|
|
230
|
|
}
|
|
231
|
|
|
|
232
|
|
|
|
233
|
|
|
|
234
|
|
|
|
235
|
0
|
public static Object divide( Object objl, Object objr)
|
|
236
|
|
throws Exception {
|
|
237
|
0
|
if( objl instanceof SQLNull)
|
|
238
|
0
|
return objl;
|
|
239
|
0
|
if( objr instanceof SQLNull)
|
|
240
|
0
|
return objr;
|
|
241
|
0
|
if( ! isDecimal( objl)) {
|
|
242
|
0
|
if( objl instanceof String)
|
|
243
|
0
|
objl = string2Decimal( (String)objl);
|
|
244
|
|
else
|
|
245
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for divide");
|
|
246
|
|
}
|
|
247
|
0
|
if( ! isDecimal( objr)) {
|
|
248
|
0
|
if( objr instanceof String)
|
|
249
|
0
|
objr = string2Decimal( (String)objr);
|
|
250
|
|
else
|
|
251
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for divide");
|
|
252
|
|
}
|
|
253
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
254
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
255
|
0
|
if( objl instanceof Integer)
|
|
256
|
0
|
return new Integer( ((Integer)objl).intValue() / ((Integer)objr).intValue());
|
|
257
|
0
|
else if( objl instanceof Double)
|
|
258
|
0
|
return new Double( ((Double)objl).doubleValue() / ((Double)objr).doubleValue());
|
|
259
|
|
else
|
|
260
|
0
|
return ((BigDecimal)objl).divide( (BigDecimal)objr, BigDecimal.ROUND_HALF_UP);
|
|
261
|
|
}
|
|
262
|
|
|
|
263
|
|
|
|
264
|
|
|
|
265
|
|
|
|
266
|
|
|
|
267
|
|
|
|
268
|
0
|
public static Object add( Object objl, Object objr)
|
|
269
|
|
throws Exception {
|
|
270
|
0
|
if( objl instanceof SQLNull)
|
|
271
|
0
|
return objl;
|
|
272
|
0
|
if( objr instanceof SQLNull)
|
|
273
|
0
|
return objr;
|
|
274
|
0
|
if( mayBeDate( objl)) {
|
|
275
|
0
|
if( objl instanceof String)
|
|
276
|
0
|
objl = string2Date( (String)objl);
|
|
277
|
0
|
Calendar cal = new GregorianCalendar();
|
|
278
|
0
|
cal.setTime( (java.sql.Date)objl);
|
|
279
|
0
|
if( ! isDecimal( objr)) {
|
|
280
|
0
|
if( objr instanceof String)
|
|
281
|
0
|
objr = string2Decimal( (String)objr);
|
|
282
|
|
else
|
|
283
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for add");
|
|
284
|
|
}
|
|
285
|
0
|
cal.add( Calendar.DATE, ((Number)objr).intValue());
|
|
286
|
0
|
return new java.sql.Date( cal.getTime().getTime());
|
|
287
|
|
} else {
|
|
288
|
0
|
if( ! isDecimal( objl)) {
|
|
289
|
0
|
if( objl instanceof String)
|
|
290
|
0
|
objl = string2Decimal( (String)objl);
|
|
291
|
|
else
|
|
292
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for add");
|
|
293
|
|
}
|
|
294
|
0
|
if( ! isDecimal( objr)) {
|
|
295
|
0
|
if( objr instanceof String)
|
|
296
|
0
|
objr = string2Decimal( (String)objr);
|
|
297
|
|
else
|
|
298
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for add");
|
|
299
|
|
}
|
|
300
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
301
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
302
|
0
|
if( objl instanceof Integer)
|
|
303
|
0
|
return new Integer( ((Integer)objl).intValue() + ((Integer)objr).intValue());
|
|
304
|
0
|
else if( objl instanceof Double)
|
|
305
|
0
|
return new Double( ((Double)objl).doubleValue() + ((Double)objr).doubleValue());
|
|
306
|
|
else
|
|
307
|
0
|
return ((BigDecimal)objl).add( (BigDecimal)objr);
|
|
308
|
|
}
|
|
309
|
|
}
|
|
310
|
|
|
|
311
|
|
|
|
312
|
|
|
|
313
|
|
|
|
314
|
0
|
public static Object subtract( Object objl, Object objr)
|
|
315
|
|
throws Exception {
|
|
316
|
0
|
if( objl instanceof SQLNull)
|
|
317
|
0
|
return objl;
|
|
318
|
0
|
if( objr instanceof SQLNull)
|
|
319
|
0
|
return objr;
|
|
320
|
0
|
if( mayBeDate( objl)) {
|
|
321
|
0
|
if( objl instanceof String)
|
|
322
|
0
|
objl = string2Date( (String)objl);
|
|
323
|
0
|
Calendar cal = new GregorianCalendar();
|
|
324
|
0
|
cal.setTime( (java.sql.Date)objl);
|
|
325
|
0
|
if( mayBeDate( objr)) {
|
|
326
|
0
|
if( objr instanceof String)
|
|
327
|
0
|
objr = string2Date( (String)objl);
|
|
328
|
0
|
Calendar cal2 = new GregorianCalendar();
|
|
329
|
0
|
cal2.setTime( (java.sql.Date)objr);
|
|
330
|
0
|
cal.set( Calendar.MILLISECOND, 0);
|
|
331
|
0
|
cal.set( Calendar.SECOND, 0);
|
|
332
|
0
|
cal.set( Calendar.MINUTE, 0);
|
|
333
|
0
|
cal.set( Calendar.HOUR, 2);
|
|
334
|
0
|
cal2.set( Calendar.MILLISECOND, 0);
|
|
335
|
0
|
cal2.set( Calendar.SECOND, 0);
|
|
336
|
0
|
cal2.set( Calendar.MINUTE, 0);
|
|
337
|
0
|
cal2.set( Calendar.HOUR, 2);
|
|
338
|
0
|
long l = ((java.sql.Date)objl).getTime() - ((java.sql.Date)objr).getTime();
|
|
339
|
0
|
return new Integer( (int)( l / 86400000L));
|
|
340
|
|
}
|
|
341
|
0
|
if( ! isDecimal( objr)) {
|
|
342
|
0
|
if( objr instanceof String)
|
|
343
|
0
|
objr = string2Decimal( (String)objr);
|
|
344
|
|
else
|
|
345
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for subtract");
|
|
346
|
|
}
|
|
347
|
0
|
cal.add( Calendar.DATE, -((Number)objr).intValue());
|
|
348
|
0
|
return new java.sql.Date( cal.getTime().getTime());
|
|
349
|
|
} else {
|
|
350
|
0
|
if( ! isDecimal( objl)) {
|
|
351
|
0
|
if( objl instanceof String)
|
|
352
|
0
|
objl = string2Decimal( (String)objl);
|
|
353
|
|
else
|
|
354
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for subtract");
|
|
355
|
|
}
|
|
356
|
0
|
if( ! isDecimal( objr)) {
|
|
357
|
0
|
if( objr instanceof String)
|
|
358
|
0
|
objr = string2Decimal( (String)objr);
|
|
359
|
|
else
|
|
360
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for subtract");
|
|
361
|
|
}
|
|
362
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
363
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
364
|
0
|
if( objl instanceof Integer)
|
|
365
|
0
|
return new Integer( ((Integer)objl).intValue() - ((Integer)objr).intValue());
|
|
366
|
0
|
else if( objl instanceof Double)
|
|
367
|
0
|
return new Double( ((Double)objl).doubleValue() - ((Double)objr).doubleValue());
|
|
368
|
|
else
|
|
369
|
0
|
return ((BigDecimal)objl).subtract( (BigDecimal)objr);
|
|
370
|
|
}
|
|
371
|
|
}
|
|
372
|
|
|
|
373
|
|
|
|
374
|
|
|
|
375
|
|
|
|
376
|
0
|
public static Object concat( Object objl, Object objr) throws Exception {
|
|
377
|
0
|
if( isDecimal( objl))
|
|
378
|
0
|
objl = objl.toString();
|
|
379
|
0
|
if( isDecimal( objr))
|
|
380
|
0
|
objr = objr.toString();
|
|
381
|
0
|
if( objl instanceof Boolean)
|
|
382
|
0
|
objl = objl.toString();
|
|
383
|
0
|
if( objr instanceof Boolean)
|
|
384
|
0
|
objr = objr.toString();
|
|
385
|
0
|
if( objr instanceof java.sql.Date)
|
|
386
|
0
|
objr = MSQLTypeUtil.date2String( (java.sql.Date)objr);
|
|
387
|
0
|
if( objl instanceof java.sql.Date)
|
|
388
|
0
|
objl = MSQLTypeUtil.date2String( (java.sql.Date)objl);
|
|
389
|
0
|
if( objl instanceof SQLNull && objr instanceof String)
|
|
390
|
0
|
return objr;
|
|
391
|
0
|
if( objr instanceof SQLNull && objl instanceof String)
|
|
392
|
0
|
return objl;
|
|
393
|
0
|
if( objl instanceof SQLNull && objr instanceof SQLNull)
|
|
394
|
0
|
return objl;
|
|
395
|
0
|
if( ! ( objl instanceof String) || ! ( objr instanceof String))
|
|
396
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for concatenation");
|
|
397
|
0
|
return ((String)objl).concat( (String)objr);
|
|
398
|
|
}
|
|
399
|
|
|
|
400
|
|
|
|
401
|
|
|
|
402
|
|
|
|
403
|
0
|
public static Object equal( Object objl, Object objr)
|
|
404
|
|
throws Exception {
|
|
405
|
0
|
if( objl instanceof SQLNull)
|
|
406
|
0
|
return objl;
|
|
407
|
0
|
if( objr instanceof SQLNull)
|
|
408
|
0
|
return objr;
|
|
409
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
410
|
0
|
if( ! isDecimal( objl)) {
|
|
411
|
0
|
if( objl instanceof String)
|
|
412
|
0
|
objl = string2Decimal( (String)objl);
|
|
413
|
|
else
|
|
414
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
415
|
|
}
|
|
416
|
0
|
if( ! isDecimal( objr)) {
|
|
417
|
0
|
if( objr instanceof String)
|
|
418
|
0
|
objr = string2Decimal( (String)objr);
|
|
419
|
|
else
|
|
420
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
421
|
|
}
|
|
422
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
423
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
424
|
0
|
if( objl instanceof Integer)
|
|
425
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) == 0);
|
|
426
|
0
|
else if( objl instanceof Double)
|
|
427
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) == 0);
|
|
428
|
|
else
|
|
429
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) == 0);
|
|
430
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
431
|
0
|
if( objl instanceof String)
|
|
432
|
0
|
objl = string2Date( (String)objl);
|
|
433
|
0
|
else if( objr instanceof String)
|
|
434
|
0
|
objr = string2Date( (String)objr);
|
|
435
|
|
else
|
|
436
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
437
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) == 0);
|
|
438
|
0
|
} else if( objl instanceof Boolean && objr instanceof Boolean)
|
|
439
|
0
|
return new Boolean( ((Boolean)objl).equals( (Boolean)objr));
|
|
440
|
0
|
else if( objl instanceof String && objr instanceof String)
|
|
441
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) == 0);
|
|
442
|
0
|
else if( objl instanceof String || objr instanceof String) {
|
|
443
|
0
|
if( objl instanceof Boolean) {
|
|
444
|
0
|
if( ((String)objr).equalsIgnoreCase( "true") || ((String)objr).equalsIgnoreCase( "false"))
|
|
445
|
0
|
return new Boolean( ((Boolean)objl).equals( new Boolean( (String)objr)));
|
|
446
|
|
else
|
|
447
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 03");
|
|
448
|
|
}
|
|
449
|
0
|
if( objr instanceof Boolean) {
|
|
450
|
0
|
if( ((String)objl).equalsIgnoreCase( "true") || ((String)objl).equalsIgnoreCase( "false"))
|
|
451
|
0
|
return new Boolean( ((Boolean)objr).equals( new Boolean( (String)objr)));
|
|
452
|
|
else
|
|
453
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 04");
|
|
454
|
|
}
|
|
455
|
|
}
|
|
456
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for equal");
|
|
457
|
|
}
|
|
458
|
|
|
|
459
|
|
|
|
460
|
|
|
|
461
|
|
|
|
462
|
0
|
public static Object notEqual( Object objl, Object objr)
|
|
463
|
|
throws Exception {
|
|
464
|
0
|
if( objl instanceof SQLNull)
|
|
465
|
0
|
return objl;
|
|
466
|
0
|
if( objr instanceof SQLNull)
|
|
467
|
0
|
return objr;
|
|
468
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
469
|
0
|
if( ! isDecimal( objl)) {
|
|
470
|
0
|
if( objl instanceof String)
|
|
471
|
0
|
objl = string2Decimal( (String)objl);
|
|
472
|
|
else
|
|
473
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
474
|
|
}
|
|
475
|
0
|
if( ! isDecimal( objr)) {
|
|
476
|
0
|
if( objr instanceof String)
|
|
477
|
0
|
objr = string2Decimal( (String)objr);
|
|
478
|
|
else
|
|
479
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
480
|
|
}
|
|
481
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
482
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
483
|
0
|
if( objl instanceof Integer)
|
|
484
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) != 0);
|
|
485
|
0
|
else if( objl instanceof Double)
|
|
486
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) != 0);
|
|
487
|
|
else
|
|
488
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) != 0);
|
|
489
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
490
|
0
|
if( objl instanceof String)
|
|
491
|
0
|
objl = string2Date( (String)objl);
|
|
492
|
0
|
else if( objr instanceof String)
|
|
493
|
0
|
objr = string2Date( (String)objr);
|
|
494
|
|
else
|
|
495
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
496
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) != 0);
|
|
497
|
0
|
} else if( objl instanceof Boolean && objr instanceof Boolean)
|
|
498
|
0
|
return new Boolean( ! ((Boolean)objl).equals( (Boolean)objr));
|
|
499
|
0
|
else if( objl instanceof String && objr instanceof String)
|
|
500
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) != 0);
|
|
501
|
0
|
else if( objl instanceof String || objr instanceof String) {
|
|
502
|
0
|
if( objl instanceof Boolean) {
|
|
503
|
0
|
if( ((String)objr).equalsIgnoreCase( "true") || ((String)objr).equalsIgnoreCase( "false"))
|
|
504
|
0
|
return new Boolean( ((Boolean)objl).booleanValue() != new Boolean( (String)objr).booleanValue());
|
|
505
|
|
else
|
|
506
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 03");
|
|
507
|
|
}
|
|
508
|
0
|
if( objr instanceof Boolean) {
|
|
509
|
0
|
if( ((String)objl).equalsIgnoreCase( "true") || ((String)objl).equalsIgnoreCase( "false"))
|
|
510
|
0
|
return new Boolean( ((Boolean)objr).booleanValue() != new Boolean( (String)objr).booleanValue());
|
|
511
|
|
else
|
|
512
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 04");
|
|
513
|
|
}
|
|
514
|
|
}
|
|
515
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for not equal");
|
|
516
|
|
}
|
|
517
|
|
|
|
518
|
|
|
|
519
|
|
|
|
520
|
|
|
|
521
|
0
|
public static Object moreOrLess( Object objl, Object objr)
|
|
522
|
|
throws Exception {
|
|
523
|
0
|
if( objl instanceof SQLNull)
|
|
524
|
0
|
return objl;
|
|
525
|
0
|
if( objr instanceof SQLNull)
|
|
526
|
0
|
return objr;
|
|
527
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
528
|
0
|
if( ! isDecimal( objl)) {
|
|
529
|
0
|
if( objl instanceof String)
|
|
530
|
0
|
objl = string2Decimal( (String)objl);
|
|
531
|
|
else
|
|
532
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
533
|
|
}
|
|
534
|
0
|
if( ! isDecimal( objr)) {
|
|
535
|
0
|
if( objr instanceof String)
|
|
536
|
0
|
objr = string2Decimal( (String)objr);
|
|
537
|
|
else
|
|
538
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
539
|
|
}
|
|
540
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
541
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
542
|
0
|
if( objl instanceof Integer)
|
|
543
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) != 0);
|
|
544
|
0
|
else if( objl instanceof Double)
|
|
545
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) != 0);
|
|
546
|
|
else
|
|
547
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) != 0);
|
|
548
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
549
|
0
|
if( objl instanceof String)
|
|
550
|
0
|
objl = string2Date( (String)objl);
|
|
551
|
0
|
else if( objr instanceof String)
|
|
552
|
0
|
objr = string2Date( (String)objr);
|
|
553
|
|
else
|
|
554
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
555
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) != 0);
|
|
556
|
0
|
} else if( objl instanceof Boolean && objr instanceof Boolean)
|
|
557
|
0
|
return new Boolean( ! ((Boolean)objl).equals( (Boolean)objr));
|
|
558
|
0
|
else if( objl instanceof String && objr instanceof String)
|
|
559
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) != 0);
|
|
560
|
0
|
else if( objl instanceof String || objr instanceof String) {
|
|
561
|
0
|
if( objl instanceof Boolean) {
|
|
562
|
0
|
if( ((String)objr).equalsIgnoreCase( "true") || ((String)objr).equalsIgnoreCase( "false"))
|
|
563
|
0
|
return new Boolean( ((Boolean)objl).booleanValue() != new Boolean( (String)objr).booleanValue() );
|
|
564
|
|
else
|
|
565
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 03");
|
|
566
|
|
}
|
|
567
|
0
|
if( objr instanceof Boolean) {
|
|
568
|
0
|
if( ((String)objl).equalsIgnoreCase( "true") || ((String)objl).equalsIgnoreCase( "false"))
|
|
569
|
0
|
return new Boolean( ((Boolean)objr).booleanValue() != new Boolean( (String)objr).booleanValue());
|
|
570
|
|
else
|
|
571
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 04");
|
|
572
|
|
}
|
|
573
|
|
}
|
|
574
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for more or less");
|
|
575
|
|
}
|
|
576
|
|
|
|
577
|
|
|
|
578
|
|
|
|
579
|
|
|
|
580
|
0
|
public static Object more( Object objl, Object objr)
|
|
581
|
|
throws Exception {
|
|
582
|
0
|
if( objl instanceof SQLNull)
|
|
583
|
0
|
return objl;
|
|
584
|
0
|
if( objr instanceof SQLNull)
|
|
585
|
0
|
return objr;
|
|
586
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
587
|
0
|
if( ! isDecimal( objl)) {
|
|
588
|
0
|
if( objl instanceof String)
|
|
589
|
0
|
objl = string2Decimal( (String)objl);
|
|
590
|
|
else
|
|
591
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
592
|
|
}
|
|
593
|
0
|
if( ! isDecimal( objr)) {
|
|
594
|
0
|
if( objr instanceof String)
|
|
595
|
0
|
objr = string2Decimal( (String)objr);
|
|
596
|
|
else
|
|
597
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
598
|
|
}
|
|
599
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
600
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
601
|
0
|
if( objl instanceof Integer)
|
|
602
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) > 0);
|
|
603
|
0
|
else if( objl instanceof Double)
|
|
604
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) > 0);
|
|
605
|
|
else
|
|
606
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) > 0);
|
|
607
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
608
|
0
|
if( objl instanceof String)
|
|
609
|
0
|
objl = string2Date( (String)objl);
|
|
610
|
0
|
else if( objr instanceof String)
|
|
611
|
0
|
objr = string2Date( (String)objr);
|
|
612
|
|
else
|
|
613
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
614
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) > 0);
|
|
615
|
0
|
} else if( (objl instanceof String || objr instanceof String) &&
|
|
616
|
|
(objl instanceof Boolean || objr instanceof Boolean)) {
|
|
617
|
0
|
if( objl instanceof Boolean)
|
|
618
|
0
|
objl = objl.toString();
|
|
619
|
0
|
if( objr instanceof Boolean)
|
|
620
|
0
|
objr = objr.toString();
|
|
621
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) > 0);
|
|
622
|
0
|
} else if( objl instanceof String && objr instanceof String)
|
|
623
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) > 0);
|
|
624
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for more");
|
|
625
|
|
}
|
|
626
|
|
|
|
627
|
|
|
|
628
|
|
|
|
629
|
|
|
|
630
|
0
|
public static Object moreEqual( Object objl, Object objr)
|
|
631
|
|
throws Exception {
|
|
632
|
0
|
if( objl instanceof SQLNull)
|
|
633
|
0
|
return objl;
|
|
634
|
0
|
if( objr instanceof SQLNull)
|
|
635
|
0
|
return objr;
|
|
636
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
637
|
0
|
if( ! isDecimal( objl)) {
|
|
638
|
0
|
if( objl instanceof String)
|
|
639
|
0
|
objl = string2Decimal( (String)objl);
|
|
640
|
|
else
|
|
641
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
642
|
|
}
|
|
643
|
0
|
if( ! isDecimal( objr)) {
|
|
644
|
0
|
if( objr instanceof String)
|
|
645
|
0
|
objr = string2Decimal( (String)objr);
|
|
646
|
|
else
|
|
647
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
648
|
|
}
|
|
649
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
650
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
651
|
0
|
if( objl instanceof Integer)
|
|
652
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) >= 0);
|
|
653
|
0
|
else if( objl instanceof Double)
|
|
654
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) >= 0);
|
|
655
|
|
else
|
|
656
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) >= 0);
|
|
657
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
658
|
0
|
if( objl instanceof String)
|
|
659
|
0
|
objl = string2Date( (String)objl);
|
|
660
|
0
|
else if( objr instanceof String)
|
|
661
|
0
|
objr = string2Date( (String)objr);
|
|
662
|
|
else
|
|
663
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
664
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) >= 0);
|
|
665
|
0
|
} else if( (objl instanceof String || objr instanceof String) &&
|
|
666
|
|
(objl instanceof Boolean || objr instanceof Boolean)) {
|
|
667
|
0
|
if( objl instanceof Boolean)
|
|
668
|
0
|
objl = objl.toString();
|
|
669
|
0
|
if( objr instanceof Boolean)
|
|
670
|
0
|
objr = objr.toString();
|
|
671
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) >= 0);
|
|
672
|
0
|
} else if( objl instanceof String && objr instanceof String)
|
|
673
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) >= 0);
|
|
674
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for more equal");
|
|
675
|
|
}
|
|
676
|
|
|
|
677
|
|
|
|
678
|
|
|
|
679
|
|
|
|
680
|
0
|
public static Object less( Object objl, Object objr)
|
|
681
|
|
throws Exception {
|
|
682
|
0
|
if( objl instanceof SQLNull)
|
|
683
|
0
|
return objl;
|
|
684
|
0
|
if( objr instanceof SQLNull)
|
|
685
|
0
|
return objr;
|
|
686
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
687
|
0
|
if( ! isDecimal( objl)) {
|
|
688
|
0
|
if( objl instanceof String)
|
|
689
|
0
|
objl = string2Decimal( (String)objl);
|
|
690
|
|
else
|
|
691
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
692
|
|
}
|
|
693
|
0
|
if( ! isDecimal( objr)) {
|
|
694
|
0
|
if( objr instanceof String)
|
|
695
|
0
|
objr = string2Decimal( (String)objr);
|
|
696
|
|
else
|
|
697
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
698
|
|
}
|
|
699
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
700
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
701
|
0
|
if( objl instanceof Integer)
|
|
702
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) < 0);
|
|
703
|
0
|
else if( objl instanceof Double)
|
|
704
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) < 0);
|
|
705
|
|
else
|
|
706
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) < 0);
|
|
707
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
708
|
0
|
if( objl instanceof String)
|
|
709
|
0
|
objl = string2Date( (String)objl);
|
|
710
|
0
|
else if( objr instanceof String)
|
|
711
|
0
|
objr = string2Date( (String)objr);
|
|
712
|
|
else
|
|
713
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
714
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) < 0);
|
|
715
|
0
|
} else if( (objl instanceof String || objr instanceof String) &&
|
|
716
|
|
(objl instanceof Boolean || objr instanceof Boolean)) {
|
|
717
|
0
|
if( objl instanceof Boolean)
|
|
718
|
0
|
objl = objl.toString();
|
|
719
|
0
|
if( objr instanceof Boolean)
|
|
720
|
0
|
objr = objr.toString();
|
|
721
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) < 0);
|
|
722
|
0
|
} else if( objl instanceof String && objr instanceof String)
|
|
723
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) < 0);
|
|
724
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for less");
|
|
725
|
|
}
|
|
726
|
|
|
|
727
|
|
|
|
728
|
|
|
|
729
|
|
|
|
730
|
0
|
public static Object lessEqual( Object objl, Object objr)
|
|
731
|
|
throws Exception {
|
|
732
|
0
|
if( objl instanceof SQLNull)
|
|
733
|
0
|
return objl;
|
|
734
|
0
|
if( objr instanceof SQLNull)
|
|
735
|
0
|
return objr;
|
|
736
|
0
|
if( isDecimal( objl) || isDecimal( objr)) {
|
|
737
|
0
|
if( ! isDecimal( objl)) {
|
|
738
|
0
|
if( objl instanceof String)
|
|
739
|
0
|
objl = string2Decimal( (String)objl);
|
|
740
|
|
else
|
|
741
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 00");
|
|
742
|
|
}
|
|
743
|
0
|
if( ! isDecimal( objr)) {
|
|
744
|
0
|
if( objr instanceof String)
|
|
745
|
0
|
objr = string2Decimal( (String)objr);
|
|
746
|
|
else
|
|
747
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 01");
|
|
748
|
|
}
|
|
749
|
0
|
objl = upgradeDecimal( objl, objr);
|
|
750
|
0
|
objr = upgradeDecimal( objr, objl);
|
|
751
|
0
|
if( objl instanceof Integer)
|
|
752
|
0
|
return new Boolean( ((Integer)objl).compareTo((Integer)objr) <= 0);
|
|
753
|
0
|
else if( objl instanceof Double)
|
|
754
|
0
|
return new Boolean( ((Double)objl).compareTo((Double)objr) <= 0);
|
|
755
|
|
else
|
|
756
|
0
|
return new Boolean( ((BigDecimal)objl).compareTo( (BigDecimal)objr) <= 0);
|
|
757
|
0
|
} else if( objl instanceof java.sql.Date || objr instanceof java.sql.Date) {
|
|
758
|
0
|
if( objl instanceof String)
|
|
759
|
0
|
objl = string2Date( (String)objl);
|
|
760
|
0
|
else if( objr instanceof String)
|
|
761
|
0
|
objr = string2Date( (String)objr);
|
|
762
|
|
else
|
|
763
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for logical expression : 02");
|
|
764
|
0
|
return new Boolean( ((java.sql.Date)objl).compareTo( (java.sql.Date)objr) <= 0);
|
|
765
|
0
|
} else if( (objl instanceof String || objr instanceof String) &&
|
|
766
|
|
(objl instanceof Boolean || objr instanceof Boolean)) {
|
|
767
|
0
|
if( objl instanceof Boolean)
|
|
768
|
0
|
objl = objl.toString();
|
|
769
|
0
|
if( objr instanceof Boolean)
|
|
770
|
0
|
objr = objr.toString();
|
|
771
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) <= 0);
|
|
772
|
0
|
} else if( objl instanceof String && objr instanceof String)
|
|
773
|
0
|
return new Boolean( ((String)objl).compareTo( (String)objr) <= 0);
|
|
774
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for less equal");
|
|
775
|
|
}
|
|
776
|
|
|
|
777
|
|
|
|
778
|
|
|
|
779
|
|
|
|
780
|
0
|
public static Object not( Object obj)
|
|
781
|
|
throws Exception {
|
|
782
|
0
|
if( obj instanceof Boolean)
|
|
783
|
0
|
return new Boolean( ! ((Boolean)obj).booleanValue());
|
|
784
|
0
|
else if( obj instanceof SQLNull)
|
|
785
|
0
|
return obj;
|
|
786
|
0
|
else if( obj instanceof String && (((String)obj).equalsIgnoreCase( "true") || ((String)obj).equalsIgnoreCase( "false")))
|
|
787
|
0
|
return new Boolean( ! new Boolean( (String)obj).booleanValue() );
|
|
788
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for not");
|
|
789
|
|
}
|
|
790
|
|
|
|
791
|
|
|
|
792
|
|
|
|
793
|
|
|
|
794
|
0
|
public static Object and( Object objl, Object objr)
|
|
795
|
|
throws Exception {
|
|
796
|
0
|
if( objl instanceof SQLNull)
|
|
797
|
0
|
return objl;
|
|
798
|
0
|
if( objr instanceof SQLNull)
|
|
799
|
0
|
return objr;
|
|
800
|
0
|
if( objl instanceof String &&
|
|
801
|
|
(((String)objl).equalsIgnoreCase( "true") ||
|
|
802
|
|
((String)objl).equalsIgnoreCase( "false")))
|
|
803
|
0
|
objl = new Boolean( (String)objl);
|
|
804
|
0
|
if( objr instanceof String &&
|
|
805
|
|
(((String)objr).equalsIgnoreCase( "true") ||
|
|
806
|
|
((String)objr).equalsIgnoreCase( "false")))
|
|
807
|
0
|
objr = new Boolean( (String)objr);
|
|
808
|
0
|
if( objl instanceof Boolean && objr instanceof Boolean)
|
|
809
|
0
|
return new Boolean( ((Boolean)objl).booleanValue() && ((Boolean)objr).booleanValue());
|
|
810
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for and");
|
|
811
|
|
}
|
|
812
|
|
|
|
813
|
|
|
|
814
|
|
|
|
815
|
|
|
|
816
|
0
|
public static Object or( Object objl, Object objr)
|
|
817
|
|
throws Exception {
|
|
818
|
0
|
if( objl instanceof SQLNull)
|
|
819
|
0
|
return objl;
|
|
820
|
0
|
if( objr instanceof SQLNull)
|
|
821
|
0
|
return objr;
|
|
822
|
0
|
if( objl instanceof String &&
|
|
823
|
|
(((String)objl).equalsIgnoreCase( "true") ||
|
|
824
|
|
((String)objl).equalsIgnoreCase( "false")))
|
|
825
|
0
|
objl = new Boolean( (String)objl);
|
|
826
|
0
|
if( objr instanceof String &&
|
|
827
|
|
(((String)objr).equalsIgnoreCase( "true") ||
|
|
828
|
|
((String)objr).equalsIgnoreCase( "false")))
|
|
829
|
0
|
objr = new Boolean( (String)objr);
|
|
830
|
0
|
if( objl instanceof Boolean && objr instanceof Boolean)
|
|
831
|
0
|
return new Boolean( ((Boolean)objl).booleanValue() || ((Boolean)objr).booleanValue());
|
|
832
|
0
|
throw new mobisnap.MobisnapException( "Invalid input for and");
|
|
833
|
|
}
|
|
834
|
|
|
|
835
|
|
}
|
|
836
|
|
|