svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.lib / org.gvsig.expressionevaluator.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / function / predicate / IlikeOperator.java @ 44262
History | View | Annotate | Download (1.1 KB)
1 | 43512 | jjdelcerro | package org.gvsig.expressionevaluator.impl.function.predicate; |
---|---|---|---|
2 | |||
3 | 44207 | jjdelcerro | import static org.gvsig.expressionevaluator.ExpressionBuilder.OPERATOR_ILIKE; |
4 | 43521 | jjdelcerro | import org.gvsig.expressionevaluator.Function; |
5 | import org.gvsig.expressionevaluator.Interpreter; |
||
6 | 43512 | jjdelcerro | import org.gvsig.expressionevaluator.impl.function.operator.AbstractBinaryOperator; |
7 | |||
8 | public class IlikeOperator extends AbstractBinaryOperator { |
||
9 | |||
10 | public IlikeOperator() {
|
||
11 | 44207 | jjdelcerro | super(Function.GROUP_STRING, OPERATOR_ILIKE, true); |
12 | 43512 | jjdelcerro | } |
13 | |||
14 | @Override
|
||
15 | 44009 | jjdelcerro | public boolean allowConstantFolding() { |
16 | return true; |
||
17 | } |
||
18 | |||
19 | @Override
|
||
20 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object op1, Object op2) { |
21 | 43512 | jjdelcerro | if( op1 instanceof CharSequence && op2 instanceof CharSequence ) { |
22 | boolean value = ilike(((CharSequence) op1).toString(), ((CharSequence) op2).toString()); |
||
23 | return value;
|
||
24 | } |
||
25 | throw new IllegalArgumentException("Types not allowed in '"+name()+"' operand."); |
||
26 | } |
||
27 | |||
28 | public static boolean ilike(String op1, String op2) { |
||
29 | return LikeOperator.like(op1.toLowerCase(),op2.toLowerCase());
|
||
30 | } |
||
31 | |||
32 | } |