Revision 28543
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteClient/wfs/schema/XMLTypesFactory.java | ||
---|---|---|
145 | 145 |
while(it.hasNext()){ |
146 | 146 |
String key = (String)it.next(); |
147 | 147 |
String[] parts = key.split(":"); |
148 |
if (parts.length > 1){ |
|
148 |
if (parts.length == 1){ |
|
149 |
if (parts[0].compareTo(typeAux.toUpperCase())==0){ |
|
150 |
return (IXMLType)types.get(key); |
|
151 |
} |
|
152 |
}else if (parts.length > 1){ |
|
149 | 153 |
if (parts[parts.length-1].compareTo(typeAux.toUpperCase())==0){ |
150 | 154 |
return (IXMLType)types.get(key); |
151 | 155 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteClient/wfs/schema/XMLSchemaParser.java | ||
---|---|---|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.io.FileReader; |
5 | 5 |
import java.io.IOException; |
6 |
import java.util.Hashtable; |
|
7 |
import java.util.Iterator; |
|
8 |
import java.util.Set; |
|
9 |
import java.util.Vector; |
|
10 | 6 |
|
11 | 7 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
12 | 8 |
import org.gvsig.remoteClient.utils.EncodingXMLParser; |
... | ... | |
99 | 95 |
private String schema = ""; |
100 | 96 |
private String encoding = "UTF-8"; |
101 | 97 |
private String nameSpace = ""; |
102 |
private Hashtable attributes = null; |
|
103 | 98 |
private String version = null; |
104 | 99 |
|
105 | 100 |
|
106 | 101 |
public XMLSchemaParser(){ |
107 |
super(); |
|
108 |
//initializes a new hash table for many namespace to store the defined types |
|
109 |
attributes = new Hashtable(); |
|
102 |
super(); |
|
110 | 103 |
} |
111 | 104 |
|
112 | 105 |
public XMLSchemaParser(String schema){ |
113 | 106 |
super(); |
114 | 107 |
//schema instace is named with the string in "schema" |
115 |
this.schema = schema; |
|
116 |
attributes = new Hashtable(); |
|
108 |
this.schema = schema; |
|
117 | 109 |
} |
118 | 110 |
|
119 | 111 |
/** |
... | ... | |
304 | 296 |
if (getAttributeName(i).compareTo(GMLTags.GML_NAME) == 0){ |
305 | 297 |
// inserts a new complex type inside the namespace |
306 | 298 |
XMLComplexType complexType = XMLTypesFactory.addComplexType(nameSpace,getAttributeValue(i)); |
307 |
parseComplexType(complexType); |
|
308 |
attributes.put(complexType.getName(),complexType); |
|
299 |
parseComplexType(complexType); |
|
309 | 300 |
} |
310 | 301 |
|
311 | 302 |
} |
... | ... | |
321 | 312 |
* Etiqueta <element> * |
322 | 313 |
************************/ |
323 | 314 |
else if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){ |
324 |
XMLElement entity = XMLElementsFactory.addType(this); |
|
325 |
try{ |
|
326 |
//Sets the name and type of one element |
|
327 |
attributes.put(entity.getName(),entity.getEntityType()); |
|
328 |
}catch(NullPointerException e){ |
|
329 |
//Type not defined yet, do nothing here because the type will be declared later |
|
330 |
} |
|
315 |
XMLElement entity = XMLElementsFactory.addType(this); |
|
331 | 316 |
} |
332 | 317 |
break; |
333 | 318 |
case KXmlParser.END_TAG: |
... | ... | |
500 | 485 |
String attName = getAttributeName(i); |
501 | 486 |
String attValue = getAttributeValue(i); |
502 | 487 |
if (CapabilitiesTags.BASE.equals(attName)){ |
503 |
attributes.put(complexType.getName(),attValue);
|
|
488 |
complexType.setBaseType(attValue);
|
|
504 | 489 |
} |
505 | 490 |
} |
506 | 491 |
|
... | ... | |
581 | 566 |
if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){ |
582 | 567 |
XMLElement element = new XMLElement(this); |
583 | 568 |
if (element != null){ |
584 |
complexType.addSubtypes(element);
|
|
569 |
complexType.addElements(element);
|
|
585 | 570 |
} |
586 | 571 |
elemento_previo=element; |
587 | 572 |
} |
... | ... | |
634 | 619 |
if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){ |
635 | 620 |
XMLElement element = new XMLElement(this); |
636 | 621 |
if (element != null){ |
637 |
complexType.addSubtypes(element);
|
|
622 |
complexType.addElements(element);
|
|
638 | 623 |
} |
639 | 624 |
} |
640 | 625 |
break; |
... | ... | |
651 | 636 |
} |
652 | 637 |
} |
653 | 638 |
|
654 |
/** |
|
655 |
* @return Returns the attributes. |
|
656 |
*/ |
|
657 |
public Hashtable getAttributes() { |
|
658 |
return attributes; |
|
659 |
} |
|
660 |
|
|
661 |
public Vector getAttributesList(){ |
|
662 |
Vector vector = new Vector(); |
|
663 |
Set keys = attributes.keySet(); |
|
664 |
Iterator it = keys.iterator(); |
|
665 |
while(it.hasNext()){ |
|
666 |
vector.add(attributes.get((String)it.next())); |
|
667 |
} |
|
668 |
return vector; |
|
669 |
} |
|
670 |
|
|
671 | 639 |
public String getversion() { |
672 | 640 |
if (version == null){ |
673 | 641 |
//return the default GML version |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteClient/wfs/schema/type/XMLComplexType.java | ||
---|---|---|
1 | 1 |
package org.gvsig.remoteClient.wfs.schema.type; |
2 | 2 |
|
3 |
import java.util.HashMap; |
|
3 | 4 |
import java.util.Iterator; |
4 | 5 |
import java.util.LinkedHashMap; |
5 | 6 |
import java.util.Map; |
... | ... | |
7 | 8 |
import java.util.Vector; |
8 | 9 |
|
9 | 10 |
import org.gvsig.remoteClient.wfs.schema.XMLElement; |
11 |
import org.gvsig.remoteClient.wfs.schema.XMLTypesFactory; |
|
10 | 12 |
|
11 | 13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
12 | 14 |
* |
... | ... | |
96 | 98 |
public static int CHOICE_TYPE = 1; |
97 | 99 |
|
98 | 100 |
private String type = null; |
99 |
private LinkedHashMap attributes = null; |
|
101 |
private LinkedHashMap baseElements = null; |
|
102 |
private String baseType = null; |
|
103 |
|
|
100 | 104 |
private int attributesType = 0; |
101 | 105 |
|
102 | 106 |
public XMLComplexType(String type) { |
103 | 107 |
super(); |
104 | 108 |
this.type = type; |
105 |
attributes = new LinkedHashMap();
|
|
109 |
baseElements = new LinkedHashMap();
|
|
106 | 110 |
} |
107 | 111 |
|
108 | 112 |
/* |
... | ... | |
125 | 129 |
* @return Returns the subtypes. |
126 | 130 |
*/ |
127 | 131 |
public Map getSubtypes() { |
128 |
return attributes;
|
|
132 |
return baseElements;
|
|
129 | 133 |
} |
130 | 134 |
|
131 | 135 |
/** |
132 | 136 |
* @param subtypes The subtypes to set. |
133 | 137 |
*/ |
134 |
public void addSubtypes(XMLElement element) {
|
|
138 |
public void addElements(XMLElement element) {
|
|
135 | 139 |
if (element.getName() != null){ |
136 |
this.attributes.put(element.getName(),element);
|
|
140 |
this.baseElements.put(element.getName(),element);
|
|
137 | 141 |
} |
138 | 142 |
} |
139 | 143 |
|
144 |
|
|
140 | 145 |
/** |
141 | 146 |
* |
142 | 147 |
* @param name |
143 | 148 |
* @return |
144 | 149 |
*/ |
145 | 150 |
public XMLElement getAttribute(String name){ |
146 |
return (XMLElement)attributes.get(name);
|
|
151 |
return (XMLElement)baseElements.get(name);
|
|
147 | 152 |
} |
148 | 153 |
|
149 | 154 |
/** |
150 | 155 |
* @return Returns the vElements. |
151 | 156 |
*/ |
152 | 157 |
public Vector getAttributes() { |
153 |
Set keys = attributes.keySet();
|
|
158 |
Set keys = baseElements.keySet();
|
|
154 | 159 |
Iterator it = keys.iterator(); |
155 | 160 |
Vector vector = new Vector(); |
156 | 161 |
while(it.hasNext()){ |
157 |
vector.add(attributes.get((String)it.next()));
|
|
162 |
vector.add(baseElements.get((String)it.next()));
|
|
158 | 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 |
} |
|
159 | 175 |
return vector; |
160 | 176 |
} |
161 | 177 |
|
... | ... | |
165 | 181 |
|
166 | 182 |
public void setAttributesType(int attributesType) { |
167 | 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; |
|
168 | 191 |
} |
169 | 192 |
|
170 |
|
|
171 |
|
|
172 | 193 |
} |
Also available in: Unified diff