gvsig-oracle / org.gvsig.oracle / trunk / org.gvsig.oracle / org.gvsig.oracle.provider / src / main / java / org / gvsig / oracle / dal / expressionbuilderformatter / Or.java @ 166
History | View | Annotate | Download (1.42 KB)
1 |
package org.gvsig.oracle.dal.expressionbuilderformatter; |
---|---|
2 |
|
3 |
import java.text.MessageFormat; |
4 |
import java.util.List; |
5 |
import org.apache.commons.lang3.StringUtils; |
6 |
|
7 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
8 |
import org.gvsig.expressionevaluator.ExpressionBuilder.BinaryOperator; |
9 |
import org.gvsig.expressionevaluator.ExpressionBuilder.Function; |
10 |
import org.gvsig.expressionevaluator.ExpressionBuilder.Value; |
11 |
import org.gvsig.expressionevaluator.Formatter; |
12 |
import org.gvsig.fmap.dal.SQLBuilder; |
13 |
import org.gvsig.oracle.dal.OracleSQLBuilder; |
14 |
|
15 |
/**
|
16 |
*
|
17 |
* @author jjdelcerro
|
18 |
*/
|
19 |
class Or implements Formatter<Value> { |
20 |
|
21 |
private final Formatter<Value> formatter; |
22 |
private final SQLBuilder builder; |
23 |
|
24 |
public Or(SQLBuilder builder, Formatter<Value> formatter) { |
25 |
this.builder = builder;
|
26 |
this.formatter = formatter;
|
27 |
} |
28 |
|
29 |
@Override
|
30 |
public boolean canApply(Value value) { |
31 |
if (value instanceof BinaryOperator) { |
32 |
return StringUtils.equalsIgnoreCase(ExpressionBuilder.OPERATOR_OR, ((BinaryOperator) value).name());
|
33 |
} |
34 |
return false; |
35 |
} |
36 |
|
37 |
@Override
|
38 |
public String format(Value function) { |
39 |
List<Value> parameters = ((Function) function).parameters();
|
40 |
String p1 = parameters.get(0).toString(formatter); |
41 |
String p2 = parameters.get(1).toString(formatter); |
42 |
String r = MessageFormat.format(OracleSQLBuilder.FORMAT_OPERATOR_OR, p1, p2); |
43 |
return r;
|
44 |
} |
45 |
|
46 |
} |