gvsig-mssqlserver / trunk / org.gvsig.mssqlserver / org.gvsig.mssqlserver.provider / src / main / java / org / gvsig / mssqlserver / dal / expressionbuilderformatter / MSSQLServerFormatter.java @ 213
History | View | Annotate | Download (2.74 KB)
1 |
/*
|
---|---|
2 |
* To change this license header, choose License Headers in Project Properties.
|
3 |
* To change this template file, choose Tools | Templates
|
4 |
* and open the template in the editor.
|
5 |
*/
|
6 |
package org.gvsig.mssqlserver.dal.expressionbuilderformatter; |
7 |
|
8 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
9 |
import org.gvsig.expressionevaluator.Formatter; |
10 |
import org.gvsig.fmap.dal.SQLBuilder; |
11 |
|
12 |
/**
|
13 |
*
|
14 |
* @author osc
|
15 |
*/
|
16 |
public class MSSQLServerFormatter implements Formatter<ExpressionBuilder.Value> { |
17 |
|
18 |
private final SQLBuilder builder; |
19 |
private final Formatter<ExpressionBuilder.Value>[] formatters; |
20 |
|
21 |
public MSSQLServerFormatter(SQLBuilder builder) {
|
22 |
|
23 |
this.builder = builder;
|
24 |
this.formatters = new Formatter[]{ |
25 |
new ST_AsBinary(this.builder, this), |
26 |
new ST_AsText(this.builder, this), |
27 |
new ST_Contains(this.builder, this), |
28 |
new ST_Crosses(this.builder, this), |
29 |
new ST_Disjoint(this.builder, this), |
30 |
new ST_Envelope(this.builder, this), |
31 |
new ST_Equals(this.builder, this), |
32 |
new ST_ExtentAggregate(this.builder, this), |
33 |
new ST_GeomFromText(this.builder, this), |
34 |
new ST_GeomFromWKB(this.builder, this), |
35 |
new ST_Intersects(this.builder, this), |
36 |
new ST_IsClosed(this.builder, this), |
37 |
new ST_Overlaps(this.builder, this), |
38 |
new ST_SRID(this.builder, this), |
39 |
new ST_Touches(this.builder, this), |
40 |
new ST_UnionAggregate(this.builder, this), |
41 |
new ST_Within(this.builder, this), |
42 |
new MSSQLConstant(this.builder, this), |
43 |
new MSSQLVariable(this.builder, this), |
44 |
new MSSQLParameter(this.builder, this) |
45 |
|
46 |
// new ILike(this.builder, this),
|
47 |
// new IsNull(this.builder, this),
|
48 |
// new IsNotNull(this.builder, this)
|
49 |
// new ST_AsEWKB(this.builder, this),
|
50 |
// new ST_ExtentAggregate(this.builder, this),
|
51 |
// new ST_GeomFromEWKB(this.builder, this),
|
52 |
// new ST_Intersects(this.builder, this),
|
53 |
// new ST_UnionAggregate(this.builder, this)
|
54 |
}; |
55 |
} |
56 |
|
57 |
@Override
|
58 |
public boolean canApply(ExpressionBuilder.Value value) { |
59 |
for (Formatter<ExpressionBuilder.Value> formatter : formatters) { |
60 |
if (formatter.canApply(value)) {
|
61 |
return true; |
62 |
} |
63 |
} |
64 |
return false; |
65 |
} |
66 |
|
67 |
@Override
|
68 |
public String format(ExpressionBuilder.Value value) { |
69 |
for (Formatter<ExpressionBuilder.Value> formatter : formatters) { |
70 |
if (formatter.canApply(value)) {
|
71 |
return formatter.format(value);
|
72 |
} |
73 |
} |
74 |
return value.toString(this); |
75 |
} |
76 |
|
77 |
} |