Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / drivers / wfs / filters / SQLExpressionFormat.java @ 8273

History | View | Annotate | Download (2.83 KB)

1
package com.iver.cit.gvsig.fmap.drivers.wfs.filters;
2

    
3
import java.io.ByteArrayInputStream;
4
import java.io.InputStream;
5
import java.util.Hashtable;
6

    
7
import org.gvsig.remoteClient.wfs.filters.FilterEncoding;
8
import org.gvsig.remoteClient.wfs.filters.ISQLExpressionFormat;
9

    
10
import Zql.ParseException;
11
import Zql.ZExp;
12
import Zql.ZExpression;
13
import Zql.ZqlParser;
14

    
15
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id: SQLExpressionFormat.java 8273 2006-10-24 07:27:56Z jorpiell $
58
 * $Log$
59
 * Revision 1.4  2006-10-24 07:27:56  jorpiell
60
 * Algunos cambios en el modelo que usa la tabla
61
 *
62
 * Revision 1.3  2006/10/23 07:37:04  jorpiell
63
 * Ya funciona el filterEncoding
64
 *
65
 * Revision 1.2  2006/10/10 12:55:06  jorpiell
66
 * Se ha a?adido el soporte de features complejas
67
 *
68
 * Revision 1.1  2006/10/05 10:26:26  jorpiell
69
 * A?adidas las clases para obtener los filtros
70
 *
71
 *
72
 */
73
/**
74
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
75
 */
76
public class SQLExpressionFormat implements ISQLExpressionFormat{
77

    
78
        /*
79
         *  (non-Javadoc)
80
         * @see org.gvsig.remoteClient.wfs.filters.ISQLExpressionFormat#format(java.lang.String)
81
         */
82
        public String format(String query) {
83
                if ((query == null) || (query.equals(""))){
84
                        return null;
85
                }
86
                InputStream is = new ByteArrayInputStream(query.getBytes());
87
                ZqlParser parser = new ZqlParser();
88
                parser.initParser(is);
89
                ZExp exp;
90
                try {
91
                        exp = parser.readExpression();
92
                        return exp.toString();
93
                } catch (ParseException e) {
94
                        // TODO Auto-generated catch block
95
                        e.printStackTrace();
96
                }
97
                return query;
98
        }
99
        
100
        /**
101
         * Creates a Filter Encoding creator that uses this
102
         * formatter to parse the SQL
103
         * @return
104
         */
105
        public static FilterEncoding createFilter(){
106
                return new FilterEncoding(new SQLExpressionFormat());                                
107
        }
108

    
109
        
110

    
111
}