Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteClient / wfs / schema / type / XMLComplexType.java @ 28543

History | View | Annotate | Download (4.72 KB)

1
package org.gvsig.remoteClient.wfs.schema.type;
2

    
3
import java.util.HashMap;
4
import java.util.Iterator;
5
import java.util.LinkedHashMap;
6
import java.util.Map;
7
import java.util.Set;
8
import java.util.Vector;
9

    
10
import org.gvsig.remoteClient.wfs.schema.XMLElement;
11
import org.gvsig.remoteClient.wfs.schema.XMLTypesFactory;
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: XMLComplexType.java 9510 2006-12-29 18:05:20Z jorpiell $
56
 * $Log$
57
 * Revision 1.3  2006-12-29 18:05:20  jorpiell
58
 * Se tienen en cuenta los simpleTypes y los choices, adem?s de los atributos multiples
59
 *
60
 * Revision 1.1  2006/12/22 11:25:04  csanchez
61
 * Nuevo parser GML 2.x para gml's sin esquema
62
 *
63
 * Revision 1.7  2006/10/31 13:52:37  ppiqueras
64
 * Mejoras para uso de features complejas
65
 *
66
 * Revision 1.6  2006/10/31 12:24:33  jorpiell
67
 * En caso de que el elemento forme parte de un tipo complejo tiene que tener un enlace al tipo del objeto padre
68
 *
69
 * Revision 1.5  2006/10/10 12:52:28  jorpiell
70
 * Soporte para features complejas.
71
 *
72
 * Revision 1.4  2006/10/02 08:33:49  jorpiell
73
 * Cambios del 10 copiados al head
74
 *
75
 * Revision 1.2.2.1  2006/09/19 12:23:15  jorpiell
76
 * Ya no se depende de geotools
77
 *
78
 * Revision 1.3  2006/09/18 12:08:55  jorpiell
79
 * Se han hecho algunas modificaciones que necesitaba el WFS
80
 *
81
 * Revision 1.2  2006/08/29 08:43:13  jorpiell
82
 * Dos peque?os cambios para tener en cuenta las referencias
83
 *
84
 * Revision 1.1  2006/08/10 12:00:49  jorpiell
85
 * Primer commit del driver de Gml
86
 *
87
 *
88
 */
89
/**
90
 * This class implements an XSD complex type
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 XMLComplexType implements IXMLType {
97
        public static int SEQUENCE_TYPE = 0;
98
        public static int CHOICE_TYPE = 1;
99
        
100
        private String type = null;
101
        private LinkedHashMap baseElements = null;
102
        private String baseType = null;
103

    
104
        private int attributesType = 0; 
105
                        
106
        public XMLComplexType(String type) {
107
                super();
108
                this.type = type;
109
                baseElements = new LinkedHashMap();
110
        }
111
        
112
        /*
113
         *  (non-Javadoc)
114
         * @see org.gvsig.remoteClient.gml.schemas.IXMLType#getType()
115
         */
116
        public int getType() {
117
                return IXMLType.COMPLEX;
118
        }
119
        
120
        /*
121
         *  (non-Javadoc)
122
         * @see org.gvsig.remoteClient.gml.schemas.IXMLType#getName()
123
         */
124
        public String getName() {
125
                return type;
126
        }
127
        
128
        /**
129
         * @return Returns the subtypes.
130
         */
131
        public Map getSubtypes() {
132
                return baseElements;
133
        }
134
        
135
        /**
136
         * @param subtypes The subtypes to set.
137
         */
138
        public void addElements(XMLElement element) {
139
                if (element.getName() != null){
140
                        this.baseElements.put(element.getName(),element);
141
                }
142
        }
143
        
144
        
145
        /**
146
         * 
147
         * @param name
148
         * @return
149
         */
150
        public XMLElement getAttribute(String name){
151
                return (XMLElement)baseElements.get(name);
152
        }
153

    
154
        /**
155
         * @return Returns the vElements.
156
         */
157
        public Vector getAttributes() {
158
                Set keys = baseElements.keySet();
159
                Iterator it = keys.iterator();
160
                Vector vector = new Vector();
161
                while(it.hasNext()){
162
                        vector.add(baseElements.get((String)it.next()));
163
                }
164
                if (baseType != null){
165
                        IXMLType type = XMLTypesFactory.getType(baseType);
166
                        if (type != null){
167
                                if (type instanceof XMLComplexType){
168
                                        Vector vector2 = ((XMLComplexType)type).getAttributes();
169
                                        for (int i=0 ; i<vector2.size() ; i++){
170
                                                vector.add(vector2.get(i));
171
                                        }
172
                                }
173
                        }
174
                }
175
                return vector;
176
        }
177

    
178
        public int getAttributesType() {
179
                return attributesType;
180
        }
181

    
182
        public void setAttributesType(int attributesType) {
183
                this.attributesType = attributesType;
184
        }        
185
        
186
        /**
187
         * @param baseType the baseType to set
188
         */
189
        public void setBaseType(String baseType) {
190
                this.baseType = baseType;
191
        }
192
        
193
}