svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.h2 / src / main / java / org / gvsig / fmap / dal / store / h2 / expressionbuilderformatter / ST_ExtentAggregate.java @ 44750
History | View | Annotate | Download (1.46 KB)
1 | 44198 | jjdelcerro | package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter; |
---|---|---|---|
2 | |||
3 | import java.text.MessageFormat; |
||
4 | import java.util.List; |
||
5 | import org.apache.commons.lang3.StringUtils; |
||
6 | 44748 | jjdelcerro | import org.apache.commons.lang3.tuple.Pair; |
7 | 44198 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionBuilder; |
8 | 44644 | jjdelcerro | import static org.gvsig.expressionevaluator.GeometryExpressionBuilder.FUNCTION_ST_EXTENTAGGREGATE; |
9 | 44198 | jjdelcerro | 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 | |||
14 | /**
|
||
15 | *
|
||
16 | * @author jjdelcerro
|
||
17 | */
|
||
18 | 44268 | omartinez | public class ST_ExtentAggregate implements Formatter<Value> { |
19 | 44198 | jjdelcerro | |
20 | private final SQLBuilder sqlbuilder; |
||
21 | private final Formatter<Value> formatter; |
||
22 | |||
23 | 44268 | omartinez | public ST_ExtentAggregate(SQLBuilder sqlbuilder, Formatter<Value> formatter) { |
24 | 44198 | jjdelcerro | this.sqlbuilder = sqlbuilder;
|
25 | this.formatter = formatter;
|
||
26 | } |
||
27 | @Override
|
||
28 | public boolean canApply(ExpressionBuilder.Value value) { |
||
29 | if (value instanceof ExpressionBuilder.Function) { |
||
30 | 44268 | omartinez | return StringUtils.equalsIgnoreCase(FUNCTION_ST_EXTENTAGGREGATE, ((Function) value).name());
|
31 | 44198 | jjdelcerro | } |
32 | return false; |
||
33 | } |
||
34 | |||
35 | @Override
|
||
36 | public String format(Value function) { |
||
37 | 44750 | jjdelcerro | List<Value> parameters = ((Function) function).parameters();
|
38 | String p1 = parameters.get(0).toString(formatter); |
||
39 | 44268 | omartinez | String r = MessageFormat.format("ST_Extent({0})", p1); |
40 | 44198 | jjdelcerro | return r;
|
41 | } |
||
42 | |||
43 | } |