Statistics
| Revision:

root / org.gvsig.xmlschema / library / trunk / org.gvsig.xmlschema / org.gvsig.xmlschema.prov / org.gvsig.xmlschema.prov.dom / src / main / java / org / gvsig / xmlschema / prov / som / model / XSComplexTypeDefinitionImpl.java @ 250

History | View | Annotate | Download (5.54 KB)

1
package org.gvsig.xmlschema.prov.som.model;
2

    
3
import org.gvsig.tools.dataTypes.DataType;
4
import org.gvsig.xmlschema.lib.api.som.IXSComplexTypeDefinition;
5
import org.gvsig.xmlschema.lib.api.som.IXSContentType;
6
import org.gvsig.xmlschema.lib.api.som.IXSElement;
7
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
8
import org.gvsig.xmlschema.lib.api.som.IXSGroup;
9
import org.gvsig.xmlschema.lib.api.som.IXSNode;
10
import org.gvsig.xmlschema.lib.api.som.IXSSchema;
11
import org.gvsig.xmlschema.lib.api.utils.SchemaObjectsMapping;
12
import org.gvsig.xmlschema.lib.api.utils.SchemaTags;
13
import org.gvsig.xmlschema.prov.som.utils.SchemaCollection;
14
import org.gvsig.xmlschema.prov.som.utils.SchemaDefaults;
15

    
16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17
 *
18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
19
 *
20
 * This program is free software; you can redistribute it and/or
21
 * modify it under the terms of the GNU General Public License
22
 * as published by the Free Software Foundation; either version 2
23
 * of the License, or (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
33
 *
34
 * For more information, contact:
35
 *
36
 *  Generalitat Valenciana
37
 *   Conselleria d'Infraestructures i Transport
38
 *   Av. Blasco Ib??ez, 50
39
 *   46010 VALENCIA
40
 *   SPAIN
41
 *
42
 *      +34 963862235
43
 *   gvsig@gva.es
44
 *      www.gvsig.gva.es
45
 *
46
 *    or
47
 *
48
 *   IVER T.I. S.A
49
 *   Salamanca 50
50
 *   46005 Valencia
51
 *   Spain
52
 *
53
 *   +34 963163400
54
 *   dac@iver.es
55
 */
56
/* CVS MESSAGES:
57
 *
58
 * $Id: XSComplexTypeDefinitionImpl.java 157 2007-06-22 12:22:53Z jorpiell $
59
 * $Log$
60
 * Revision 1.2  2007/06/22 12:20:48  jorpiell
61
 * The typeNotFoundException has been deleted. It never was thrown
62
 *
63
 * Revision 1.1  2007/06/14 16:15:03  jorpiell
64
 * builds to create the jars generated and add the schema code to the libGPEProject
65
 *
66
 * Revision 1.1  2007/06/14 13:50:07  jorpiell
67
 * The schema jar name has been changed
68
 *
69
 * Revision 1.4  2007/06/08 11:35:16  jorpiell
70
 * IXSSchema interface updated
71
 *
72
 * Revision 1.3  2007/06/07 14:54:13  jorpiell
73
 * Add the schema support
74
 *
75
 * Revision 1.2  2007/05/30 12:25:48  jorpiell
76
 * Add the element collection
77
 *
78
 * Revision 1.1  2007/05/25 11:55:00  jorpiell
79
 * First update
80
 *
81
 *
82
 */
83
/**
84
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
85
 */
86
public class XSComplexTypeDefinitionImpl extends XSTypeDefinitionImpl implements IXSComplexTypeDefinition {
87
                        
88
        public XSComplexTypeDefinitionImpl(IXSSchema schema) {
89
                super(schema);
90
        }
91
        /*
92
         * (non-Javadoc)
93
         * @see org.gvsig.gpe.schema.som.IXSComplexTypeDefinition#getContentType()
94
         */
95
        public IXSContentType getContentType(){
96
                IXSNode node = new SchemaCollection(getSchema(),getElement(),getContentMapping()).getFirstNode();
97
                if (node != null){
98
                        return (IXSContentType)node;
99
                }
100
                return null;
101
        }
102

    
103
        /**
104
         * @return The extension mapping
105
         * @throws TypeNotFoundException
106
         */
107
        private SchemaObjectsMapping getContentMapping(){
108
                SchemaObjectsMapping elementTm = new SchemaObjectsMapping(getSchema());
109
                elementTm.addType(SchemaTags.COMPLEX_CONTENT, XSComplexContentImpl.class);
110
                elementTm.addType(SchemaTags.SIMPLE_CONTENT, XSComplexContentImpl.class);
111
                return elementTm;
112
        }
113
        
114
        /*
115
         * (non-Javadoc)
116
         * @see org.gvsig.gpe.schema.som.IXSComplexTypeDefinition#getGroup()
117
         */
118
        public IXSGroup getGroup(){
119
                IXSNode node = new SchemaCollection(getSchema(),getElement(),getGroupMapping()).getFirstNode();
120
                if (node != null){
121
                        return (IXSGroup)node;
122
                }
123
                return null;
124
        }
125
        
126
        /**
127
         * @return The extension mapping
128
         * @throws TypeNotFoundException
129
         */
130
        private SchemaObjectsMapping getGroupMapping(){
131
                SchemaObjectsMapping elementTm = new SchemaObjectsMapping(getSchema());
132
                elementTm.addType(SchemaTags.SEQUENCE, XSSequenceImpl.class);
133
                elementTm.addType(SchemaTags.ALL, XSAllImpl.class);
134
                elementTm.addType(SchemaTags.GROUP, XSGroupImpl.class);
135
                elementTm.addType(SchemaTags.CHOICE, XSChoiceImpl.class);
136
                return elementTm;
137
        }
138
        
139
        /**
140
         * Adds a new element to the complex type
141
         */
142
        public IXSElementDeclaration addElement(String name, String typeName, boolean nillable, int minOccurs, int maxOccurs){
143
                IXSElement eElement = getElementsFactory().createElement(getSchema(),
144
                                name,
145
                                typeName,
146
                                nillable,
147
                                minOccurs,
148
                                maxOccurs);
149
                getElementsFactory().addElementToComplexType(
150
                                getSchema(),
151
                                eElement, 
152
                                getElement());        
153
                XSElementDeclarationImpl elementDeclaration = new XSElementDeclarationImpl(getSchema());
154
                elementDeclaration.setElement(eElement);
155
                return elementDeclaration;
156
        }
157
        
158
        /*
159
         * (non-Javadoc)
160
         * @see org.gvsig.gpe.schema.som.IXSComplexTypeDefinition#addElement(java.lang.String, java.lang.String)
161
         */
162
        public IXSElementDeclaration addElement(String name, String typeName) {
163
                return addElement(name, typeName, SchemaDefaults.ELEMENT_NILLABLE,
164
                                SchemaDefaults.ELEMENT_MIN_OCCURS, SchemaDefaults.ELEMENT_MAX_OCCURS);
165
        }
166

    
167
        /*
168
         * (non-Javadoc)
169
         * @see org.gvsig.gpe.schema.som.IXSTypeDefinition#getTypeName()
170
         */
171
        public String getTypeName() {
172
                return getElement().getAttribute(SchemaTags.NAME);                
173
        }
174
        
175
    public DataType getDataType() {
176
        // TODO Auto-generated method stub
177
        return null;
178
    }
179
    
180
    public boolean isComplex(){
181
        return true;
182
    }
183
}