svn-gvsig-desktop / branches / v10 / libraries / libRemoteServices / src / org / gvsig / remoteClient / gml / factories / FeaturesParserFactory.java @ 12337
History | View | Annotate | Download (4.6 KB)
1 |
package org.gvsig.remoteClient.gml.factories; |
---|---|
2 |
|
3 |
import java.lang.reflect.InvocationTargetException; |
4 |
import java.util.Hashtable; |
5 |
|
6 |
import org.gvsig.remoteClient.gml.GMLFeaturesParser; |
7 |
import org.gvsig.remoteClient.gml.exceptions.GMLParserException; |
8 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
9 |
import org.gvsig.remoteClient.gml.v2.GMLFeaturesParser_v2; |
10 |
import org.gvsig.remoteClient.gml.warnings.GMLWarningInfo; |
11 |
import org.gvsig.remoteClient.gml.warnings.GMLWarningVersionNotSupported; |
12 |
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
14 |
*
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
16 |
*
|
17 |
* This program is free software; you can redistribute it and/or
|
18 |
* modify it under the terms of the GNU General Public License
|
19 |
* as published by the Free Software Foundation; either version 2
|
20 |
* of the License, or (at your option) any later version.
|
21 |
*
|
22 |
* This program is distributed in the hope that it will be useful,
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
* GNU General Public License for more details.
|
26 |
*
|
27 |
* You should have received a copy of the GNU General Public License
|
28 |
* along with this program; if not, write to the Free Software
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
30 |
*
|
31 |
* For more information, contact:
|
32 |
*
|
33 |
* Generalitat Valenciana
|
34 |
* Conselleria d'Infraestructures i Transport
|
35 |
* Av. Blasco Ib??ez, 50
|
36 |
* 46010 VALENCIA
|
37 |
* SPAIN
|
38 |
*
|
39 |
* +34 963862235
|
40 |
* gvsig@gva.es
|
41 |
* www.gvsig.gva.es
|
42 |
*
|
43 |
* or
|
44 |
*
|
45 |
* IVER T.I. S.A
|
46 |
* Salamanca 50
|
47 |
* 46005 Valencia
|
48 |
* Spain
|
49 |
*
|
50 |
* +34 963163400
|
51 |
* dac@iver.es
|
52 |
*/
|
53 |
/* CVS MESSAGES:
|
54 |
*
|
55 |
* $Id: FeaturesParserFactory.java 9917 2007-01-25 16:13:00Z jorpiell $
|
56 |
* $Log$
|
57 |
* Revision 1.1.2.1 2007-01-25 16:12:59 jorpiell
|
58 |
* Se han sustituido las clases por las que hay en el nuevo driver de GML.
|
59 |
*
|
60 |
* Revision 1.3 2007/01/15 13:11:00 csanchez
|
61 |
* Sistema de Warnings y Excepciones adaptado a BasicException
|
62 |
*
|
63 |
* Revision 1.2 2006/12/22 11:25:44 csanchez
|
64 |
* Nuevo parser GML 2.x para gml's sin esquema
|
65 |
*
|
66 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell
|
67 |
* Primer commit del driver de Gml
|
68 |
*
|
69 |
*
|
70 |
*/
|
71 |
/**
|
72 |
* This class has all the classes to parse different types
|
73 |
* of GML files.
|
74 |
*
|
75 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
76 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
|
77 |
*
|
78 |
*/
|
79 |
public class FeaturesParserFactory { |
80 |
private static Hashtable supportedVersions = new Hashtable(); |
81 |
static {
|
82 |
supportedVersions.put("1.0",GMLFeaturesParser_v2.class);
|
83 |
supportedVersions.put("2.0",GMLFeaturesParser_v2.class);
|
84 |
supportedVersions.put("1.0.0",GMLFeaturesParser_v2.class);
|
85 |
supportedVersions.put("2.0.0",GMLFeaturesParser_v2.class);
|
86 |
supportedVersions.put("2.1.1",GMLFeaturesParser_v2.class);
|
87 |
supportedVersions.put("2.1.2",GMLFeaturesParser_v2.class);
|
88 |
supportedVersions.put("2.x",GMLFeaturesParser_v2.class);
|
89 |
//Default GML version if it's not especified in the schema or it hasn't schema
|
90 |
supportedVersions.put("99.99.99",GMLFeaturesParser_v2.class);
|
91 |
} |
92 |
public GMLWarningInfo warnings = null; |
93 |
private GMLFeaturesParser gmlParser = null; |
94 |
|
95 |
/**
|
96 |
* Gets the features iterator
|
97 |
* @param version
|
98 |
* Depending of this value, a different parser will be
|
99 |
* created and returned
|
100 |
* @param factory
|
101 |
* Factory to create the geometries
|
102 |
* @param parser
|
103 |
* Used to parse the GML file
|
104 |
* @return
|
105 |
* @throws IllegalArgumentException
|
106 |
* @throws SecurityException
|
107 |
* @throws InstantiationException
|
108 |
* @throws IllegalAccessException
|
109 |
* @throws InvocationTargetException
|
110 |
* @throws NoSuchMethodException
|
111 |
*/
|
112 |
public FeaturesParserFactory(){
|
113 |
warnings = new GMLWarningInfo();
|
114 |
} |
115 |
public GMLFeaturesParser createParser(String version, IGeometriesFactory factory, XMLSchemaParser parser) throws GMLParserException{ |
116 |
Class clazz = (Class) supportedVersions.get(version); |
117 |
if (clazz == null){ |
118 |
clazz = (Class) supportedVersions.get("99.99.99"); |
119 |
//WARNING VERSION NOT SUPPORTED OR NOT SPECIFIED
|
120 |
warnings.setElement(new GMLWarningVersionNotSupported(version));
|
121 |
} |
122 |
if (clazz != null){ |
123 |
//Utilizamos un interfaz con los tipos y las geometrias b?sicas de GML
|
124 |
//?Otra opcion seria parsear el schemas de opengis, para obtener los tipos b?sicos?
|
125 |
Class [] args = {IGeometriesFactory.class,XMLSchemaParser.class}; |
126 |
Object [] params = {factory,parser}; |
127 |
//pasamos el parser con el que estamos leyendo el gml y el interfaz de geometrias
|
128 |
//para continuar con la comprobaci?n del fichero GML
|
129 |
try {
|
130 |
gmlParser = (GMLFeaturesParser) clazz.getConstructor(args).newInstance(params); |
131 |
} catch (Exception e) { |
132 |
throw new GMLParserException(e); |
133 |
} |
134 |
} |
135 |
return gmlParser ;
|
136 |
} |
137 |
} |