Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / libraries / libRemoteServices / src / org / gvsig / remoteClient / gml / factories / XMLTypesFactory.java @ 8745

History | View | Annotate | Download (4.03 KB)

1
package org.gvsig.remoteClient.gml.factories;
2

    
3
import java.util.Hashtable;
4
import java.util.Set;
5

    
6
import org.gvsig.remoteClient.gml.schemas.GMLGeometryType;
7
import org.gvsig.remoteClient.gml.schemas.IXMLType;
8
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
9
import org.gvsig.remoteClient.gml.schemas.XMLSimpleType;
10

    
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: XMLTypesFactory.java 8745 2006-11-14 13:14:23Z  $
54
 * $Log$
55
 * Revision 1.1.2.1  2006-09-19 12:23:15  jorpiell
56
 * Ya no se depende de geotools
57
 *
58
 * Revision 1.2  2006/09/18 12:08:55  jorpiell
59
 * Se han hecho algunas modificaciones que necesitaba el WFS
60
 *
61
 * Revision 1.1  2006/08/10 12:00:49  jorpiell
62
 * Primer commit del driver de Gml
63
 *
64
 *
65
 */
66
/**
67
 * GML and XML types factory. All the types that are
68
 * located in the schemas must be registered here
69
 * 
70
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
71
 */
72
public class XMLTypesFactory {
73
        private static Hashtable types = new Hashtable();
74
                
75
        static{
76
                types.put(XMLSimpleType.STRING,new XMLSimpleType(XMLSimpleType.STRING));
77
                types.put(XMLSimpleType.INTEGER,new XMLSimpleType(XMLSimpleType.INTEGER));
78
                types.put(XMLSimpleType.INT,new XMLSimpleType(XMLSimpleType.INT));
79
                types.put(XMLSimpleType.DOUBLE,new XMLSimpleType(XMLSimpleType.DOUBLE));
80
                types.put(XMLSimpleType.FLOAT,new XMLSimpleType(XMLSimpleType.FLOAT));
81
                types.put(XMLSimpleType.BOOLEAN,new XMLSimpleType(XMLSimpleType.BOOLEAN));
82
                types.put(XMLSimpleType.LONG,new XMLSimpleType(XMLSimpleType.LONG));
83
                types.put(GMLGeometryType.POINT,new GMLGeometryType(GMLGeometryType.POINT));
84
                types.put(GMLGeometryType.MULTIPOINT,new GMLGeometryType(GMLGeometryType.MULTIPOINT));
85
                types.put(GMLGeometryType.LINE,new GMLGeometryType(GMLGeometryType.LINE));
86
                types.put(GMLGeometryType.POLYGON,new GMLGeometryType(GMLGeometryType.POLYGON));
87
                types.put(GMLGeometryType.GEOMETRY,new GMLGeometryType(GMLGeometryType.GEOMETRY));
88
        }
89
        
90
        /**
91
         * Gets a type by name
92
         * @param type
93
         * Type name
94
         * @return
95
         */
96
        public static IXMLType getType(String type){
97
                return (IXMLType)types.get(type.toUpperCase());
98
        }
99
        
100
        /**
101
         * Adds a new type
102
         * @param type
103
         * type to add 
104
         */
105
        private static void addType(IXMLType type){
106
                types.put(type.getName().toUpperCase(),type);
107
        }        
108
        
109
        /**
110
         * Adds a complex type
111
         * @param nameSpace
112
         * NameSpace where is located
113
         * @param name
114
         * Complex type name
115
         * @return
116
         */
117
        public static XMLComplexType addCompleyType(String nameSpace,String name){
118
                XMLComplexType complexType = new XMLComplexType(nameSpace + ":" + name);
119
                addType(complexType);
120
                return complexType;
121
        }
122

    
123
        /**
124
         * Just for degug. It prints all the registred components.
125
         */
126
        public static void printTypes(){
127
                System.out.println("*** TIPOS ***");
128
                Object[] keys = types.keySet().toArray();
129
                for (int i=0 ; i<types.size() ; i++){
130
                        IXMLType type = (IXMLType)types.get(keys[i]);
131
                        System.out.print("NAME: " + type.getName());
132
                        System.out.print(" TYPE: " + type.getType() + "\n");
133
                }
134
        }
135
        
136
}