svn-gvsig-desktop / branches / v10 / libraries / libRemoteServices / src / org / gvsig / remoteClient / gml / factories / XMLTypesFactory.java @ 12337
History | View | Annotate | Download (5.89 KB)
1 |
package org.gvsig.remoteClient.gml.factories; |
---|---|
2 |
|
3 |
import java.util.Hashtable; |
4 |
import java.util.Iterator; |
5 |
import java.util.Set; |
6 |
|
7 |
import org.gvsig.remoteClient.gml.types.GMLGeometryType; |
8 |
import org.gvsig.remoteClient.gml.types.IXMLType; |
9 |
import org.gvsig.remoteClient.gml.types.XMLComplexType; |
10 |
import org.gvsig.remoteClient.gml.types.XMLSimpleType; |
11 |
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
13 |
*
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
15 |
*
|
16 |
* This program is free software; you can redistribute it and/or
|
17 |
* modify it under the terms of the GNU General Public License
|
18 |
* as published by the Free Software Foundation; either version 2
|
19 |
* of the License, or (at your option) any later version.
|
20 |
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
29 |
*
|
30 |
* For more information, contact:
|
31 |
*
|
32 |
* Generalitat Valenciana
|
33 |
* Conselleria d'Infraestructures i Transport
|
34 |
* Av. Blasco Ib??ez, 50
|
35 |
* 46010 VALENCIA
|
36 |
* SPAIN
|
37 |
*
|
38 |
* +34 963862235
|
39 |
* gvsig@gva.es
|
40 |
* www.gvsig.gva.es
|
41 |
*
|
42 |
* or
|
43 |
*
|
44 |
* IVER T.I. S.A
|
45 |
* Salamanca 50
|
46 |
* 46005 Valencia
|
47 |
* Spain
|
48 |
*
|
49 |
* +34 963163400
|
50 |
* dac@iver.es
|
51 |
*/
|
52 |
/* CVS MESSAGES:
|
53 |
*
|
54 |
* $Id: XMLTypesFactory.java 12337 2007-06-26 10:19:28Z jorpiell $
|
55 |
* $Log$
|
56 |
* Revision 1.1.2.6 2007-06-26 10:19:28 jorpiell
|
57 |
* XS:Decimal type added
|
58 |
*
|
59 |
* Revision 1.1.2.5 2007/01/25 16:12:59 jorpiell
|
60 |
* Se han sustituido las clases por las que hay en el nuevo driver de GML.
|
61 |
*
|
62 |
* Revision 1.8 2006/12/29 17:15:48 jorpiell
|
63 |
* Se tienen en cuenta los simpleTypes y los choices, adem?s de los atributos multiples
|
64 |
*
|
65 |
* Revision 1.7 2006/12/22 11:25:44 csanchez
|
66 |
* Nuevo parser GML 2.x para gml's sin esquema
|
67 |
*
|
68 |
* Revision 1.5 2006/10/11 11:21:00 jorpiell
|
69 |
* Se escriben los tipos correctamente (no en mayusculas) para que las traducciones funcionen
|
70 |
*
|
71 |
* Revision 1.4 2006/10/10 12:52:28 jorpiell
|
72 |
* Soporte para features complejas.
|
73 |
*
|
74 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell
|
75 |
* Cambios del 10 copiados al head
|
76 |
*
|
77 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell
|
78 |
* Ya no se depende de geotools
|
79 |
*
|
80 |
* Revision 1.2 2006/09/18 12:08:55 jorpiell
|
81 |
* Se han hecho algunas modificaciones que necesitaba el WFS
|
82 |
*
|
83 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell
|
84 |
* Primer commit del driver de Gml
|
85 |
*
|
86 |
*
|
87 |
*/
|
88 |
/**
|
89 |
* GML and XML types factory. All the types that are
|
90 |
* located in the schemas must be registered here
|
91 |
*
|
92 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
93 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
|
94 |
*
|
95 |
*/
|
96 |
public class XMLTypesFactory { |
97 |
private static Hashtable types = new Hashtable(); |
98 |
|
99 |
static{
|
100 |
types.put(XMLSimpleType.STRING.toUpperCase(),new XMLSimpleType(XMLSimpleType.STRING));
|
101 |
types.put(XMLSimpleType.INTEGER.toUpperCase(),new XMLSimpleType(XMLSimpleType.INTEGER));
|
102 |
types.put(XMLSimpleType.INT.toUpperCase(),new XMLSimpleType(XMLSimpleType.INT));
|
103 |
types.put(XMLSimpleType.DOUBLE.toUpperCase(),new XMLSimpleType(XMLSimpleType.DOUBLE));
|
104 |
types.put(XMLSimpleType.FLOAT.toUpperCase(),new XMLSimpleType(XMLSimpleType.FLOAT));
|
105 |
types.put(XMLSimpleType.BOOLEAN.toUpperCase(),new XMLSimpleType(XMLSimpleType.BOOLEAN));
|
106 |
types.put(XMLSimpleType.LONG.toUpperCase(),new XMLSimpleType(XMLSimpleType.LONG));
|
107 |
types.put(XMLSimpleType.DECIMAL.toUpperCase(),new XMLSimpleType(XMLSimpleType.DECIMAL));
|
108 |
types.put(GMLGeometryType.POINT.toUpperCase(),new GMLGeometryType(GMLGeometryType.POINT));
|
109 |
types.put(GMLGeometryType.MULTIPOINT.toUpperCase(),new GMLGeometryType(GMLGeometryType.MULTIPOINT));
|
110 |
types.put(GMLGeometryType.LINE.toUpperCase(),new GMLGeometryType(GMLGeometryType.LINE));
|
111 |
types.put(GMLGeometryType.POLYGON.toUpperCase(),new GMLGeometryType(GMLGeometryType.POLYGON));
|
112 |
types.put(GMLGeometryType.GEOMETRY.toUpperCase(),new GMLGeometryType(GMLGeometryType.GEOMETRY));
|
113 |
} |
114 |
|
115 |
/**
|
116 |
* Gets a type by name
|
117 |
* @param type
|
118 |
* Type name
|
119 |
* @return
|
120 |
*/
|
121 |
public static IXMLType getType(String type){ |
122 |
IXMLType xmlType = (IXMLType)types.get(type.toUpperCase()); |
123 |
if (xmlType == null){ |
124 |
xmlType = getTypeWithOutNameSpace(type); |
125 |
} |
126 |
return xmlType;
|
127 |
} |
128 |
|
129 |
/**
|
130 |
* This method is used to solve some mistakes. It doesn't
|
131 |
* consider the namespace
|
132 |
* @param type
|
133 |
* @return
|
134 |
*/
|
135 |
public static IXMLType getTypeWithOutNameSpace(String type){ |
136 |
Set keys = types.keySet();
|
137 |
Iterator it = keys.iterator();
|
138 |
while(it.hasNext()){
|
139 |
String key = (String)it.next(); |
140 |
String[] parts = key.split(":"); |
141 |
if (parts.length > 1){ |
142 |
if (parts[1].compareTo(type.toUpperCase())==0){ |
143 |
return (IXMLType)types.get(key);
|
144 |
} |
145 |
} |
146 |
} |
147 |
return null; |
148 |
} |
149 |
|
150 |
/**
|
151 |
* Adds a new type
|
152 |
* @param type
|
153 |
* type to add
|
154 |
*/
|
155 |
private static void addType(IXMLType type){ |
156 |
types.put(type.getName().toUpperCase(),type); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* Adds a complex type
|
161 |
* @param nameSpace
|
162 |
* NameSpace where is located
|
163 |
* @param name
|
164 |
* Complex type name
|
165 |
* @return
|
166 |
*/
|
167 |
public static XMLComplexType addComplexType(String nameSpace,String name){ |
168 |
XMLComplexType complexType = new XMLComplexType(nameSpace + ":" + name); |
169 |
addType(complexType); |
170 |
return complexType;
|
171 |
} |
172 |
|
173 |
public static XMLSimpleType addSimpleType(String name,String type){ |
174 |
XMLSimpleType simpleType = new XMLSimpleType(name,type);
|
175 |
types.put(name.toUpperCase(),simpleType); |
176 |
return simpleType;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* Just for degug. It prints all the registred components.
|
181 |
*/
|
182 |
public static void printTypes(){ |
183 |
System.out.println("*** TIPOS ***"); |
184 |
Object[] keys = types.keySet().toArray(); |
185 |
for (int i=0 ; i<types.size() ; i++){ |
186 |
IXMLType type = (IXMLType)types.get(keys[i]); |
187 |
System.out.print("NAME: " + type.getName()); |
188 |
System.out.print(" TYPE: " + type.getType() + "\n"); |
189 |
} |
190 |
} |
191 |
|
192 |
} |