svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.impl / src / main / java / org / gvsig / sldsupport / impl / sld1_0_0 / parsing / expression / ExpressionElement.java @ 40794
History | View | Annotate | Download (2.23 KB)
1 |
package org.gvsig.sldsupport.impl.sld1_0_0.parsing.expression; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.gvsig.sldsupport.exception.SLDReadException; |
6 |
import org.gvsig.sldsupport.impl.filter.DefaultSLDFilter; |
7 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.spatial.BBoxOperatorElement; |
8 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.spatial.BinarySpatialOperatorElement; |
9 |
import org.gvsig.sldsupport.impl.util.SLDUtils; |
10 |
import org.gvsig.sldsupport.sld.SLDTags; |
11 |
import org.gvsig.sldsupport.sld.filter.FilterTags; |
12 |
import org.gvsig.sldsupport.sld.filter.SLDFilter; |
13 |
import org.gvsig.sldsupport.sld.filter.SLDFilterOperator; |
14 |
import org.gvsig.sldsupport.sld.filter.expression.SLDExpression; |
15 |
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDLiteral; |
16 |
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDPropertyName; |
17 |
import org.gvsig.sldsupport.sld.filter.operator.spatial.SLDBinarySpatialOperator; |
18 |
import org.gvsig.sldsupport.sld.filter.operator.spatial.SLDDistanceBufferOperator; |
19 |
import org.kxml2.io.KXmlParser; |
20 |
import org.xmlpull.v1.XmlPullParser; |
21 |
import org.xmlpull.v1.XmlPullParserException; |
22 |
|
23 |
public class ExpressionElement { |
24 |
|
25 |
public static SLDExpression parse(XmlPullParser parser , String version) |
26 |
throws XmlPullParserException, IOException, SLDReadException { |
27 |
|
28 |
String name = parser.getName();
|
29 |
|
30 |
if (SLDUtils.isStr(name, FilterTags.PROPERTYNAME)) {
|
31 |
SLDPropertyName pn = new SLDPropertyName();
|
32 |
String txt = parser.nextText();
|
33 |
pn.setPropertyName(txt); |
34 |
// Go to next tag
|
35 |
parser.next(); |
36 |
return pn;
|
37 |
} |
38 |
|
39 |
if (SLDUtils.isStr(name, FilterTags.LITERAL)) {
|
40 |
SLDLiteral lit = new SLDLiteral();
|
41 |
String txt = parser.nextText();
|
42 |
lit.setValue(txt); |
43 |
// Go to next tag
|
44 |
parser.next(); |
45 |
return lit;
|
46 |
} |
47 |
|
48 |
if (SLDUtils.isStr(name, FilterTags.ADD)
|
49 |
|| SLDUtils.isStr(name, FilterTags.SUB) |
50 |
|| SLDUtils.isStr(name, FilterTags.MUL) |
51 |
|| SLDUtils.isStr(name, FilterTags.DIV)) { |
52 |
return ArithmeticElement.parse(parser, version);
|
53 |
} |
54 |
|
55 |
if (SLDUtils.isStr(name, FilterTags.FUNCTION)) {
|
56 |
return FunctionElement.parse(parser, version);
|
57 |
} |
58 |
|
59 |
throw new SLDReadException("Unexpected entity in expression: " + name); |
60 |
|
61 |
|
62 |
} |
63 |
} |