Revision 141

View differences:

org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/buildNumber.properties
1
#Thu Apr 02 16:17:31 CEST 2015
2
buildNumber=2094
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25
<!--
26
  <dependencySets>
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
      <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes>
32
        <include>org.gvsig:org.gvsig.wfs.app.mainplugin</include>
33
      </includes>
34
    </dependencySet>
35
  </dependencySets>
36
-->
37

  
38
</assembly>
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/WFSServiceInformation.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs;
25

  
26
import java.util.HashMap;
27
import java.util.Iterator;
28
import java.util.Vector;
29

  
30
import org.gvsig.remoteclient.ogc.OGCClientOperation;
31
import org.gvsig.remoteclient.ogc.OGCServiceInformation;
32

  
33
/**
34
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
35
 */
36
public class WFSServiceInformation extends OGCServiceInformation{
37
	public String version;
38
	public String name;
39
	public String scope;
40
	public String title;
41
	public String abstr;
42
	public String keywords;
43
	public String fees;
44
	public String operationsInfo;
45
	public String personname;
46
	public String organization;
47
	public String function;
48
	public String addresstype;
49
	public String address;
50
	public String place;
51
	public String province;
52
	public String postcode;
53
	public String country;
54
	public String phone;
55
	public String fax;
56
	public String email;
57
	public Vector formats;
58
	private HashMap operationsGet; 
59
	private HashMap operationsPost; 
60
	private HashMap namespaces;
61
	private int maxFeatures = -1;
62

  
63
    public WFSServiceInformation() {  	
64
		clear();     
65
	}
66

  
67
	public void clear() {
68
		version = new String();
69
		name = new String();
70
		scope = new String();
71
		title = new String();
72
		abstr = new String();
73
		keywords = new String();
74
		fees = new String();
75
		operationsInfo = new String();
76
		personname = new String();
77
		organization = new String();
78
		function = new String();
79
		addresstype = new String();
80
		address = new String();
81
		place = new String();
82
		province = new String();
83
		postcode = new String();
84
		country = new String();
85
		phone = new String();
86
		fax = new String();
87
		email = new String();
88
		formats = new Vector();       	
89
		operationsGet = new HashMap();  
90
		operationsPost = new HashMap();   
91
		namespaces = new HashMap();
92
	}
93
	
94
	/**
95
	 * Adds a new namespace
96
	 * @param namespacePrefix
97
	 * Namespace prefix
98
	 * @param namespaceURI
99
	 * Namespace URI
100
	 */
101
	public void addNamespace(String namespacePrefix, String namespaceURI){
102
		namespaces.put(namespacePrefix, namespaceURI);
103
	}
104
	
105
	/**
106
	 * Gest a namespace URI
107
	 * @param namespaceprefix
108
	 * Namespace prefix
109
	 * @return
110
	 * The namespace URI
111
	 */
112
	public String getNamespace(String namespaceprefix){
113
		if (namespaces.containsKey(namespaceprefix)){
114
			return (String)namespaces.get(namespaceprefix);
115
		}
116
		return null;
117
	}
118
	
119
	public String getNamespacePrefix(String namespace){
120
        if (namespace == null){
121
            return null;
122
        }
123
	    Iterator it = namespaces.keySet().iterator();
124
        while (it.hasNext()){
125
            String prefix = (String)it.next();
126
            if (namespace.equals(namespaces.get(prefix))){
127
                return prefix;
128
            }
129
        }
130
        return null;
131
    }
132

  
133
	/* (non-Javadoc)
134
	 * @see org.gvsig.remoteClient.ogc.OGCServiceInformation#createOperation(java.lang.String)
135
	 */	
136
	public OGCClientOperation createOperation(String name) {
137
		return new WFSOperation(name); 
138
	}
139

  
140
	/* (non-Javadoc)
141
	 * @see org.gvsig.remoteClient.ogc.OGCServiceInformation#createOperation(java.lang.String, java.lang.String)
142
	 */	
143
	public OGCClientOperation createOperation(String name, String onlineResource) {
144
		return new WFSOperation(name, onlineResource);
145
	}	
146
	
147
   
148
    
149
    /**
150
     * @return the maxFeatures
151
     */
152
    public int getMaxFeatures() {
153
        return maxFeatures;
154
    }
155

  
156
    
157
    /**
158
     * @param maxFeatures the maxFeatures to set
159
     */
160
    public void setMaxFeatures(int maxFeatures) {
161
        this.maxFeatures = maxFeatures;
162
    }
163
}
164

  
0 165

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/FilterEncoding.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.remoteclient.wfs.filters.filterencoding;
26
import java.util.ArrayList;
27
import java.util.Hashtable;
28
import java.util.Iterator;
29
import java.util.Set;
30

  
31
import org.gvsig.compat.CompatLocator;
32
import org.gvsig.compat.lang.StringUtils;
33
import org.gvsig.remoteclient.wfs.WFSStatus;
34
import org.gvsig.remoteclient.wfs.edition.WFSTTags;
35
import org.gvsig.remoteclient.wfs.filters.AbstractFilter;
36
import org.gvsig.remoteclient.wfs.filters.BinaryTree;
37
import org.gvsig.remoteclient.wfs.filters.BinaryTree.Node;
38
import org.gvsig.remoteclient.wfs.filters.DefaultSQLExpressionFormat;
39
import org.gvsig.remoteclient.wfs.filters.ISQLExpressionFormat;
40
import org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_0_0.EnvelopeFEQuery1_0_0;
41
import org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_0_0.GeometryFEQuery_1_0_0;
42
import org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_1_0.EnvelopeFEQuery1_1_0;
43
import org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_1_0.GeometryFEQuery_1_1_0;
44
import org.gvsig.remoteclient.wfs.filters.operations.WFSEnvelopeFilterOperation;
45
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation;
46
import org.gvsig.remoteclient.wfs.filters.operations.WFSSpatialFilterOperation;
47

  
48
/**
49
 * This class implements the Filter Encoding Language. It is used to
50
 * create querys in this language
51
 *
52
 * Name: OpenGIS? Filter Encoding Implementation Specification
53
 * Version: 1.1.0
54
 * Project Document: OGC 04-095
55
 * @see http://portal.opengeospatial.org/files/?artifact_id=8340
56
 *
57
 * @author Jorge Piera Llodra (piera_jor@gva.es)
58
 */
