Statistics
| Revision:

root / trunk / extensions / extSymbology / src / org / gvsig / remoteClient / sld / filterEncoding / FLogicOperatorNot.java @ 20768

History | View | Annotate | Download (5.07 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
/**
53
 * Implements the main functionalities to parse a logical negation 
54
 * operator of a Filter Encoding expression<br>
55
 *  
56
 * The logical negation operator (NOT) reverses the logical value of an 
57
 * expression
58
 *  
59
 * @see http://www.opengeospatial.org/standards/filter
60
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
61
 */
62
public class FLogicOperatorNot {
63

    
64
        FComparisonOperator compOperator = null;
65
        FLogicOperator logicOperators = null; 
66
        Set <String> fieldNames = new HashSet <String>();
67
        String propertyName;
68
        int numOperators = 0;
69
        String opExpressionStr = "";
70

    
71

    
72
        public void parse(XMLSchemaParser parser , String tag) throws XmlPullParserException, IOException, LegendDriverException {
73

    
74
                int currentTag;
75
                boolean end = false;
76
                currentTag = parser.next();
77

    
78

    
79
                while (!end)
80
                {
81
                        switch(currentTag)
82
                        {
83
                        case XMLSchemaParser.START_TAG:
84
                                if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISEQUALTO))==0 ||
85
                                                parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISNOTEQUALTO))==0 ||
86
                                                parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISLESSTHAN))==0 ||
87
                                                parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISGREATERTHAN))==0 ||
88
                                                parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISLESSOREQUALTHAN))==0 ||
89
                                                parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISGREATEROREQUALTHAN))==0)  {
90

    
91
                                        if(parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISEQUALTO))!=0 &&
92
                                                        parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYISNOTEQUALTO))!=0 ){
93
                                        }
94

    
95
                                        compOperator = new FComparisonOperator();
96
                                        opExpressionStr +="( ";
97
                                        compOperator.parse(parser ,parser.getName());        
98
                                        opExpressionStr += compOperator.getOpExpressionStr();
99
                                        opExpressionStr += ") ";
100

    
101
                                        fieldNames.addAll(compOperator.getFieldNames());
102
                                        numOperators++;
103

    
104

    
105
                                }
106
                                else if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.AND))==0 ||
107
                                                parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.OR))==0){
108
                                        logicOperators = new FLogicOperator();
109
                                        opExpressionStr +="( ";
110
                                        logicOperators.parse(parser,parser.getName());
111
                                        opExpressionStr += logicOperators.getOpExpressionStr();
112
                                        opExpressionStr +=") ";
113

    
114
                                        fieldNames.addAll(logicOperators.getFieldNames());
115
                                        numOperators++;
116

    
117
                                        if (logicOperators.getNumOperators() < 2)
118
                                                throw new LegendDriverException(LegendDriverException.PARSE_LEGEND_FILE_ERROR);
119

    
120

    
121
                                }
122
                                else if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.NOT))==0) {
123
                                        FLogicOperatorNot notlogicOperators = new FLogicOperatorNot();
124
                                        opExpressionStr +="( "+"Not ";
125
                                        notlogicOperators.parse(parser,parser.getName());
126
                                        opExpressionStr += notlogicOperators.getOpExpressionStr();
127
                                        opExpressionStr +=") ";
128

    
129
                                        fieldNames.addAll(notlogicOperators.getFieldNames());
130
                                        numOperators++;
131
                                }
132

    
133

    
134
                                break;
135
                        case XMLSchemaParser.END_TAG:
136
                                if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.NOT)) == 0)
137
                                        end = true;
138
                                break;
139
                        case XMLSchemaParser.TEXT:
140
                                break;
141
                        }
142
                        if (!end)
143
                                currentTag = parser.next();
144
                }
145

    
146
                parser.require(XMLSchemaParser.END_TAG, null, FilterTags.NOT);
147

    
148
        }
149

    
150
        public int getNumOperators() { return numOperators; }
151
        public Set<String> getFieldNames() { return fieldNames; }
152
        public String getOpExpressionStr() {return opExpressionStr;}
153

    
154

    
155
}
156

    
157