Revision 8017
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/factories/XMLTypesFactory.java | ||
---|---|---|
1 | 1 |
package org.gvsig.remoteClient.gml.factories; |
2 | 2 |
|
3 | 3 |
import java.util.Hashtable; |
4 |
import java.util.Iterator; |
|
4 | 5 |
import java.util.Set; |
5 | 6 |
|
6 | 7 |
import org.gvsig.remoteClient.gml.schemas.GMLGeometryType; |
... | ... | |
52 | 53 |
* |
53 | 54 |
* $Id$ |
54 | 55 |
* $Log$ |
55 |
* Revision 1.3 2006-10-02 08:33:49 jorpiell |
|
56 |
* Revision 1.4 2006-10-10 12:52:28 jorpiell |
|
57 |
* Soporte para features complejas. |
|
58 |
* |
|
59 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
56 | 60 |
* Cambios del 10 copiados al head |
57 | 61 |
* |
58 | 62 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell |
... | ... | |
97 | 101 |
* @return |
98 | 102 |
*/ |
99 | 103 |
public static IXMLType getType(String type){ |
100 |
return (IXMLType)types.get(type.toUpperCase()); |
|
104 |
IXMLType xmlType = (IXMLType)types.get(type.toUpperCase()); |
|
105 |
if (xmlType == null){ |
|
106 |
xmlType = getTypeWithOutNameSpace(type); |
|
107 |
} |
|
108 |
return xmlType; |
|
101 | 109 |
} |
102 | 110 |
|
103 | 111 |
/** |
112 |
* This method is used to solve some mistakes. It doesn't |
|
113 |
* consider the namespace |
|
114 |
* @param type |
|
115 |
* @return |
|
116 |
*/ |
|
117 |
public static IXMLType getTypeWithOutNameSpace(String type){ |
|
118 |
Set keys = types.keySet(); |
|
119 |
Iterator it = keys.iterator(); |
|
120 |
while(it.hasNext()){ |
|
121 |
String key = (String)it.next(); |
|
122 |
String[] parts = key.split(":"); |
|
123 |
if (parts.length > 1){ |
|
124 |
if (parts[1].compareTo(type.toUpperCase())==0){ |
|
125 |
return (IXMLType)types.get(key); |
|
126 |
} |
|
127 |
} |
|
128 |
} |
|
129 |
return null; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
104 | 133 |
* Adds a new type |
105 | 134 |
* @param type |
106 | 135 |
* type to add |
... | ... | |
117 | 146 |
* Complex type name |
118 | 147 |
* @return |
119 | 148 |
*/ |
120 |
public static XMLComplexType addCompleyType(String nameSpace,String name){
|
|
149 |
public static XMLComplexType addComplexType(String nameSpace,String name){
|
|
121 | 150 |
XMLComplexType complexType = new XMLComplexType(nameSpace + ":" + name); |
122 | 151 |
addType(complexType); |
123 | 152 |
return complexType; |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/factories/XMLElementsFactory.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.util.Hashtable; |
5 |
import java.util.Iterator; |
|
6 |
import java.util.Map; |
|
7 |
import java.util.Set; |
|
5 | 8 |
|
9 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
|
10 |
import org.gvsig.remoteClient.gml.schemas.XMLComplexType; |
|
6 | 11 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
7 | 12 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
8 | 13 |
import org.xmlpull.v1.XmlPullParserException; |
... | ... | |
51 | 56 |
* |
52 | 57 |
* $Id$ |
53 | 58 |
* $Log$ |
54 |
* Revision 1.1 2006-08-10 12:00:49 jorpiell |
|
59 |
* Revision 1.2 2006-10-10 12:52:28 jorpiell |
|
60 |
* Soporte para features complejas. |
|
61 |
* |
|
62 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
55 | 63 |
* Primer commit del driver de Gml |
56 | 64 |
* |
57 | 65 |
* |
... | ... | |
67 | 75 |
private static Hashtable elements = new Hashtable(); |
68 | 76 |
|
69 | 77 |
public static XMLElement getElement(String name){ |
78 |
if (name == null){ |
|
79 |
return null; |
|
80 |
} |
|
70 | 81 |
return (XMLElement)elements.get(name.toUpperCase()); |
71 | 82 |
} |
72 | 83 |
|
... | ... | |
97 | 108 |
/** |
98 | 109 |
* Just for degug. It prints all the registred components. |
99 | 110 |
*/ |
100 |
public static void printElements(){
|
|
111 |
public static void printEntities(){
|
|
101 | 112 |
System.out.println("*** ELEMENTOS ***"); |
102 | 113 |
Object[] keys = elements.keySet().toArray(); |
103 | 114 |
for (int i=0 ; i<elements.size() ; i++){ |
104 |
XMLElement element = (XMLElement)elements.get(keys[i]); |
|
105 |
System.out.print("NAME: " + element.getName()); |
|
106 |
if (element.getType() != null){ |
|
107 |
System.out.print(" TYPE: " + element.getType().getName()); |
|
115 |
XMLElement entity = (XMLElement)elements.get(keys[i]); |
|
116 |
printEntity(entity,0); |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
public static void printEntity(XMLElement entity,int level){ |
|
121 |
String tab = ""; |
|
122 |
for (int i=0 ; i<level ; i++){ |
|
123 |
tab = tab + "\t"; |
|
124 |
} |
|
125 |
System.out.print(tab + "NAME: " + entity.getName()); |
|
126 |
if (entity.getEntityType() != null){ |
|
127 |
System.out.print(" TYPE: " + entity.getEntityType().getName() + "\n"); |
|
128 |
if (entity.getEntityType().getType() == IXMLType.COMPLEX){ |
|
129 |
Map children = ((XMLComplexType)entity.getEntityType()).getSubtypes(); |
|
130 |
Set childrenKeys = children.keySet(); |
|
131 |
Iterator it = childrenKeys.iterator(); |
|
132 |
level++; |
|
133 |
while(it.hasNext()){ |
|
134 |
String child = (String)it.next(); |
|
135 |
XMLElement eChild = (XMLElement)children.get(child); |
|
136 |
printEntity(eChild,level); |
|
137 |
} |
|
108 | 138 |
} |
109 |
System.out.print("\n"); |
|
139 |
}else{ |
|
140 |
System.out.print(" TYPE: ERROR \n"); |
|
110 | 141 |
} |
142 |
|
|
111 | 143 |
} |
144 |
|
|
112 | 145 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/schemas/XMLComplexType.java | ||
---|---|---|
1 | 1 |
package org.gvsig.remoteClient.gml.schemas; |
2 | 2 |
|
3 |
import java.util.Hashtable; |
|
3 |
import java.util.Iterator; |
|
4 |
import java.util.LinkedHashMap; |
|
5 |
import java.util.Map; |
|
6 |
import java.util.Set; |
|
4 | 7 |
import java.util.Vector; |
5 | 8 |
|
6 | 9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
... | ... | |
47 | 50 |
* |
48 | 51 |
* $Id$ |
49 | 52 |
* $Log$ |
50 |
* Revision 1.4 2006-10-02 08:33:49 jorpiell |
|
53 |
* Revision 1.5 2006-10-10 12:52:28 jorpiell |
|
54 |
* Soporte para features complejas. |
|
55 |
* |
|
56 |
* Revision 1.4 2006/10/02 08:33:49 jorpiell |
|
51 | 57 |
* Cambios del 10 copiados al head |
52 | 58 |
* |
53 | 59 |
* Revision 1.2.2.1 2006/09/19 12:23:15 jorpiell |
... | ... | |
71 | 77 |
*/ |
72 | 78 |
public class XMLComplexType implements IXMLType { |
73 | 79 |
private String type = null; |
74 |
private Hashtable elements = null; |
|
75 |
private Vector vElements = null; |
|
76 |
|
|
80 |
private LinkedHashMap attributes = null; |
|
81 |
|
|
77 | 82 |
public XMLComplexType(String type) { |
78 | 83 |
super(); |
79 | 84 |
this.type = type; |
80 |
elements = new Hashtable(); |
|
81 |
vElements = new Vector(); |
|
85 |
attributes = new LinkedHashMap(); |
|
82 | 86 |
} |
83 | 87 |
|
84 | 88 |
/* |
... | ... | |
100 | 104 |
/** |
101 | 105 |
* @return Returns the subtypes. |
102 | 106 |
*/ |
103 |
public Hashtable getSubtypes() {
|
|
104 |
return elements;
|
|
107 |
public Map getSubtypes() {
|
|
108 |
return attributes;
|
|
105 | 109 |
} |
106 | 110 |
|
107 | 111 |
/** |
... | ... | |
109 | 113 |
*/ |
110 | 114 |
public void addSubtypes(XMLElement element) { |
111 | 115 |
if (element.getName() != null){ |
112 |
this.elements.put(element.getName(),element);
|
|
116 |
this.attributes.put(element.getName(),element);
|
|
113 | 117 |
} |
114 | 118 |
} |
115 | 119 |
|
... | ... | |
118 | 122 |
* @param name |
119 | 123 |
* @return |
120 | 124 |
*/ |
121 |
public XMLElement getElement(String name){
|
|
122 |
return (XMLElement)elements.get(name);
|
|
125 |
public XMLElement getAttribute(String name){
|
|
126 |
return (XMLElement)attributes.get(name);
|
|
123 | 127 |
} |
124 | 128 |
|
125 | 129 |
/** |
126 | 130 |
* @return Returns the vElements. |
127 | 131 |
*/ |
128 |
public Vector getVElements() { |
|
129 |
return vElements; |
|
132 |
public Vector getAttributes() { |
|
133 |
Set keys = attributes.keySet(); |
|
134 |
Iterator it = keys.iterator(); |
|
135 |
Vector vector = new Vector(); |
|
136 |
while(it.hasNext()){ |
|
137 |
vector.add(attributes.get((String)it.next())); |
|
138 |
} |
|
139 |
return vector; |
|
130 | 140 |
} |
131 | 141 |
|
132 | 142 |
|
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/schemas/XMLElement.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
|
5 |
import org.gvsig.remoteClient.gml.GMLTags; |
|
6 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
|
5 | 7 |
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory; |
6 | 8 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
7 |
import org.gvsig.remoteClient.wfs.WFSSchemaParser; |
|
8 |
import org.gvsig.remoteClient.wfs.WFSAttribute.Type; |
|
9 | 9 |
import org.kxml2.io.KXmlParser; |
10 | 10 |
import org.xmlpull.v1.XmlPullParserException; |
11 | 11 |
|
... | ... | |
53 | 53 |
* |
54 | 54 |
* $Id$ |
55 | 55 |
* $Log$ |
56 |
* Revision 1.2 2006-08-29 08:43:13 jorpiell |
|
56 |
* Revision 1.3 2006-10-10 12:52:28 jorpiell |
|
57 |
* Soporte para features complejas. |
|
58 |
* |
|
59 |
* Revision 1.2 2006/08/29 08:43:13 jorpiell |
|
57 | 60 |
* Dos peque?os cambios para tener en cuenta las referencias |
58 | 61 |
* |
59 | 62 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
... | ... | |
73 | 76 |
private String typeUnknown = null; |
74 | 77 |
private int minOccurs = -1; |
75 | 78 |
private int maxOccurs = -1; |
79 |
private int totalDigits = 0; |
|
80 |
private int fractionDigits = 0; |
|
76 | 81 |
|
77 |
|
|
78 | 82 |
public XMLElement(XMLSchemaParser parser) throws XmlPullParserException, IOException { |
79 | 83 |
super(); |
80 | 84 |
parse(parser); |
... | ... | |
124 | 128 |
/** |
125 | 129 |
* @return Returns the type. |
126 | 130 |
*/ |
127 |
public IXMLType getType() { |
|
131 |
public IXMLType getEntityType() {
|
|
128 | 132 |
if (type != null){ |
129 | 133 |
return type; |
130 | 134 |
} |
131 |
this.type = XMLTypesFactory.getType(typeUnknown); |
|
135 |
if (typeUnknown != null){ |
|
136 |
this.type = XMLTypesFactory.getType(typeUnknown); |
|
137 |
} |
|
138 |
if ((type == null) && (typeUnknown != null)){ |
|
139 |
if (typeUnknown.split(":").length > 1){ |
|
140 |
this.type = XMLTypesFactory.getType(null + ":" + typeUnknown.split(":")[1]); |
|
141 |
} |
|
142 |
} |
|
132 | 143 |
return type; |
133 | 144 |
|
134 | 145 |
} |
135 | 146 |
/** |
136 | 147 |
* @param type The type to set. |
137 | 148 |
*/ |
138 |
public void setType(String type) { |
|
149 |
public void setEntityType(String type) {
|
|
139 | 150 |
IXMLType xmlType = XMLTypesFactory.getType(type); |
140 | 151 |
if (xmlType == null){ |
141 | 152 |
String[] types = type.split(":"); |
... | ... | |
172 | 183 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_NAME) == 0){ |
173 | 184 |
setName(parser.getAttributeValue(i)); |
174 | 185 |
}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_TYPE) == 0){ |
175 |
setType(parser.getAttributeValue(i)); |
|
186 |
setEntityType(parser.getAttributeValue(i));
|
|
176 | 187 |
}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_MAXOCCURS) == 0){ |
177 | 188 |
try{ |
178 | 189 |
setMaxOccurs(Integer.parseInt(parser.getAttributeValue(i))); |
... | ... | |
188 | 199 |
}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_REF) == 0){ |
189 | 200 |
setReference(parser.getAttributeValue(i)); |
190 | 201 |
} |
191 |
} |
|
202 |
} |
|
203 |
|
|
192 | 204 |
} |
205 |
|
|
206 |
private void parseSimpleType(XMLSchemaParser parser) throws IOException, XmlPullParserException |
|
207 |
{ |
|
208 |
int currentTag; |
|
209 |
boolean end = false; |
|
210 |
currentTag = parser.getEventType(); |
|
211 |
|
|
212 |
while (!end) |
|
213 |
{ |
|
214 |
switch(currentTag) |
|
215 |
{ |
|
216 |
case KXmlParser.START_TAG: |
|
217 |
if (parser.getName().compareTo(CapabilitiesTags.RESTRICTION)==0){ |
|
218 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
219 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.BASE) == 0){ |
|
220 |
setEntityType(parser.getAttributeValue(i)); |
|
221 |
} |
|
222 |
} |
|
223 |
parseRestriction(parser); |
|
224 |
} |
|
225 |
break; |
|
226 |
case KXmlParser.END_TAG: |
|
227 |
if (parser.getName().compareTo(CapabilitiesTags.SIMPLETYPE) == 0) |
|
228 |
end = true; |
|
229 |
break; |
|
230 |
case KXmlParser.TEXT: |
|
231 |
break; |
|
232 |
} |
|
233 |
if (!end){ |
|
234 |
currentTag = parser.next(); |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
private void parseRestriction(XMLSchemaParser parser) throws IOException, XmlPullParserException |
|
240 |
{ |
|
241 |
int currentTag; |
|
242 |
boolean end = false; |
|
243 |
|
|
244 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.RESTRICTION); |
|
245 |
currentTag = parser.next(); |
|
246 |
|
|
247 |
while (!end) |
|
248 |
{ |
|
249 |
switch(currentTag) |
|
250 |
{ |
|
251 |
case KXmlParser.START_TAG: |
|
252 |
if (parser.getName().compareTo(CapabilitiesTags.TOTAL_DIGITS)==0) |
|
253 |
{ |
|
254 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
255 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.VALUE) == 0){ |
|
256 |
setTotalDigits(Integer.parseInt(parser.getAttributeValue(i))); |
|
257 |
} |
|
258 |
} |
|
259 |
}else if (parser.getName().compareTo(CapabilitiesTags.FRACTION_DIGITS)==0){ |
|
260 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
261 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.VALUE) == 0){ |
|
262 |
setFractionDigits(Integer.parseInt(parser.getAttributeValue(i))); |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
break; |
|
267 |
case KXmlParser.END_TAG: |
|
268 |
if (parser.getName().compareTo(CapabilitiesTags.RESTRICTION) == 0) |
|
269 |
end = true; |
|
270 |
break; |
|
271 |
case KXmlParser.TEXT: |
|
272 |
break; |
|
273 |
} |
|
274 |
if (!end){ |
|
275 |
currentTag = parser.next(); |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
193 | 279 |
|
194 | 280 |
/** |
195 | 281 |
* @return Returns the reference. |
... | ... | |
203 | 289 |
*/ |
204 | 290 |
public void setReference(String reference) { |
205 | 291 |
this.reference = reference; |
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* @return Returns the fractionDigits. |
|
296 |
*/ |
|
297 |
public int getFractionDigits() { |
|
298 |
return fractionDigits; |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* @param fractionDigits The fractionDigits to set. |
|
303 |
*/ |
|
304 |
public void setFractionDigits(int fractionDigits) { |
|
305 |
this.fractionDigits = fractionDigits; |
|
306 |
} |
|
307 |
|
|
308 |
/** |
|
309 |
* @return Returns the totalDigits. |
|
310 |
*/ |
|
311 |
public int getTotalDigits() { |
|
312 |
return totalDigits; |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* @param totalDigits The totalDigits to set. |
|
317 |
*/ |
|
318 |
public void setTotalDigits(int totalDigits) { |
|
319 |
this.totalDigits = totalDigits; |
|
206 | 320 |
} |
321 |
|
|
322 |
|
|
207 | 323 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/schemas/XMLSimpleType.java | ||
---|---|---|
51 | 51 |
* |
52 | 52 |
* $Id$ |
53 | 53 |
* $Log$ |
54 |
* Revision 1.3 2006-10-02 08:33:49 jorpiell |
|
54 |
* Revision 1.4 2006-10-10 12:52:28 jorpiell |
|
55 |
* Soporte para features complejas. |
|
56 |
* |
|
57 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
55 | 58 |
* Cambios del 10 copiados al head |
56 | 59 |
* |
57 | 60 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell |
... | ... | |
80 | 83 |
public static final String INT = "XS:INT"; |
81 | 84 |
|
82 | 85 |
private String type = null; |
83 |
private int totalDigits = 0; |
|
84 |
private int fractionDigits = 0; |
|
86 |
|
|
85 | 87 |
|
86 | 88 |
|
87 |
|
|
88 | 89 |
public XMLSimpleType(String type) { |
89 | 90 |
super(); |
90 | 91 |
this.type = type; |
... | ... | |
104 | 105 |
*/ |
105 | 106 |
public int getType() { |
106 | 107 |
return IXMLType.SIMPLE; |
107 |
} |
|
108 |
}
|
|
108 | 109 |
|
109 | 110 |
/** |
110 |
* @return Returns the fractionDigits. |
|
111 |
*/ |
|
112 |
public int getFractionDigits() { |
|
113 |
return fractionDigits; |
|
114 |
} |
|
115 |
/** |
|
116 |
* @param fractionDigits The fractionDigits to set. |
|
117 |
*/ |
|
118 |
public void setFractionDigits(int fractionDigits) { |
|
119 |
this.fractionDigits = fractionDigits; |
|
120 |
} |
|
121 |
/** |
|
122 |
* @return Returns the totalDigits. |
|
123 |
*/ |
|
124 |
public int getTotalDigits() { |
|
125 |
return totalDigits; |
|
126 |
} |
|
127 |
/** |
|
128 |
* @param totalDigits The totalDigits to set. |
|
129 |
*/ |
|
130 |
public void setTotalDigits(int totalDigits) { |
|
131 |
this.totalDigits = totalDigits; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 | 111 |
* @param type The type to set. |
136 | 112 |
*/ |
137 | 113 |
public void setType(String type) { |
... | ... | |
157 | 133 |
return value; |
158 | 134 |
} |
159 | 135 |
|
160 |
private void parseSimpleType(XMLSchemaParser parser) throws IOException, XmlPullParserException |
|
161 |
{ |
|
162 |
int currentTag; |
|
163 |
boolean end = false; |
|
164 |
|
|
165 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SIMPLETYPE); |
|
166 |
currentTag = parser.next(); |
|
167 |
|
|
168 |
while (!end) |
|
169 |
{ |
|
170 |
switch(currentTag) |
|
171 |
{ |
|
172 |
case KXmlParser.START_TAG: |
|
173 |
if (parser.getName().compareTo(CapabilitiesTags.RESTRICTION)==0) |
|
174 |
{ |
|
175 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
176 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.BASE) == 0){ |
|
177 |
setType(parser.getAttributeValue(i)); |
|
178 |
} |
|
179 |
} |
|
180 |
parseRestriction(parser); |
|
181 |
} |
|
182 |
break; |
|
183 |
case KXmlParser.END_TAG: |
|
184 |
if (parser.getName().compareTo(CapabilitiesTags.SIMPLETYPE) == 0) |
|
185 |
end = true; |
|
186 |
break; |
|
187 |
case KXmlParser.TEXT: |
|
188 |
break; |
|
189 |
} |
|
190 |
if (!end){ |
|
191 |
currentTag = parser.next(); |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 | 136 |
|
196 |
private void parseRestriction(XMLSchemaParser parser) throws IOException, XmlPullParserException |
|
197 |
{ |
|
198 |
int currentTag; |
|
199 |
boolean end = false; |
|
200 |
|
|
201 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.RESTRICTION); |
|
202 |
currentTag = parser.next(); |
|
203 |
|
|
204 |
while (!end) |
|
205 |
{ |
|
206 |
switch(currentTag) |
|
207 |
{ |
|
208 |
case KXmlParser.START_TAG: |
|
209 |
if (parser.getName().compareTo(CapabilitiesTags.TOTAL_DIGITS)==0) |
|
210 |
{ |
|
211 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
212 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.VALUE) == 0){ |
|
213 |
setTotalDigits(Integer.parseInt(parser.getAttributeValue(i))); |
|
214 |
} |
|
215 |
} |
|
216 |
}else if (parser.getName().compareTo(CapabilitiesTags.FRACTION_DIGITS)==0){ |
|
217 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
218 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.VALUE) == 0){ |
|
219 |
setFractionDigits(Integer.parseInt(parser.getAttributeValue(i))); |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
223 |
break; |
|
224 |
case KXmlParser.END_TAG: |
|
225 |
if (parser.getName().compareTo(CapabilitiesTags.RESTRICTION) == 0) |
|
226 |
end = true; |
|
227 |
break; |
|
228 |
case KXmlParser.TEXT: |
|
229 |
break; |
|
230 |
} |
|
231 |
if (!end){ |
|
232 |
currentTag = parser.next(); |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 | 137 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/schemas/XMLSchemaParser.java | ||
---|---|---|
7 | 7 |
import java.io.FileReader; |
8 | 8 |
import java.io.IOException; |
9 | 9 |
import java.util.Hashtable; |
10 |
import java.util.Iterator; |
|
11 |
import java.util.Set; |
|
12 |
import java.util.Vector; |
|
10 | 13 |
|
11 | 14 |
import org.gvsig.remoteClient.gml.GMLTags; |
12 | 15 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
13 | 16 |
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory; |
14 | 17 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
15 |
import org.gvsig.remoteClient.wfs.WFSAttribute; |
|
16 |
import org.gvsig.remoteClient.wfs.WFSSchemaParser; |
|
17 | 18 |
import org.kxml2.io.KXmlParser; |
18 | 19 |
import org.xmlpull.v1.XmlPullParserException; |
19 | 20 |
|
... | ... | |
61 | 62 |
* |
62 | 63 |
* $Id$ |
63 | 64 |
* $Log$ |
64 |
* Revision 1.3 2006-10-02 08:33:49 jorpiell |
|
65 |
* Revision 1.4 2006-10-10 12:52:28 jorpiell |
|
66 |
* Soporte para features complejas. |
|
67 |
* |
|
68 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
65 | 69 |
* Cambios del 10 copiados al head |
66 | 70 |
* |
67 | 71 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell |
... | ... | |
85 | 89 |
public class XMLSchemaParser extends KXmlParser { |
86 | 90 |
private String schema = ""; |
87 | 91 |
private String encoding = "UTF-8"; |
92 |
private String nameSpace = ""; |
|
93 |
private Hashtable attributes = null; |
|
88 | 94 |
|
89 | 95 |
public XMLSchemaParser(){ |
90 | 96 |
super(); |
97 |
attributes = new Hashtable(); |
|
91 | 98 |
} |
92 | 99 |
|
93 | 100 |
public XMLSchemaParser(String schema){ |
101 |
super(); |
|
94 | 102 |
this.schema = schema; |
103 |
attributes = new Hashtable(); |
|
95 | 104 |
} |
96 | 105 |
|
97 | 106 |
/** |
... | ... | |
163 | 172 |
} |
164 | 173 |
|
165 | 174 |
public void parse(File f,String nameSpace) { |
175 |
this.nameSpace = nameSpace; |
|
166 | 176 |
FileReader reader = null; |
167 | 177 |
try |
168 | 178 |
{ |
... | ... | |
204 | 214 |
if (getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0){ |
205 | 215 |
for (int i=0 ; i<getAttributeCount() ; i++){ |
206 | 216 |
if (getAttributeName(i).compareTo(GMLTags.GML_NAME) == 0){ |
207 |
XMLComplexType complexType = XMLTypesFactory.addCompleyType(nameSpace,getAttributeValue(i)); |
|
208 |
parseComplexType(complexType); |
|
217 |
XMLComplexType complexType = XMLTypesFactory.addComplexType(nameSpace,getAttributeValue(i)); |
|
218 |
parseComplexType(complexType); |
|
219 |
attributes.put(complexType.getName(),complexType); |
|
209 | 220 |
} |
210 | 221 |
|
211 | 222 |
} |
212 | 223 |
} else if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){ |
213 |
XMLElementsFactory.addType(this); |
|
224 |
XMLElement entity = XMLElementsFactory.addType(this); |
|
225 |
try{ |
|
226 |
attributes.put(entity.getName(),entity.getEntityType()); |
|
227 |
}catch(NullPointerException e){ |
|
228 |
//Type not defined |
|
229 |
} |
|
230 |
|
|
214 | 231 |
} |
215 | 232 |
break; |
216 | 233 |
case KXmlParser.END_TAG: |
... | ... | |
248 | 265 |
switch(currentTag) |
249 | 266 |
{ |
250 | 267 |
case KXmlParser.START_TAG: |
251 |
if (getName().compareTo(CapabilitiesTags.COMPLEXCONTENT)==0) |
|
252 |
{ |
|
268 |
if (getName().compareTo(CapabilitiesTags.COMPLEXCONTENT)==0){ |
|
253 | 269 |
parseComplexContent(complexType); |
254 |
} |
|
270 |
}else if(getName().compareTo(CapabilitiesTags.SEQUENCE)==0){ |
|
271 |
parseSequence(complexType); |
|
272 |
} |
|
255 | 273 |
break; |
256 | 274 |
case KXmlParser.END_TAG: |
257 | 275 |
if (getName().compareTo(CapabilitiesTags.COMPLEXTYPE) == 0) |
... | ... | |
263 | 281 |
if (!end){ |
264 | 282 |
currentTag = next(); |
265 | 283 |
} |
266 |
} |
|
284 |
}
|
|
267 | 285 |
} |
268 | 286 |
|
269 | 287 |
private void parseComplexContent(XMLComplexType complexType) throws IOException, XmlPullParserException |
... | ... | |
335 | 353 |
|
336 | 354 |
require(KXmlParser.START_TAG, null, CapabilitiesTags.SEQUENCE); |
337 | 355 |
currentTag = next(); |
338 |
|
|
356 |
|
|
339 | 357 |
while (!end) |
340 | 358 |
{ |
341 | 359 |
switch(currentTag) |
342 | 360 |
{ |
343 | 361 |
case KXmlParser.START_TAG: |
344 |
if (getName().compareTo(CapabilitiesTags.ELEMENT)==0) |
|
345 |
{ |
|
346 |
XMLElement element = XMLElementsFactory.addType(this); |
|
362 |
if (getName().compareTo(CapabilitiesTags.ELEMENT)==0){ |
|
363 |
XMLElement element = new XMLElement(this); |
|
347 | 364 |
if (element != null){ |
348 | 365 |
complexType.addSubtypes(element); |
349 | 366 |
} |
350 |
} |
|
367 |
}else if(getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0){ |
|
368 |
for (int i=0 ; i<getAttributeCount() ; i++){ |
|
369 |
if (getAttributeName(i).compareTo(GMLTags.GML_NAME) == 0){ |
|
370 |
XMLComplexType complexTypeChild = XMLTypesFactory.addComplexType(nameSpace,getAttributeValue(i)); |
|
371 |
parseComplexType(complexTypeChild); |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
351 | 375 |
break; |
352 | 376 |
case KXmlParser.END_TAG: |
353 | 377 |
if (getName().compareTo(CapabilitiesTags.SEQUENCE) == 0) |
... | ... | |
362 | 386 |
} |
363 | 387 |
} |
364 | 388 |
|
389 |
/** |
|
390 |
* @return Returns the attributes. |
|
391 |
*/ |
|
392 |
public Hashtable getAttributes() { |
|
393 |
return attributes; |
|
394 |
} |
|
365 | 395 |
|
396 |
public Vector getAttributesList(){ |
|
397 |
Vector vector = new Vector(); |
|
398 |
Set keys = attributes.keySet(); |
|
399 |
Iterator it = keys.iterator(); |
|
400 |
while(it.hasNext()){ |
|
401 |
vector.add(attributes.get((String)it.next())); |
|
402 |
} |
|
403 |
return vector; |
|
404 |
} |
|
405 |
|
|
406 |
|
|
366 | 407 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/v2/GMLFeaturesIterator_v2.java | ||
---|---|---|
6 | 6 |
import java.util.Vector; |
7 | 7 |
|
8 | 8 |
import org.gvsig.remoteClient.gml.GMLException; |
9 |
import org.gvsig.remoteClient.gml.GMLTags; |
|
9 | 10 |
import org.gvsig.remoteClient.gml.IGMLFeaturesIterator; |
10 | 11 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
11 | 12 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
... | ... | |
16 | 17 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
17 | 18 |
import org.gvsig.remoteClient.gml.schemas.XMLSimpleType; |
18 | 19 |
import org.gvsig.remoteClient.gml.utils.GMLUtilsParser; |
20 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
19 | 21 |
import org.kxml2.io.KXmlParser; |
20 | 22 |
import org.xmlpull.v1.XmlPullParserException; |
21 | 23 |
|
... | ... | |
63 | 65 |
* |
64 | 66 |
* $Id$ |
65 | 67 |
* $Log$ |
66 |
* Revision 1.3 2006-10-02 08:33:49 jorpiell |
|
68 |
* Revision 1.4 2006-10-10 12:52:28 jorpiell |
|
69 |
* Soporte para features complejas. |
|
70 |
* |
|
71 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
67 | 72 |
* Cambios del 10 copiados al head |
68 | 73 |
* |
69 | 74 |
* Revision 1.1.2.2 2006/09/25 11:35:15 jorpiell |
... | ... | |
178 | 183 |
int currentTag; |
179 | 184 |
boolean end = false; |
180 | 185 |
ArrayList params = new ArrayList(); |
181 |
ArrayList values = new ArrayList(); |
|
182 |
Hashtable duplicates = new Hashtable(); |
|
186 |
ArrayList values = new ArrayList(); |
|
183 | 187 |
Object geom = null; |
188 |
XMLElement entity = null; |
|
184 | 189 |
|
185 |
XMLElement element = XMLElementsFactory.getElement(elementName); |
|
186 |
if (element != null){ |
|
187 |
XMLComplexType elementType = (XMLComplexType)element.getType(); |
|
188 |
try{ |
|
189 |
currentTag = getParser().next(); |
|
190 |
while (!end){ |
|
191 |
switch(currentTag){ |
|
192 |
case KXmlParser.START_TAG: |
|
190 |
try{ |
|
191 |
currentTag = getParser().nextTag(); |
|
192 |
while (!end){ |
|
193 |
switch(currentTag){ |
|
194 |
case KXmlParser.START_TAG: |
|
195 |
entity = XMLElementsFactory.getElement(getParser().getName()); |
|
196 |
if (entity != null){ |
|
197 |
geom = parseComplexFeature(entity,params,values); |
|
198 |
end = true; |
|
199 |
} |
|
200 |
break; |
|
201 |
case KXmlParser.END_TAG: |
|
202 |
if ((getParser().getName().compareTo(elementName) == 0)) |
|
203 |
end = true; |
|
204 |
break; |
|
205 |
case KXmlParser.TEXT: |
|
206 |
break; |
|
207 |
} |
|
208 |
if (!end){ |
|
209 |
currentTag = getParser().next(); |
|
210 |
} |
|
211 |
} |
|
212 |
}catch (XmlPullParserException e) { |
|
213 |
// TODO Auto-generated catch block |
|
214 |
e.printStackTrace(); |
|
215 |
throw new GMLException(GMLException.EXC_PARSE); |
|
216 |
} catch (IOException e) { |
|
217 |
// TODO Auto-generated catch block |
|
218 |
e.printStackTrace(); |
|
219 |
throw new GMLException(GMLException.EXC_READ_FILE); |
|
220 |
} |
|
221 |
|
|
222 |
return getFactory().createSimpleFeature(entity.getName(),geom,params,values); |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
226 |
* Parses a Complex type |
|
227 |
* @param complexTypeName |
|
228 |
* @param params |
|
229 |
* @param values |
|
230 |
* @return |
|
231 |
* The geom |
|
232 |
* @throws GMLException |
|
233 |
*/ |
|
234 |
private Object parseComplexFeature(XMLElement entity,ArrayList params,ArrayList values) throws GMLException{ |
|
235 |
int currentTag; |
|
236 |
boolean end = false; |
|
237 |
Object geom = null; |
|
238 |
ArrayList myValues = new ArrayList(); |
|
239 |
ArrayList myParams = new ArrayList(); |
|
240 |
|
|
241 |
params.add(entity.getName()); |
|
242 |
values.add(null); |
|
243 |
|
|
244 |
params.add(myParams); |
|
245 |
values.add(myValues); |
|
246 |
|
|
247 |
XMLComplexType entityType = (XMLComplexType)entity.getEntityType(); |
|
248 |
try{ |
|
249 |
currentTag = getParser().nextTag(); |
|
250 |
while (!end){ |
|
251 |
switch(currentTag){ |
|
252 |
case KXmlParser.START_TAG: |
|
253 |
if (getParser().getName().compareTo(GMLTags.GML_BOUNDEDBY)==0){ |
|
254 |
GMLUtilsParser.parseBoundedBy(getParser()); |
|
255 |
}else{ |
|
193 | 256 |
String attName = getParser().getName(); |
194 |
XMLElement attribute = elementType.getElement(attName);
|
|
257 |
XMLElement attribute = entityType.getAttribute(attName);
|
|
195 | 258 |
if (attribute != null){ |
196 |
if (attribute.getType() != null){ |
|
197 |
if (attribute.getType().getType() == IXMLType.SIMPLE){ |
|
198 |
if (duplicates.get(attName) == null){ |
|
199 |
params.add(attName); |
|
200 |
duplicates.put(attName,attName); |
|
201 |
getParser().next(); |
|
202 |
values.add(((XMLSimpleType)attribute.getType()).getObject(getParser().getText())); |
|
203 |
} |
|
204 |
}else if (attribute.getType().getType() == IXMLType.GML_GEOMETRY){ |
|
259 |
if (attribute.getEntityType() != null){ |
|
260 |
if (attribute.getEntityType().getType() == IXMLType.SIMPLE){ |
|
261 |
myParams.add(attName); |
|
262 |
getParser().next(); |
|
263 |
myValues.add(((XMLSimpleType)attribute.getEntityType()).getObject(getParser().getText())); |
|
264 |
}else if (attribute.getEntityType().getType() == IXMLType.GML_GEOMETRY){ |
|
205 | 265 |
geom = GMLUtilsParser.parseGeometry(getParser(),attName,getFactory()); |
206 |
}else if (attribute.getType().getType() == IXMLType.COMPLEX){ |
|
207 |
//Not in GML v2
|
|
266 |
}else if (attribute.getEntityType().getType() == IXMLType.COMPLEX){
|
|
267 |
parseComplexFeature(attribute,myParams,myValues);
|
|
208 | 268 |
} |
209 | 269 |
} |
210 | 270 |
} |
211 |
break; |
|
212 |
case KXmlParser.END_TAG: |
|
213 |
if ((getParser().getName().compareTo(elementName) == 0)) |
|
214 |
end = true; |
|
215 |
break; |
|
216 |
case KXmlParser.TEXT: |
|
217 |
break; |
|
218 | 271 |
} |
219 |
if (!end){ |
|
220 |
currentTag = getParser().next(); |
|
221 |
} |
|
272 |
break; |
|
273 |
case KXmlParser.END_TAG: |
|
274 |
if ((getParser().getName().compareTo(entity.getName()) == 0)) |
|
275 |
end = true; |
|
276 |
break; |
|
277 |
case KXmlParser.TEXT: |
|
278 |
break; |
|
222 | 279 |
} |
223 |
}catch (XmlPullParserException e) { |
|
224 |
// TODO Auto-generated catch block |
|
225 |
e.printStackTrace(); |
|
226 |
throw new GMLException(GMLException.EXC_PARSE); |
|
227 |
} catch (IOException e) { |
|
228 |
// TODO Auto-generated catch block |
|
229 |
e.printStackTrace(); |
|
230 |
throw new GMLException(GMLException.EXC_READ_FILE); |
|
231 |
} |
|
232 |
} |
|
233 |
return getFactory().createSimpleFeature(elementName,geom,params,values); |
|
280 |
if (!end){ |
|
281 |
currentTag = getParser().next(); |
|
282 |
} |
|
283 |
} |
|
284 |
}catch (XmlPullParserException e) { |
|
285 |
// TODO Auto-generated catch block |
|
286 |
e.printStackTrace(); |
|
287 |
throw new GMLException(GMLException.EXC_PARSE); |
|
288 |
} catch (IOException e) { |
|
289 |
// TODO Auto-generated catch block |
|
290 |
e.printStackTrace(); |
|
291 |
throw new GMLException(GMLException.EXC_READ_FILE); |
|
292 |
} |
|
293 |
|
|
294 |
return geom; |
|
234 | 295 |
} |
235 | 296 |
|
236 | 297 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/v2/GMLFeaturesParser_v2.java | ||
---|---|---|
1 | 1 |
package org.gvsig.remoteClient.gml.v2; |
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 |
import java.util.Hashtable; |
|
5 | 4 |
|
6 | 5 |
import org.gvsig.remoteClient.gml.GMLException; |
7 | 6 |
import org.gvsig.remoteClient.gml.GMLTags; |
... | ... | |
9 | 8 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
10 | 9 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
11 | 10 |
import org.gvsig.remoteClient.gml.utils.GMLUtilsParser; |
12 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
13 |
import org.gvsig.remoteClient.wfs.WFSAttribute; |
|
14 | 11 |
import org.kxml2.io.KXmlParser; |
15 | 12 |
import org.xmlpull.v1.XmlPullParserException; |
16 | 13 |
|
... | ... | |
58 | 55 |
* |
59 | 56 |
* $Id$ |
60 | 57 |
* $Log$ |
61 |
* Revision 1.2 2006-08-10 12:37:05 jorpiell |
|
58 |
* Revision 1.3 2006-10-10 12:52:28 jorpiell |
|
59 |
* Soporte para features complejas. |
|
60 |
* |
|
61 |
* Revision 1.2 2006/08/10 12:37:05 jorpiell |
|
62 | 62 |
* A?adido el tag description al GML parser |
63 | 63 |
* |
64 | 64 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wfs/WFSAttribute.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.wfs; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.TreeMap; |
|
5 |
|
|
6 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
7 |
import org.kxml2.io.KXmlParser; |
|
8 |
import org.xmlpull.v1.XmlPullParserException; |
|
9 |
|
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id$ |
|
53 |
* $Log$ |
|
54 |
* Revision 1.2 2006-07-12 06:23:31 jorpiell |
|
55 |
* Soportados tipos m?s complejos |
|
56 |
* |
|
57 |
* Revision 1.1 2006/05/25 10:20:57 jorpiell |
|
58 |
* Se ha cambiado el nombre de la clase WFSField por la clase WFSAttribute, porque resultaba confuso |
|
59 |
* |
|
60 |
* Revision 1.3 2006/05/23 13:23:22 jorpiell |
|
61 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource |
|
62 |
* |
|
63 |
* Revision 1.1 2006/04/20 16:39:16 jorpiell |
|
64 |
* A?adida la operacion de describeFeatureType y el parser correspondiente. |
|
65 |
* |
|
66 |
* |
|
67 |
*/ |
|
68 |
/** |
|
69 |
* This class is used to represent a feature field. |
|
70 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
71 |
*/ |
|
72 |
public class WFSAttribute { |
|
73 |
private String name = null; |
|
74 |
private Type type = null; |
|
75 |
private int minOccurs = -1; |
|
76 |
private int maxOccurs = -1; |
|
77 |
|
|
78 |
|
|
79 |
public WFSAttribute() { |
|
80 |
super(); |
|
81 |
this.type = new Type(); |
|
82 |
} |
|
83 |
|
|
84 |
public String toString(){ |
|
85 |
return name; |
|
86 |
} |
|
87 |
/** |
|
88 |
* @return Returns the maxOcurs. |
|
89 |
*/ |
|
90 |
public int getMaxOccurs() { |
|
91 |
return maxOccurs; |
|
92 |
} |
|
93 |
/** |
|
94 |
* @param maxOcurs The maxOcurs to set. |
|
95 |
*/ |
|
96 |
public void setMaxOccurs(int maxOccurs) { |
|
97 |
this.maxOccurs = maxOccurs; |
|
98 |
} |
|
99 |
/** |
|
100 |
* @return Returns the minOcurs. |
|
101 |
*/ |
|
102 |
public int getMinOccurs() { |
|
103 |
return minOccurs; |
|
104 |
} |
|
105 |
/** |
|
106 |
* @param minOcurs The minOcurs to set. |
|
107 |
*/ |
|
108 |
public void setMinOccurs(int minOccurs) { |
|
109 |
this.minOccurs = minOccurs; |
|
110 |
} |
|
111 |
/** |
|
112 |
* @return Returns the name. |
|
113 |
*/ |
|
114 |
public String getName() { |
|
115 |
return name; |
|
116 |
} |
|
117 |
/** |
|
118 |
* @param name The name to set. |
|
119 |
*/ |
|
120 |
public void setName(String name) { |
|
121 |
this.name = name; |
|
122 |
} |
|
123 |
/** |
|
124 |
* @return Returns the type. |
|
125 |
*/ |
|
126 |
public String getType() { |
|
127 |
return type.getType(); |
|
128 |
} |
|
129 |
/** |
|
130 |
* @param type The type to set. |
|
131 |
*/ |
|
132 |
public void setType(String type) { |
|
133 |
if (this.type == null){ |
|
134 |
this.type = new Type(); |
|
135 |
} |
|
136 |
this.type.setType(type); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* <p>Parses the contents of the parser |
|
141 |
* to extract the information about an WFS Layer</p> |
|
142 |
* @throws IOException |
|
143 |
* @throws XmlPullParserException |
|
144 |
* |
|
145 |
*/ |
|
146 |
public void parse(WFSSchemaParser parser) throws XmlPullParserException, IOException{ |
|
147 |
|
|
148 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
149 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_NAME) == 0){ |
|
150 |
setName(parser.getAttributeValue(i)); |
|
151 |
}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_TYPE) == 0){ |
|
152 |
setType(parser.getAttributeValue(i)); |
|
153 |
}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_MAXOCCURS) == 0){ |
|
154 |
setMaxOccurs(Integer.parseInt(parser.getAttributeValue(i))); |
|
155 |
}else if (parser.getAttributeName(i).compareTo(CapabilitiesTags.ELEMENT_MINOCCURS) == 0){ |
|
156 |
setMinOccurs(Integer.parseInt(parser.getAttributeValue(i))); |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
public class Type{ |
|
162 |
private String type = ""; |
|
163 |
private int totalDigits = 0; |
|
164 |
private int fractionDigits = 0; |
|
165 |
|
|
166 |
public void parse(WFSSchemaParser parser) throws XmlPullParserException, IOException{ |
|
167 |
|
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* @return Returns the fractionDigits. |
|
173 |
*/ |
|
174 |
public int getFractionDigits() { |
|
175 |
return fractionDigits; |
|
176 |
} |
|
177 |
/** |
|
178 |
* @param fractionDigits The fractionDigits to set. |
|
179 |
*/ |
|
180 |
public void setFractionDigits(int fractionDigits) { |
|
181 |
this.fractionDigits = fractionDigits; |
|
182 |
} |
|
183 |
/** |
|
184 |
* @return Returns the totalDigits. |
|
185 |
*/ |
|
186 |
public int getTotalDigits() { |
|
187 |
return totalDigits; |
|
188 |
} |
|
189 |
/** |
|
190 |
* @param totalDigits The totalDigits to set. |
|
191 |
*/ |
|
192 |
public void setTotalDigits(int totalDigits) { |
|
193 |
this.totalDigits = totalDigits; |
|
194 |
} |
|
195 |
/** |
|
196 |
* @return Returns the type. |
|
197 |
*/ |
|
198 |
public String getType() { |
|
199 |
return type; |
|
200 |
} |
|
201 |
/** |
|
202 |
* @param type The type to set. |
|
203 |
*/ |
|
204 |
public void setType(String type) { |
|
205 |
this.type = type; |
|
206 |
} |
|
207 |
|
|
208 |
private void parseSimpleType(WFSSchemaParser parser) throws IOException, XmlPullParserException |
|
209 |
{ |
|
210 |
int currentTag; |
|
211 |
boolean end = false; |
|
212 |
|
|
213 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SIMPLETYPE); |
|
214 |
currentTag = parser.next(); |
|
215 |
|
|
216 |
while (!end) |
|
217 |
{ |
|
218 |
switch(currentTag) |
|
219 |
{ |
|
220 |
case KXmlParser.START_TAG: |
|
221 |
if (parser.getName().compareTo(CapabilitiesTags.RESTRICTION)==0) |
|
222 |
{ |
|
223 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
224 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.BASE) == 0){ |
|
225 |
setType(parser.getAttributeValue(i)); |
|
226 |
} |
|
227 |
} |
|
228 |
parseRestriction(parser); |
|
229 |
} |
|
230 |
break; |
|
231 |
case KXmlParser.END_TAG: |
|
232 |
if (parser.getName().compareTo(CapabilitiesTags.SIMPLETYPE) == 0) |
|
233 |
end = true; |
|
234 |
break; |
|
235 |
case KXmlParser.TEXT: |
|
236 |
break; |
|
237 |
} |
|
238 |
if (!end){ |
|
239 |
currentTag = parser.next(); |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
private void parseRestriction(WFSSchemaParser parser) throws IOException, XmlPullParserException |
|
245 |
{ |
|
246 |
int currentTag; |
|
247 |
boolean end = false; |
|
248 |
|
|
249 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.RESTRICTION); |
|
250 |
currentTag = parser.next(); |
|
251 |
|
|
252 |
while (!end) |
|
253 |
{ |
|
254 |
switch(currentTag) |
|
255 |
{ |
|
256 |
case KXmlParser.START_TAG: |
|
257 |
if (parser.getName().compareTo(CapabilitiesTags.TOTAL_DIGITS)==0) |
|
258 |
{ |
|
259 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
260 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.VALUE) == 0){ |
|
261 |
setTotalDigits(Integer.parseInt(parser.getAttributeValue(i))); |
|
262 |
} |
|
263 |
} |
|
264 |
}else if (parser.getName().compareTo(CapabilitiesTags.FRACTION_DIGITS)==0){ |
|
265 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
266 |
if (parser.getAttributeName(i).compareTo(CapabilitiesTags.VALUE) == 0){ |
|
267 |
setFractionDigits(Integer.parseInt(parser.getAttributeValue(i))); |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
break; |
|
272 |
case KXmlParser.END_TAG: |
|
273 |
if (parser.getName().compareTo(CapabilitiesTags.RESTRICTION) == 0) |
|
274 |
end = true; |
|
275 |
break; |
|
276 |
case KXmlParser.TEXT: |
|
277 |
break; |
|
278 |
} |
|
279 |
if (!end){ |
|
280 |
currentTag = parser.next(); |
|
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
|
|
286 |
} |
|
287 |
|
|
288 |
public void parseType(WFSSchemaParser parser) throws IOException, XmlPullParserException { |
|
289 |
this.type.parseSimpleType(parser); |
|
290 |
} |
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wfs/wfs_1_0_0/WFSProtocolHandler1_0_0.java | ||
---|---|---|
9 | 9 |
import java.util.Hashtable; |
10 | 10 |
import java.util.Vector; |
11 | 11 |
|
12 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
|
13 |
import org.gvsig.remoteClient.gml.factories.XMLTypesFactory; |
|
14 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
|
15 |
import org.gvsig.remoteClient.gml.schemas.XMLComplexType; |
|
16 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
|
17 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
|
12 | 18 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
13 |
import org.gvsig.remoteClient.wfs.WFSSchemaParser; |
|
14 |
import org.gvsig.remoteClient.wfs.WFSAttribute; |
|
15 | 19 |
import org.gvsig.remoteClient.wfs.WFSProtocolHandler; |
16 |
import org.gvsig.remoteClient.wms.wms_1_1_0.WMSLayer1_1_0; |
|
17 | 20 |
import org.kxml2.io.KXmlParser; |
18 | 21 |
import org.xmlpull.v1.XmlPullParserException; |
19 | 22 |
|
... | ... | |
61 | 64 |
* |
62 | 65 |
* $Id$ |
63 | 66 |
* $Log$ |
64 |
* Revision 1.6 2006-06-14 07:54:18 jorpiell |
|
67 |
* Revision 1.7 2006-10-10 12:52:28 jorpiell |
|
68 |
* Soporte para features complejas. |
|
69 |
* |
|
70 |
* Revision 1.6 2006/06/14 07:54:18 jorpiell |
|
65 | 71 |
* Se parsea el online resource que antes se ignoraba |
66 | 72 |
* |
67 | 73 |
* Revision 1.5 2006/05/25 10:20:57 jorpiell |
... | ... | |
395 | 401 |
} |
396 | 402 |
} |
397 | 403 |
|
398 |
public boolean parseDescribeFeatureType(File f) { |
|
399 |
FileReader reader = null; |
|
400 |
try |
|
401 |
{ |
|
402 |
reader = new FileReader(f); |
|
403 |
BufferedReader br = new BufferedReader(reader); |
|
404 |
char[] buffer = new char[100]; |
|
405 |
br.read(buffer); |
|
406 |
StringBuffer st = new StringBuffer(new String(buffer)); |
|
407 |
String searchText = "encoding=\""; |
|
408 |
int index = st.indexOf(searchText); |
|
409 |
if (index>-1) { |
|
410 |
st.delete(0, index+searchText.length()); |
|
411 |
encoding = st.substring(0, st.indexOf("\"")); |
|
412 |
} |
|
413 |
} catch (FileNotFoundException ex) { |
|
414 |
ex.printStackTrace(); |
|
415 |
} catch (IOException e) { |
|
416 |
e.printStackTrace(); |
|
417 |
} |
|
404 |
public boolean parseDescribeFeatureType(File f,String nameSpace) { |
|
405 |
XMLSchemaParser schemaParser = new XMLSchemaParser(); |
|
406 |
schemaParser.parse(f,nameSpace); |
|
418 | 407 |
|
419 |
int tag; |
|
420 |
WFSSchemaParser parser = null; |
|
421 |
parser = new WFSSchemaParser(); |
|
422 |
try |
|
423 |
{ |
|
424 |
parser.setInput(new FileInputStream(f), encoding); |
|
425 |
parser.nextTag(); |
|
426 |
|
|
427 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) |
|
428 |
{ |
|
429 |
parser.setSchemaFromMainTag(parser.getName()); |
|
430 |
|
|
431 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_SCHEMAROOT); |
|
432 |
tag = parser.nextTag(); |
|
433 |
while(tag != KXmlParser.END_DOCUMENT) |
|
434 |
{ |
|
435 |
switch(tag) |
|
436 |
{ |
|
437 |
case KXmlParser.START_TAG: |
|
438 |
if (parser.getName().compareTo(CapabilitiesTags.COMPLEXTYPE)==0) |
|
439 |
{ |
|
440 |
parseComplexType(parser); |
|
441 |
} |
|
442 |
break; |
|
443 |
case KXmlParser.END_TAG: |
|
444 |
break; |
|
445 |
case KXmlParser.TEXT: |
|
446 |
if (parser.getName()!=null) |
|
447 |
System.out.println("[TEXT]["+parser.getText().trim()+"]"); |
|
448 |
break; |
|
449 |
} |
|
450 |
tag = parser.next(); |
|
451 |
} |
|
452 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
|
408 |
String layerName = getCurrentFeature(); |
|
409 |
if (getCurrentFeature().split(":").length>1){ |
|
410 |
layerName = getCurrentFeature().split(":")[1]; |
|
411 |
} |
|
412 |
XMLElement entity = XMLElementsFactory.getElement(layerName); |
|
413 |
if (entity != null){ |
|
414 |
IXMLType type = entity.getEntityType(); |
|
415 |
if ((type != null) && (type instanceof XMLComplexType)){ |
|
416 |
setFields(((XMLComplexType)type).getAttributes()); |
|
453 | 417 |
} |
454 | 418 |
} |
455 |
catch(XmlPullParserException parser_ex){ |
|
456 |
System.out.println(parser_ex.getMessage()); |
|
457 |
parser_ex.printStackTrace(); |
|
458 |
return false; |
|
459 |
} |
|
460 |
catch (IOException ioe) { |
|
461 |
ioe.printStackTrace(); |
|
462 |
return false; |
|
463 |
} |
|
464 | 419 |
return true; |
465 | 420 |
} |
466 | 421 |
|
467 |
private void parseComplexType(WFSSchemaParser parser) throws IOException, XmlPullParserException |
|
468 |
{ |
|
469 |
int currentTag; |
|
470 |
boolean end = false; |
|
471 |
|
|
472 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.COMPLEXTYPE); |
|
473 |
currentTag = parser.next(); |
|
474 |
|
|
475 |
while (!end) |
|
476 |
{ |
|
477 |
switch(currentTag) |
|
478 |
{ |
|
479 |
case KXmlParser.START_TAG: |
|
480 |
if (parser.getName().compareTo(CapabilitiesTags.COMPLEXCONTENT)==0) |
|
481 |
{ |
|
482 |
parseComplexContent(parser); |
|
483 |
} |
|
484 |
break; |
|
485 |
case KXmlParser.END_TAG: |
|
486 |
if (parser.getName().compareTo(CapabilitiesTags.COMPLEXTYPE) == 0) |
|
487 |
end = true; |
|
488 |
break; |
|
489 |
case KXmlParser.TEXT: |
|
490 |
break; |
|
491 |
} |
|
492 |
if (!end){ |
|
493 |
currentTag = parser.next(); |
|
494 |
} |
|
495 |
} |
|
496 |
} |
|
497 |
|
|
498 |
private void parseComplexContent(WFSSchemaParser parser) throws IOException, XmlPullParserException |
|
499 |
{ |
|
500 |
int currentTag; |
|
501 |
boolean end = false; |
|
502 |
|
|
503 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.COMPLEXCONTENT); |
|
504 |
currentTag = parser.next(); |
|
505 |
|
|
506 |
while (!end) |
|
507 |
{ |
|
508 |
switch(currentTag) |
|
509 |
{ |
|
510 |
case KXmlParser.START_TAG: |
|
511 |
if (parser.getName().compareTo(CapabilitiesTags.EXTENSION )==0) |
|
512 |
{ |
|
513 |
parseExtension(parser); |
|
514 |
} |
|
515 |
break; |
|
516 |
case KXmlParser.END_TAG: |
|
517 |
if (parser.getName().compareTo(CapabilitiesTags.COMPLEXCONTENT) == 0) |
|
518 |
end = true; |
|
519 |
break; |
|
520 |
case KXmlParser.TEXT: |
|
521 |
break; |
|
522 |
} |
|
523 |
if (!end){ |
|
524 |
currentTag = parser.next(); |
|
525 |
} |
|
526 |
} |
|
527 |
} |
|
528 |
|
|
529 |
private void parseExtension(WFSSchemaParser parser) throws IOException, XmlPullParserException |
|
530 |
{ |
|
531 |
int currentTag; |
|
532 |
boolean end = false; |
|
533 |
|
|
534 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.EXTENSION); |
|
535 |
currentTag = parser.next(); |
|
536 |
|
|
537 |
while (!end) |
|
538 |
{ |
|
539 |
switch(currentTag) |
|
540 |
{ |
|
541 |
case KXmlParser.START_TAG: |
|
542 |
if (parser.getName().compareTo(CapabilitiesTags.SEQUENCE)==0) |
|
543 |
{ |
|
544 |
parseSequence(parser); |
|
545 |
} |
|
546 |
break; |
|
547 |
case KXmlParser.END_TAG: |
|
548 |
if (parser.getName().compareTo(CapabilitiesTags.EXTENSION) == 0) |
|
549 |
end = true; |
|
550 |
break; |
|
551 |
case KXmlParser.TEXT: |
|
552 |
break; |
|
553 |
} |
|
554 |
if (!end){ |
|
555 |
currentTag = parser.next(); |
|
556 |
} |
|
557 |
} |
|
558 |
} |
|
559 |
|
|
560 |
private void parseSequence(WFSSchemaParser parser) throws IOException, XmlPullParserException |
|
561 |
{ |
|
562 |
int currentTag; |
|
563 |
boolean end = false; |
|
564 |
|
Also available in: Unified diff