svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.api / src / main / java / org / gvsig / sldsupport / filterencoding / FComparisonOperator.java @ 40779
History | View | Annotate | Download (4.19 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib��ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.sldsupport.filterencoding; |
42 |
|
43 |
import java.io.IOException; |
44 |
import java.util.HashSet; |
45 |
import java.util.Set; |
46 |
|
47 |
import org.gvsig.sldsupport.exception.SLDReadException; |
48 |
import org.xmlpull.v1.XmlPullParser; |
49 |
import org.xmlpull.v1.XmlPullParserException; |
50 |
|
51 |
/**
|
52 |
* Implements the main functionalities to parse a comparison operator
|
53 |
* of a Filter Encoding expression.<br>
|
54 |
*
|
55 |
* A comparison operator is used to form expressions that evaluate the
|
56 |
* mathematical comparison between two arguments. If the arguments satisfy
|
57 |
* the comparison then the expression evaluates to TRUE.Otherwise the
|
58 |
* expression evaluates to FALSE.
|
59 |
*
|
60 |
* @see http://www.opengeospatial.org/standards/filter
|
61 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
62 |
*/
|
63 |
public class FComparisonOperator { |
64 |
|
65 |
|
66 |
String comparisonType;
|
67 |
FExpression insideExpression; |
68 |
FExpression insideExpression2; |
69 |
Set <String> fieldNames = new HashSet <String>(); |
70 |
boolean value = true; |
71 |
int hasIntervals = 0; |
72 |
protected String opExpressionStr =""; |
73 |
|
74 |
|
75 |
public void parse(XmlPullParser parser, String tag) |
76 |
throws XmlPullParserException, IOException, SLDReadException { |
77 |
|
78 |
int currentTag;
|
79 |
boolean end = false; |
80 |
|
81 |
this.comparisonType = tag;
|
82 |
|
83 |
parser.require(XmlPullParser.START_TAG, null, tag);
|
84 |
currentTag = parser.next(); |
85 |
|
86 |
while (!end)
|
87 |
{ |
88 |
switch(currentTag)
|
89 |
{ |
90 |
case XmlPullParser.START_TAG:
|
91 |
insideExpression =new FExpression();
|
92 |
insideExpression.parse(parser,currentTag,parser.getName()); |
93 |
opExpressionStr += insideExpression.getExpressionStr(); |
94 |
|
95 |
opExpressionStr += FilterUtils.getSymbol4Expression("ogc:"+this.comparisonType) + " "; |
96 |
|
97 |
fieldNames.addAll(insideExpression.getFieldNames()); |
98 |
currentTag = parser.nextTag(); |
99 |
insideExpression2 =new FExpression();
|
100 |
insideExpression2.parse(parser, currentTag,parser.getName()); |
101 |
opExpressionStr += insideExpression2.getExpressionStr(); |
102 |
|
103 |
fieldNames.addAll(insideExpression2.getFieldNames()); |
104 |
parser.nextTag(); |
105 |
if (insideExpression == null || insideExpression2 == null) { |
106 |
throw new SLDReadException(new Exception( |
107 |
"Bad expressions in comparison operator."));
|
108 |
} |
109 |
|
110 |
case XmlPullParser.END_TAG:
|
111 |
if (parser.getName().compareTo(tag) == 0) |
112 |
end = true;
|
113 |
break;
|
114 |
case XmlPullParser.TEXT:
|
115 |
break;
|
116 |
} |
117 |
if (!end)
|
118 |
currentTag = parser.next(); |
119 |
} |
120 |
|
121 |
parser.require(XmlPullParser.END_TAG, null, tag);
|
122 |
|
123 |
} |
124 |
|
125 |
public String getComparisonType() { return comparisonType; } |
126 |
public void setComparisonType(String comparisonType) { this.comparisonType = comparisonType; } |
127 |
public boolean evaluate() { return value; } |
128 |
public Set<String> getFieldNames() { return fieldNames; } |
129 |
public int getHasIntervals() { return hasIntervals; } |
130 |
public FExpression getInsideExpression() { return insideExpression; } |
131 |
public FExpression getInsideExpression2() {return insideExpression2; } |
132 |
public String getOpExpressionStr() {return opExpressionStr;} |
133 |
|
134 |
} |