root / trunk / extensions / extSymbology / src / org / gvsig / remoteClient / sld / filterEncoding / FComparisonOperator.java @ 20768
History | View | Annotate | Download (4.22 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.remoteClient.sld.filterEncoding; |
42 |
|
43 |
import java.io.IOException; |
44 |
import java.util.HashSet; |
45 |
import java.util.Set; |
46 |
|
47 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
48 |
import org.xmlpull.v1.XmlPullParserException; |
49 |
|
50 |
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException; |
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(XMLSchemaParser parser, String tag) throws XmlPullParserException, IOException, LegendDriverException { |
76 |
|
77 |
int currentTag;
|
78 |
boolean end = false; |
79 |
|
80 |
this.comparisonType = tag;
|
81 |
|
82 |
parser.require(XMLSchemaParser.START_TAG, null, tag);
|
83 |
currentTag = parser.next(); |
84 |
|
85 |
while (!end)
|
86 |
{ |
87 |
switch(currentTag)
|
88 |
{ |
89 |
case XMLSchemaParser.START_TAG:
|
90 |
insideExpression =new FExpression();
|
91 |
insideExpression.parse(parser,currentTag,parser.getName()); |
92 |
opExpressionStr += insideExpression.getExpressionStr(); |
93 |
|
94 |
opExpressionStr += FilterUtils.getSymbol4Expression("ogc:"+this.comparisonType) + " "; |
95 |
|
96 |
fieldNames.addAll(insideExpression.getFieldNames()); |
97 |
currentTag = parser.nextTag(); |
98 |
insideExpression2 =new FExpression();
|
99 |
insideExpression2.parse(parser, currentTag,parser.getName()); |
100 |
opExpressionStr += insideExpression2.getExpressionStr(); |
101 |
|
102 |
fieldNames.addAll(insideExpression2.getFieldNames()); |
103 |
parser.nextTag(); |
104 |
if (insideExpression == null || insideExpression2 == null) |
105 |
throw new LegendDriverException(LegendDriverException.PARSE_LEGEND_FILE_ERROR); |
106 |
|
107 |
case XMLSchemaParser.END_TAG:
|
108 |
if (parser.getName().compareTo(tag) == 0) |
109 |
end = true;
|
110 |
break;
|
111 |
case XMLSchemaParser.TEXT:
|
112 |
break;
|
113 |
} |
114 |
if (!end)
|
115 |
currentTag = parser.next(); |
116 |
} |
117 |
|
118 |
parser.require(XMLSchemaParser.END_TAG, null, tag);
|
119 |
|
120 |
} |
121 |
|
122 |
public String getComparisonType() { return comparisonType; } |
123 |
public void setComparisonType(String comparisonType) { this.comparisonType = comparisonType; } |
124 |
public boolean evaluate() { return value; } |
125 |
public Set<String> getFieldNames() { return fieldNames; } |
126 |
public int getHasIntervals() { return hasIntervals; } |
127 |
public FExpression getInsideExpression() { return insideExpression; } |
128 |
public FExpression getInsideExpression2() {return insideExpression2; } |
129 |
public String getOpExpressionStr() {return opExpressionStr;} |
130 |
|
131 |
} |