59
public class FilterEncoding extends AbstractFilter {
60
    public static final int RELATIONSHIP_PROPERTY = 0;
61
    public static final int RELATIONSHIP_VAUES = 1;
62

  
63
    private StringBuffer currentQuery = null;
64
    //Operation types
65
    private static final int OPERATION_PROPERTYNAME = 0;
66
    private static final int OPERATION_LITERAL = 1;
67

  
68
    //Filter namespace.
69
    private String nameSpacePrefix = null;
70
    private String nameSpaceLocation = null;
71

  
72
    //If the Filter can have blanckSpaces
73
    private boolean hasBlankSpaces = true;
74
    private String defaultBlankSpace = "%20";
75
    //This character must be replaced by any set of characters (typically "*")
76
    private String wildCardChar = null;
77
    //This character must be replaced by one character (typically "?")
78
    private String singleChar = null;
79
    //Escape character (typically "\")
80
    private String escapeChar = null;
81
    //Default values
82
    public static final String DEFAULT_NAMESPACE_PREFIX = "ogc";
83
    public static final String DEFAULT_WILDCARD = "*";
84
    public static final String DEFAULT_SINGLECHAR = "?";
85
    public static final String DEFAULT_ESCAPE = "\\";
86
    public static final String DEFAULT_NAMESPACE = "xmlns:ogc=\"http://www.opengis.net/ogc\"";
87

  
88
    private Hashtable filterAttributes = new Hashtable();
89

  
90
    /**
91
     * If the namespace XML is qualified
92
     */
93
    private boolean isQualified = false;
94

  
95
    private static final StringUtils stringUtils = CompatLocator.getStringUtils();
96

  
97
    /**
98
     * Create a new Filter Encoding Parser
99
     *
100
     *
101
     * @param nameSpacePrefix
102
     * Filter namespace. (typically "ogc")
103
     * @param wildCardChar
104
     * This character must be replaced by any set of characters (typically "*")
105
     * @param singleChar
106
     * This character must be replaced by one character (typically "?")
107
     * @param escape
108
     * Escape character
109
     * @param filterAttribute Sometimes, "Field" label needs an attribute.
110
     */
111
    public FilterEncoding(ISQLExpressionFormat formatter,String namesPacePrefix, String wildCard, String singleChar, String escape, Hashtable filterAttributes) {
112
        super(formatter);
113
        if (namesPacePrefix == null){
114
            setQualified(false);
115
        }else{
116
            setQualified(true);
117
        }
118
        this.wildCardChar = wildCard;
119
        this.singleChar = singleChar;
120
        this.escapeChar = escape;
121
        this.filterAttributes = filterAttributes;
122
    }
123

  
124

  
125
    /**
126
     * Create a new Filter Encoding Parser
127
     * @param formatter
128
     */
129
    public FilterEncoding(ISQLExpressionFormat formatter) {
130
        this(formatter,null,DEFAULT_WILDCARD,DEFAULT_SINGLECHAR,
131
            DEFAULT_ESCAPE,new Hashtable());
132
    }
133

  
134
    /**
135
     * Create a new Filter Encoding Parser
136
     */
137
    FilterEncoding() {
138
        this(new DefaultSQLExpressionFormat());
139
    }
140

  
141
    /**
142
     * Create a new Filter Encoding Parser
143
     */
144
    public FilterEncoding(WFSStatus status) {
145
        this();
146
        this.nameSpacePrefix = status.getNamespacePrefix();
147
        this.nameSpaceLocation = status.getNamespaceLocation();
148
        setQueryByAttribute(status.getFilterByAttribute());
149
        clearSpatialFilters();
150
        addSpatialFilter(status.getFilterByArea());
151
    }
152

  
153
    /*
154
     *  (non-Javadoc)
155
     * @see org.gvsig.remoteClient.filterEncoding.QueryLanguage#toString(org.gvsig.remoteClient.filterEncoding.BinaryTree)
156
     */
157
    public String toString(BinaryTree tree, String version) {
158
        //If is a filter by ids...
159
        StringBuffer idQuery = null;
160
        if (getIds() != null){
161
            idQuery = new StringBuffer();
162
            ArrayList ids = getIds();
163
            for (int i=0 ; i<ids.size() ; i++){
164
                if (ids.get(i) != null){
165
                    Hashtable attributes = new Hashtable();
166
                    attributes.put("fid","\"" + ids.get(i).toString() + "\"");
167
                    idQuery.append(setTag("FeatureId", attributes, null));
168
                }
169
            }
170
            return enclosesWithFilterTag(idQuery.toString(), version);
171
        }
172
        //If is a filter by attributes...
173
        String filterQuery = null;
174
        if ((tree.getRoot() == null) && (getSpatialFiltersCount() == 0)){
175
            return null;
176
        }
177
        if (tree.getRoot() != null){
178
            currentQuery = new StringBuffer();
179
            filterQuery = getFilterNode(tree.getRoot());
180
            if (getSpatialFiltersCount() == 0){
181
                return enclosesWithFilterTag(filterQuery, version);
182
            }
183
        }
184
        //If is a filter by area
185
        String bboxQuery = null;
186
        if (getSpatialFiltersCount() > 0){
187
            for (int i=0 ; i<getSpatialFiltersCount() ; i++){
188
                WFSSpatialFilterOperation spatialFilter = getSpatialFilterAt(i);
189
                SpatialFEQuery feQuery = null;
190
                if (spatialFilter instanceof WFSGeometryFilterOperation){
191
                    if (version.equals("1.0.0")){
192
                    	feQuery = new GeometryFEQuery_1_0_0((WFSGeometryFilterOperation)spatialFilter);
193
                    }else{
194
                        feQuery = new GeometryFEQuery_1_1_0((WFSGeometryFilterOperation)spatialFilter);
195
                    }
196
                }else if (spatialFilter instanceof WFSEnvelopeFilterOperation){
197
                    //TODO add this for a manager
198
                    if (version.equals("1.0.0")){
199
                        feQuery = new EnvelopeFEQuery1_0_0((WFSEnvelopeFilterOperation)spatialFilter);
200
                    }else{
201
                        feQuery = new EnvelopeFEQuery1_1_0((WFSEnvelopeFilterOperation)spatialFilter);
202
                    }
203
                }
204
                //If there is a spatial query
205
                if (feQuery != null){
206
                    bboxQuery = feQuery.getFilterEncoding();
207
                    if (tree.getRoot() == null){
208
                        String filter_bbox = enclosesWithFilterTag(bboxQuery, version);
209
                        return filter_bbox;
210
                    }
211
                }
212
            }
213
        }
214
        return enclosesWithFilterTag(filterQuery + bboxQuery, version);
215
    }
216

  
217
    /**
218
     * Gets the filter code from a node
219
     * @param node
220
     */
221
    private String getFilterNode(Node node){
222
        if (node.isField()){
223
            return getExpression(node.getValue());
224
        }else{
225
            String left = "";
226
            String rigth = "";
227
            if (node.getLeftNode() != null){
228
                left = getFilterNode(node.getLeftNode());
229
            }
230
            if (node.getRigthNode() != null){
231
                rigth = getFilterNode(node.getRigthNode());
232
            }
233
            int operationCode = getLogicalOperator(node.getValue());
234
            String operation = getLogicalOperator(operationCode);
235
            return enterLabel(left+rigth, operation);
236
        }
237
    }
238

  
239
    /**
240
     * Parses a expresion like 'A op B' and returns the
241
     * expresion using the filter encoding language
242
     * @param expression
243
     * @return
244
     */
245
    private String getExpression(String expression){
246
        String[] words = stringUtils.split(expression, " ");
247
        //Param
248
        String param = words[0];
249
        if (param.charAt(0) == '"'){
250
            param = param.substring(1,param.length());
251
        }
252
        if (param.charAt(param.length()-1) == '"'){
253
            param = param.substring(0,param.length()-1);
254
        }
255
        //Operator
256
        String operator = words[1];
257
        //Value
258
        String value = words[2];
259
        for (int i=3 ; i<words.length ; i++){
260
            value = value + " " + words[i];
261
        }
262
        if (value.charAt(0) == '\''){
263
            value = value.substring(1,value.length());
264
        }
265
        if (value.charAt(value.length()-1) == '\''){
266
            value = value.substring(0,value.length()-1);
267
        }
268
        int operatorCode = getRelationalOperator(operator);
269
        operator = getRelationalOperator(operatorCode);
270
        return createExpression(operator,param,value);
271
    }
272

  
273
    /**
274
     * It writes a "PropertyIsXXX" part of a filtyer encoding query
275
     *
276
     *
277
     * @return The part of the query
278
     * @param property Possible Values: PropertIsLike, PropertyIsLess, PropertyIsGreater,... See
279
     * the Filter Encoding documentation
280
     * @param parameter Parameter name
281
     * @param value Parameter value
282
     * @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property
283
     * and one literal value)
284
     */
285
    private String createExpression(String property, String parameter, String value) {
286
        String cadena = "";
287
        cadena = "<" + WFSTTags.OGC_NAMESPACE_PREFIX + ":" + property;
288
        if (property.equals("PropertyIsLike")) {
289
            if (wildCardChar != null) {
290
                cadena = cadena + " wildCard=\"" + this.wildCardChar + "\"";
291
            }
292
            if (singleChar != null) {
293
                cadena = cadena + " singleChar=\"" + this.singleChar + "\"";
294
            }
295
            if (escapeChar != null) {
296
                cadena = cadena + " escape=\"" + this.escapeChar + "\"";
297
            }
298
        }
299
        cadena = cadena + ">" + enterLabel(nameSpacePrefix + ":" + parameter, "PropertyName");
300
        cadena = cadena + enterLabel(value, "Literal");
301
        return cadena + "</" + WFSTTags.OGC_NAMESPACE_PREFIX + ":" + property + ">";
302
    }
303

  
304
    /**
305
     * Envuelve a una pregunta con una etiqueta
306
     *
307
     *
308
     * @return String : parte de la query en el lenguaje soportado
309
     * @param pregunta Pregunta a envolver
310
     * @param etiqueta Nombre de la etiqueta
311
     */
312
    private String enterLabel(String value, String tagName) {
313
        if (tagName.equals("Filter") && (!(filterAttributes.isEmpty()))) {
314
            return setTag(tagName,filterAttributes,value);
315
        } else {
316
            return setTag(tagName,null,value);
317
        }
318
    }
319

  
320
    /**
321
     * Envolves a value with an XML tag
322
     *
323
     * @return String
324
     * XML tag with its value
325
     * @param tagName
326
     * XML tag name
327
     * @param attributes
328
     * XML tag attributes
329
     * @param value
330
     * Tag value
331
     */
332
    public String setTag(String tagName, Hashtable attributes, String value) {
333
        StringBuffer tag = new StringBuffer();
334

  
335
        tag.append("<");
336
        tag.append(WFSTTags.OGC_NAMESPACE_PREFIX + ":");
337
        tag.append(tagName);
338
        if (attributes != null){
339
            Set keys = attributes.keySet();
340
            if (attributes.size() > 0){
341
                Iterator it = keys.iterator();
342
                while (it.hasNext()){
343
                    String key = (String)it.next();
344
                    if (hasBlankSpaces){
345
                        tag.append(" ");
346
                    }else{
347
                        tag.append(defaultBlankSpace);
348
                    }
349
                    tag.append(key + "=" + (String)attributes.get(key));
350

  
351
                }
352
            }
353
        }
354
        if (value == null){
355
            tag.append("/>");
356
        }else{
357
            tag.append(">" + value);
358
            tag.append("</");
359
            tag.append(WFSTTags.OGC_NAMESPACE_PREFIX + ":");
360
            tag.append(tagName);
361
            tag.append(">");
362
        }
363
        return tag.toString();
364
    }
365

  
366

  
367
    /**
368
     * Encloses a query with the filter tag
369
     * @param query
370
     * @return
371
     */
372
    private String enclosesWithFilterTag(String query, String version){
373
        StringBuffer filter = new StringBuffer();
374
        filter.append("<ogc:Filter");
375
        if (!isQualified){
376
            filter.append(" ");
377
            addNamespace(filter, WFSTTags.OGC_NAMESPACE_PREFIX, WFSTTags.OGC_NAMESPACE);
378
            addNamespace(filter, WFSTTags.GML_NAMESPACE_PREFIX, WFSTTags.GML_NAMESPACE);
379
            if (nameSpacePrefix != null){
380
                addNamespace(filter, nameSpacePrefix, nameSpaceLocation);
381
            }
382
            filter.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
383
            filter.append("xsi:schemaLocation=\"http://www.opengis.net/ogc ../filter/".concat(version).concat("/filter.xsd http://www.opengis.net/gml ../gml/2.1.2/geometry.xsd\""));
384
        }
385
        filter.append(">");
386
        filter.append(query);
387
        filter.append("</ogc:Filter>");
388
        return filter.toString();
389
    }
390

  
391
    private void addNamespace(StringBuffer buffer, String nameSpacePrefix, String nameSpaceLocation){
392
        buffer.append(WFSTTags.XMLNS + ":" + nameSpacePrefix + "=\"" + nameSpaceLocation + "\" ");
393
    }
394

  
395
    /*
396
     *  (non-Javadoc)
397
     * @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getLogicOperator(int)
398
     */
399
    public String getLogicalOperator(int operator) {
400
        switch (operator){
401
        case LOGICAL_OPERATOR_AND:
402
            return "And";
403
        case LOGICAL_OPERATOR_OR:
404
            return "Or";
405
        case LOGICAL_OPERATOR_NOT:
406
            return "Not";
407
        default:
408
            return "And";
409
        }
410
    }
411

  
412
    /*
413
     *  (non-Javadoc)
414
     * @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getRelationalOperator(int)
415
     */
416
    public String getRelationalOperator(int operator) {
417
        switch (operator){
418
        case RELATIONAL_OPERATOR_IS_EQUALS_TO:
419
            return "PropertyIsEqualTo";
420
        case RELATIONAL_OPERATOR_IS_NOT_EQUALS_TO:
421
            return "PropertyIsNotEqualTo";
422
        case RELATIONAL_OPERATOR_IS_LESS_THAN:
423
            return "PropertyIsLessThan";
424
        case RELATIONAL_OPERATOR_IS_GREATER_THAN:
425
            return "PropertyIsGreaterThan";
426
        case RELATIONAL_OPERATOR_IS_LESS_THAN_OR_EQUAL_TO:
427
            return "PropertyIsLessThanOrEqualTo";
428
        case RELATIONAL_OPERATOR_IS_GREATER_THAN_OR_EQUAL_TO:
429
            return "PropertyIsGreaterThanOrEqualTo";
430
        case RELATIONAL_OPERATOR_IS_LIKE:
431
            return "PropertyIsLike";
432
        case RELATIONAL_OPERATOR_IS_NULL:
433
            return "PropertyIsNull";
434
        case RELATIONAL_OPERATOR_IS_BETWEEN:
435
            return "PropertyIsBetween";
436
        default:
437
            return "PropertyIsLike";
438
        }
439
    }
440

  
441
    /*
442
     *  (non-Javadoc)
443
     * @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getGeometricOperator(int)
444
     */
445
    public String getGeometricOperator(int operator) {
446
        switch (operator){
447
        case GEOMETRIC_OPERATOR_EQUALS:
448
            return "Equals";
449
        case GEOMETRIC_OPERATOR_DISJOINT:
450
            return "Disjoint";
451
        case GEOMETRIC_OPERATOR_TOUCHES:
452
            return "Touches";
453
        case GEOMETRIC_OPERATOR_WITHIN:
454
            return "Within";
455
        case GEOMETRIC_OPERATOR_OVERLAPS:
456
            return "Overlaps";
457
        case GEOMETRIC_OPERATOR_CROSSES:
458
            return "Crosses";
459
        case GEOMETRIC_OPERATOR_INTERSECT:
460
            return "Intersect";
461
        case GEOMETRIC_OPERATOR_CONTAINS:
462
            return "Contains";
463
        case GEOMETRIC_OPERATOR_DWITHIN:
464
            return "Dwithin";
465
        case GEOMETRIC_OPERATOR_BEYOND:
466
            return "Beyond";
467
        case GEOMETRIC_OPERATOR_BBOX:
468
            return "BBOX";
469
        default:
470
            return "Equals";
471
        }
472

  
473
    }
474

  
475
    public String getSeparator(int separator) {
476
        return null;
477
    }
478

  
479
    /**
480
     * @param isQualified the isQualified to set
481
     */
482
    public void setQualified(boolean isQualified) {
483
        this.isQualified = isQualified;
484
        if (isQualified){
485
            nameSpacePrefix = DEFAULT_NAMESPACE_PREFIX + ":";
486
        }else{
487
            nameSpacePrefix = "";
488
        }
489
    }
490

  
491

  
492
    /**
493
     * @param namepacePrefix the namepacePrefix to set
494
     */
495
    public void setNamepacePrefix(String namepacePrefix) {
496
        if ((namepacePrefix == null) || (namepacePrefix.equals(""))){
497
            this.nameSpacePrefix = "";
498
        }else{
499
            this.nameSpacePrefix = namepacePrefix + ":";
500
        }
501
    }
502

  
503

  
504
    /**
505
     * @param hasBlankSpaces the hasBlankSpaces to set
506
     */
507
    public void setHasBlankSpaces(boolean hasBlankSpaces) {
508
        this.hasBlankSpaces = hasBlankSpaces;
509
    }
510
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/GeometryFEQuery.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.remoteclient.wfs.filters.filterencoding;
26

  
27
import java.awt.geom.PathIterator;
28

  
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.Geometry.TYPES;
31
import org.gvsig.fmap.geom.primitive.GeneralPathX;
32
import org.gvsig.fmap.geom.primitive.Surface;
33
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation;
34

  
35
/**
36
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
37
 */
38
public abstract class GeometryFEQuery extends SpatialFEQuery{
39
	protected Geometry geometry = null;
40

  
41
	public GeometryFEQuery(WFSGeometryFilterOperation geometryOperation) {
42
		super(geometryOperation);
43
		this.geometry = geometryOperation.getGeometry();
44
	}
45

  
46

  
47

  
48
}
49

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/wfs_1_0_0/EnvelopeFEQuery1_0_0.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_0_0;
25

  
26
import org.gvsig.remoteclient.wfs.filters.filterencoding.EnvelopeFEQuery;
27
import org.gvsig.remoteclient.wfs.filters.operations.WFSEnvelopeFilterOperation;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class EnvelopeFEQuery1_0_0 extends EnvelopeFEQuery{
36

  
37
    /**
38
     * @param envelopeOperation
39
     */
40
    public EnvelopeFEQuery1_0_0(WFSEnvelopeFilterOperation envelopeOperation) {
41
        super(envelopeOperation);       
42
    }
43
    
44
    public String getFilterEncoding(){
45
        StringBuffer request = new StringBuffer();
46
        request.append("<ogc:BBOX>");       
47
        request.append("<ogc:PropertyName>" + spatialFilterOperation.getAttributeFullName() + "</ogc:PropertyName>");
48
        request.append("<gml:Box srsName=\"" + spatialFilterOperation.getSrsName() + "\">");
49
        request.append("<gml:coordinates>");
50
        request.append(envelope.getMinimum(0) + "," + envelope.getMinimum(1));
51
        request.append(" ");
52
        request.append(envelope.getMaximum(0) + "," + envelope.getMaximum(1));
53
        request.append("</gml:coordinates>");
54
        request.append("</gml:Box>");
55
        request.append("</ogc:BBOX>");
56
        return request.toString();
57
    }
58

  
59
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/wfs_1_0_0/GeometryFEQuery_1_0_0.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_0_0;
26

  
27
import java.awt.geom.PathIterator;
28

  
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.Geometry.TYPES;
31
import org.gvsig.fmap.geom.primitive.GeneralPathX;
32
import org.gvsig.fmap.geom.primitive.Surface;
33
import org.gvsig.remoteclient.wfs.filters.filterencoding.GeometryFEQuery;
34
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation;
35

  
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
38
 */
39
public class GeometryFEQuery_1_0_0 extends GeometryFEQuery{
40

  
41
	public GeometryFEQuery_1_0_0(WFSGeometryFilterOperation geometryOperation) {
42
		super(geometryOperation);
43
	}
44

  
45
	public String getFilterEncoding(){
46
		StringBuffer request = new StringBuffer();
47
		if (geometry.getType() == TYPES.SURFACE){
48

  
49
			Surface surface = (Surface)geometry;
50
			request.append("<ogc:Intersects>");
51
			request.append("<ogc:PropertyName>" + spatialFilterOperation.getAttributeName() + "</ogc:PropertyName>");
52
			request.append("<gml:MultiPolygon srsName=\"" + spatialFilterOperation.getSrsName() + "\">");
53
			request.append("<gml:polygonMember>");
54
			request.append("<gml:Polygon>");
55
			request.append("<gml:outerBoundaryIs>");
56
			request.append("<gml:LinearRing>");
57
			request.append("<gml:coordinates cs=\",\" decimal=\".\" ts=\" \">");
58
			GeneralPathX generalPath = surface.getGeneralPath();
59
			PathIterator it = generalPath.getPathIterator(null);
60
			int type;
61
			double[] coordinates = new double[6];
62
			double[] firstCoordinates = null;
63
			while (!it.isDone()){
64
				type = it.currentSegment(coordinates);
65
				switch (type) {
66
					case PathIterator.SEG_MOVETO:
67
					case PathIterator.SEG_LINETO:
68
						request.append(coordinates[0]);
69
						request.append(",");
70
						request.append(coordinates[1]);
71
						request.append(" ");
72
						if (firstCoordinates == null){
73
							firstCoordinates = new double[2];
74
							firstCoordinates[0] = coordinates[0];
75
							firstCoordinates[1] = coordinates[1];
76
						}
77
						break;
78
				}
79
				it.next();
80
			}
81
			if ((coordinates[0] != firstCoordinates[0]) ||
82
					(coordinates[1] != firstCoordinates[1])){
83
				request.append(firstCoordinates[0]);
84
				request.append(",");
85
				request.append(firstCoordinates[1]);
86
			}
87
			request.append("</gml:coordinates>");
88
			request.append("</gml:LinearRing>");
89
			request.append("</gml:outerBoundaryIs>");
90
			request.append("</gml:Polygon>");
91
			request.append("</gml:polygonMember>");
92
			request.append("</gml:MultiPolygon>");
93
			request.append("</ogc:Intersects>");
94
		}
95
		return request.toString();
96
	}
97

  
98

  
99
}
100

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/EnvelopeFEQuery.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.remoteclient.wfs.filters.filterencoding;
26

  
27
import org.gvsig.fmap.geom.primitive.Envelope;
28
import org.gvsig.remoteclient.wfs.filters.operations.WFSEnvelopeFilterOperation;
29

  
30
/**
31
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
32
 */
33
public abstract class EnvelopeFEQuery extends SpatialFEQuery {
34
	protected Envelope envelope = null;
35

  
36
	public EnvelopeFEQuery(WFSEnvelopeFilterOperation envelopeOperation) {
37
		super(envelopeOperation);
38
		this.envelope = envelopeOperation.getEnvelope(); 
39
	}
40
}
41

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/SpatialFEQuery.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.remoteclient.wfs.filters.filterencoding;
26

  
27
import org.gvsig.remoteclient.wfs.filters.operations.WFSSpatialFilterOperation;
28

  
29
/**
30
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
31
 */
32
public abstract class SpatialFEQuery implements FEQuery{
33
    protected WFSSpatialFilterOperation spatialFilterOperation = null;
34
  
35
    public SpatialFEQuery(WFSSpatialFilterOperation spatialFilterOperation) {
36
        this.spatialFilterOperation = spatialFilterOperation;           
37
    }
38

  
39
}
40

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/wfs_1_1_0/GeometryFEQuery_1_1_0.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_1_0;
26

  
27
import java.awt.geom.PathIterator;
28

  
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.Geometry.TYPES;
31
import org.gvsig.fmap.geom.primitive.GeneralPathX;
32
import org.gvsig.fmap.geom.primitive.Surface;
33
import org.gvsig.remoteclient.wfs.filters.filterencoding.GeometryFEQuery;
34
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation;
35

  
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
38
 */
39
public class GeometryFEQuery_1_1_0 extends GeometryFEQuery{
40

  
41
	public GeometryFEQuery_1_1_0(WFSGeometryFilterOperation geometryOperation) {
42
		super(geometryOperation);
43
	}
44

  
45
	public String getFilterEncoding(){
46
		StringBuffer request = new StringBuffer();
47
		if (geometry.getType() == TYPES.SURFACE){
48
			Surface surface = (Surface)geometry;
49
			request.append("<ogc:Intersects>");
50
			request.append("<ogc:PropertyName>" + spatialFilterOperation.getAttributeName() + "</ogc:PropertyName>");
51
			request.append("<gml:MultiSurface srsName=\"" + spatialFilterOperation.getSrsName() + "\">");
52
			request.append("<gml:surfaceMember>");
53
			request.append("<gml:Polygon>");
54
			request.append("<gml:exterior>");
55
			request.append("<gml:LinearRing>");
56
			request.append("<gml:coordinates cs=\",\" decimal=\".\" ts=\" \">");
57
			GeneralPathX generalPath = surface.getGeneralPath();
58
			PathIterator it = generalPath.getPathIterator(null);
59
			int type;
60
			double[] coordinates = new double[6];
61
			double[] firstCoordinates = null;
62
			while (!it.isDone()){
63
				type = it.currentSegment(coordinates);
64
				switch (type) {
65
					case PathIterator.SEG_MOVETO:
66
					case PathIterator.SEG_LINETO:
67
						request.append(coordinates[0]);
68
						request.append(",");
69
						request.append(coordinates[1]);
70
						request.append(" ");
71
						if (firstCoordinates == null){
72
							firstCoordinates = new double[2];
73
							firstCoordinates[0] = coordinates[0];
74
							firstCoordinates[1] = coordinates[1];
75
						}
76
						break;
77
				}
78
				it.next();
79
			}
80
			if ((coordinates[0] != firstCoordinates[0]) ||
81
					(coordinates[1] != firstCoordinates[1])){
82
				request.append(firstCoordinates[0]);
83
				request.append(",");
84
				request.append(firstCoordinates[1]);
85
			}
86
			request.append("</gml:coordinates>");
87
			request.append("</gml:LinearRing>");
88
			request.append("</gml:exterior>");
89
			request.append("</gml:Polygon>");
90
			request.append("</gml:surfaceMember>");
91
			request.append("</gml:MultiSurface>");
92
			request.append("</ogc:Intersects>");
93
		}
94
		return request.toString();
95
	}
96

  
97

  
98
}
99

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/wfs_1_1_0/EnvelopeFEQuery1_1_0.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs.filters.filterencoding.wfs_1_1_0;
25

  
26
import org.gvsig.remoteclient.wfs.filters.filterencoding.EnvelopeFEQuery;
27
import org.gvsig.remoteclient.wfs.filters.operations.WFSEnvelopeFilterOperation;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class EnvelopeFEQuery1_1_0 extends EnvelopeFEQuery{
36

  
37
    /**
38
     * @param envelopeOperation
39
     */
40
    public EnvelopeFEQuery1_1_0(WFSEnvelopeFilterOperation envelopeOperation) {
41
        super(envelopeOperation);       
42
    }
43
    
44
    public String getFilterEncoding(){
45
        StringBuffer request = new StringBuffer();
46
        request.append("<ogc:BBOX>");
47
        request.append("<ogc:PropertyName>" + spatialFilterOperation.getAttributeFullName() + "</ogc:PropertyName>");
48
        request.append("<gml:Envelope srsName=\"" + spatialFilterOperation.getSrsName() + "\">");
49
        request.append("<gml:lowerCorner>");
50
        request.append(envelope.getMinimum(0) + " " + envelope.getMinimum(1));
51
        request.append("</gml:lowerCorner>");
52
        request.append("<gml:upperCorner>");
53
        request.append(envelope.getMaximum(0) + " " + envelope.getMaximum(1));
54
        request.append("</gml:upperCorner>");
55
        request.append("</gml:Envelope>");
56
        request.append("</ogc:BBOX>");
57
        return request.toString();
58
    }
59

  
60
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/filterencoding/FEQuery.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.remoteclient.wfs.filters.filterencoding;
26
/**
27
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
28
 */
29
public interface FEQuery {
30
	
31
	public String getFilterEncoding();
32
}
33

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/DefaultSQLExpressionFormat.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs.filters;
25
/**
26
 * Default SQL formatter
27
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
28
 */
29
public class DefaultSQLExpressionFormat implements ISQLExpressionFormat{
30

  
31
	/*
32
	 * (non-Javadoc)
33
	 * @see org.gvsig.remoteClient.wfs.filters.ISQLExpressionFormat#format(java.lang.String)
34
	 */
35
	public String format(String expression) {
36
		return expression;
37
	}
38

  
39
}
0 40

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/ParseExpressions.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs.filters;
25

  
26
import java.util.ArrayList;
27

  
28
/**
29
 * It parses a SQL expression (just the where part) and seperates
30
 * it in "sub-expresion". A sub-expresion could be a separator ('(' or ')'),
31
 * a logical operator ('And', 'Not' or 'Or') or a expresion (A op B).
32
 *  
33
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
34
 */
35
public class ParseExpressions {
36
		
37
	/**
38
	 * It parses a expression and return one arrayList with
39
	 * the separated words
40
	 * @param expression
41
	 * @return
42
	 */
43
	public ArrayList parseExpression(String expression){
44
		ArrayList expressions = new ArrayList();
45
		
46
		char[] chars = expression.toCharArray();
47
		int i=0;
48
		while (i<chars.length){
49
			if (chars[i] == '('){
50
				expressions.add("(");
51
				i++;
52
			}else if(chars[i] == ')'){
53
				expressions.add(")");
54
				i++;
55
			}else if(chars[i] == ' '){
56
				i++;
57
			}else{
58
				int desp = getShift(chars,i);
59
				expressions.add(expression.substring(i,i + desp));
60
				i = i + desp;
61
			}
62
		}		
63
		return expressions;
64
	}
65
	
66
	/**
67
	 * Gets the shift of the next expression.
68
	 * @param chars
69
	 * @param position
70
	 * @return
71
	 */
72
	private int getShift(char[] chars,int position){
73
		int shift = 0;
74
		shift = isAndOperator(chars,position);
75
		if (shift == 0){
76
			shift = isOrOperator(chars,position);
77
			if (shift == 0){
78
				shift = isNotOperator(chars,position);
79
				if (shift == 0){
80
					shift = isExpression(chars,position);
81
				}
82
			}
83
		}
84
		return shift;
85
	}
86
	
87
	private int isExpression(char[] chars,int position){
88
		int desp = 0;
89
		for (int i=position ;i<chars.length ; i++){
90
			if (chars[i] == ')'){
91
				break;			
92
			}			
93
			desp++;
94
		}
95
		return desp;
96
	}
97
	
98
	/**
99
	 * Return true if the next array is a AND operator
100
	 * @param chars
101
	 * @param position
102
	 * @return
103
	 */
104
	private int isAndOperator(char[] chars,int position){
105
		if (chars[position] == 'A' && 
106
				chars[position+1] == 'N' && 
107
				chars[position+2] == 'D' &&
108
				chars[position+3] == ' '){
109
			return 3;
110
		}
111
		return 0;
112
	}
113
	
114
	/**
115
	 * Return true if the next array is a OR operator
116
	 * @param chars
117
	 * @param position
118
	 * @return
119
	 */
120
	private int isOrOperator(char[] chars,int position){
121
		if (chars[position] == 'O' && 
122
				chars[position+1] == 'R' && 
123
				chars[position+2] == ' '){
124
			return 2;
125
		}
126
		return 0;
127
	}
128
	
129
	/**
130
	 * Return true if the next array is a NOT operator
131
	 * @param chars
132
	 * @param position
133
	 * @return
134
	 */
135
	private int isNotOperator(char[] chars,int position){
136
		if (chars[position] == 'N' && 
137
				chars[position+1] == 'O' && 
138
				chars[position+2] == 'T' &&
139
				chars[position+3] == ' '){
140
			return 3;
141
		}
142
		return 0;
143
	}
144

  
145
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.12/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/filters/ISQLExpressionFormat.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs.filters;
25
/**
26
 * This interface must be implemented by the classes that
27
 * format a SQL expression. A formatted expression has
28
 * this form: ((a = b) AND (3 = 4)). The exprerssions (a = b)
29
 * are witten between brackets and there has two terms.
30
 * The logic operators are used to link expressions.
31
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
32
 */
33
public interface ISQLExpressionFormat {
34
	public String format(String expression);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff