svn-gvsig-desktop / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / bindings / FeatureMemberTypeBinding.java @ 11604
History | View | Annotate | Download (3.71 KB)
1 |
package org.gvsig.gpe.gml.bindings; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.util.Hashtable; |
5 |
|
6 |
import org.gvsig.gpe.containers.Element; |
7 |
import org.gvsig.gpe.gml.GMLTags; |
8 |
import org.gvsig.gpe.gml.GPEGmlParser; |
9 |
import org.gvsig.gpe.gml.bindings.geometries.BoundedByTypeBinding; |
10 |
import org.gvsig.gpe.gml.bindings.geometries.DoubleTypeBinding; |
11 |
import org.gvsig.gpe.gml.utils.CompareUtils; |
12 |
import org.gvsig.gpe.gml.utils.GMLUtilsParser; |
13 |
import org.gvsig.gpe.gml.writer.geometries.BoundedByWriter; |
14 |
import org.xmlpull.v1.XmlPullParser; |
15 |
import org.xmlpull.v1.XmlPullParserException; |
16 |
|
17 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
18 |
*
|
19 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
20 |
*
|
21 |
* This program is free software; you can redistribute it and/or
|
22 |
* modify it under the terms of the GNU General Public License
|
23 |
* as published by the Free Software Foundation; either version 2
|
24 |
* of the License, or (at your option) any later version.
|
25 |
*
|
26 |
* This program is distributed in the hope that it will be useful,
|
27 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
28 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
29 |
* GNU General Public License for more details.
|
30 |
*
|
31 |
* You should have received a copy of the GNU General Public License
|
32 |
* along with this program; if not, write to the Free Software
|
33 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
34 |
*
|
35 |
* For more information, contact:
|
36 |
*
|
37 |
* Generalitat Valenciana
|
38 |
* Conselleria d'Infraestructures i Transport
|
39 |
* Av. Blasco Ib??ez, 50
|
40 |
* 46010 VALENCIA
|
41 |
* SPAIN
|
42 |
*
|
43 |
* +34 963862235
|
44 |
* gvsig@gva.es
|
45 |
* www.gvsig.gva.es
|
46 |
*
|
47 |
* or
|
48 |
*
|
49 |
* IVER T.I. S.A
|
50 |
* Salamanca 50
|
51 |
* 46005 Valencia
|
52 |
* Spain
|
53 |
*
|
54 |
* +34 963163400
|
55 |
* dac@iver.es
|
56 |
*/
|
57 |
/* CVS MESSAGES:
|
58 |
*
|
59 |
* $Id: FeatureMemberTypeBinding.java 11604 2007-05-14 09:30:30Z jorpiell $
|
60 |
* $Log$
|
61 |
* Revision 1.1 2007-05-14 09:30:30 jorpiell
|
62 |
* Add the FeatureMember tag
|
63 |
*
|
64 |
*
|
65 |
*/
|
66 |
/**
|
67 |
* This class parses the gml objects that has a
|
68 |
* gml:FeatureMember type. The structure of the
|
69 |
* properties that this type has is variable and depends
|
70 |
* on its schema. Example:
|
71 |
* <p>
|
72 |
* <pre>
|
73 |
* <code>
|
74 |
* <gml:featureMember>
|
75 |
* <cit:cities>
|
76 |
* <cit:the_geom>
|
77 |
* <gml:Point srsName='0'>
|
78 |
* <gml:coordinates>-123.06999969482422,49.411192817494346</gml:coordinates>
|
79 |
* </gml:Point>
|
80 |
* </cit:the_geom>
|
81 |
* <cit:NAME>Vancouver</cit:NAME>
|
82 |
* <cit:CAPITAL>N</cit:CAPITAL>
|
83 |
* <cit:PROV_NAME>British Columbia</cit:PROV_NAME>
|
84 |
* </cit:cities>
|
85 |
* </gml:featureMember>
|
86 |
* </code>
|
87 |
* </pre>
|
88 |
* </p>
|
89 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
90 |
*/
|
91 |
public class FeatureMemberTypeBinding { |
92 |
|
93 |
/**
|
94 |
* It parses a feature
|
95 |
* @param parser
|
96 |
* The XML parser
|
97 |
* @param handler
|
98 |
* The GPE parser that contains the content handler and
|
99 |
* the error handler
|
100 |
* @return
|
101 |
* A feature
|
102 |
* @throws XmlPullParserException
|
103 |
* @throws IOException
|
104 |
*/
|
105 |
public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
106 |
boolean endFeature = false; |
107 |
int currentTag;
|
108 |
Object feature = null; |
109 |
|
110 |
String tag = parser.getName();
|
111 |
currentTag = parser.getEventType(); |
112 |
|
113 |
while (!endFeature){
|
114 |
switch(currentTag){
|
115 |
case XmlPullParser.START_TAG:
|
116 |
if (!CompareUtils.compareWithOutNamespace(tag, GMLTags.GML_FEATUREMEMBER)){
|
117 |
feature = FeatureTypeBinding.parse(parser, handler); |
118 |
} |
119 |
break;
|
120 |
case XmlPullParser.END_TAG:
|
121 |
if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_FEATUREMEMBER)){
|
122 |
endFeature = true;
|
123 |
} |
124 |
break;
|
125 |
case XmlPullParser.TEXT:
|
126 |
|
127 |
break;
|
128 |
} |
129 |
if (!endFeature){
|
130 |
currentTag = parser.next(); |
131 |
tag = parser.getName(); |
132 |
} |
133 |
} |
134 |
|
135 |
return feature;
|
136 |
} |
137 |
} |