svn-gvsig-desktop / branches / v10 / libraries / libGPE-KML / src / org / gvsig / gpe / kml / parser / v21 / features / MetadataBinding.java @ 18284
History | View | Annotate | Download (3.18 KB)
1 | 18284 | jpiera | package org.gvsig.gpe.kml.parser.v21.features; |
---|---|---|---|
2 | |||
3 | import java.io.IOException; |
||
4 | |||
5 | import org.gvsig.gpe.kml.GPEDeafultKmlParser; |
||
6 | import org.gvsig.gpe.kml.KmlTags; |
||
7 | import org.kxml2.io.KXmlParser; |
||
8 | import org.xmlpull.v1.XmlPullParser; |
||
9 | import org.xmlpull.v1.XmlPullParserException; |
||
10 | |||
11 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
12 | *
|
||
13 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
14 | *
|
||
15 | * This program is free software; you can redistribute it and/or
|
||
16 | * modify it under the terms of the GNU General Public License
|
||
17 | * as published by the Free Software Foundation; either version 2
|
||
18 | * of the License, or (at your option) any later version.
|
||
19 | *
|
||
20 | * This program is distributed in the hope that it will be useful,
|
||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
23 | * GNU General Public License for more details.
|
||
24 | *
|
||
25 | * You should have received a copy of the GNU General Public License
|
||
26 | * along with this program; if not, write to the Free Software
|
||
27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
28 | *
|
||
29 | * For more information, contact:
|
||
30 | *
|
||
31 | * Generalitat Valenciana
|
||
32 | * Conselleria d'Infraestructures i Transport
|
||
33 | * Av. Blasco Ib??ez, 50
|
||
34 | * 46010 VALENCIA
|
||
35 | * SPAIN
|
||
36 | *
|
||
37 | * +34 963862235
|
||
38 | * gvsig@gva.es
|
||
39 | * www.gvsig.gva.es
|
||
40 | *
|
||
41 | * or
|
||
42 | *
|
||
43 | * IVER T.I. S.A
|
||
44 | * Salamanca 50
|
||
45 | * 46005 Valencia
|
||
46 | * Spain
|
||
47 | *
|
||
48 | * +34 963163400
|
||
49 | * dac@iver.es
|
||
50 | */
|
||
51 | /* CVS MESSAGES:
|
||
52 | *
|
||
53 | * $Id: MetadataBinding.java 357 2008-01-09 17:50:08Z jpiera $
|
||
54 | * $Log$
|
||
55 | * Revision 1.2 2007/06/07 14:53:59 jorpiell
|
||
56 | * Add the schema support
|
||
57 | *
|
||
58 | * Revision 1.1 2007/05/16 15:54:20 jorpiell
|
||
59 | * Add elements support
|
||
60 | *
|
||
61 | *
|
||
62 | */
|
||
63 | /**
|
||
64 | * This class parses a Metadata tag. This tag is just a
|
||
65 | * free XML subset and has metadata information about
|
||
66 | * the object tha contains it. It is used to add
|
||
67 | * elements a Feature
|
||
68 | * @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
||
69 | * @see http://code.google.com/apis/kml/documentation/kml_tags_21.html#metadata
|
||
70 | */
|
||
71 | public class MetadataBinding { |
||
72 | |||
73 | /**
|
||
74 | * It parses the Metadata tag
|
||
75 | * @param parser
|
||
76 | * The XML parser
|
||
77 | * @param handler
|
||
78 | * The GPE parser that contains the content handler and
|
||
79 | * the error handler
|
||
80 | * @param feature
|
||
81 | * The elements will be add to this feature
|
||
82 | * @throws IOException
|
||
83 | * @throws XmlPullParserException
|
||
84 | */
|
||
85 | public static void parse(XmlPullParser parser,GPEDeafultKmlParser handler, Object feature) throws XmlPullParserException, IOException{ |
||
86 | boolean endFeature = false; |
||
87 | int currentTag;
|
||
88 | |||
89 | String tag = parser.getName();
|
||
90 | currentTag = parser.getEventType(); |
||
91 | |||
92 | while (!endFeature){
|
||
93 | switch(currentTag){
|
||
94 | case KXmlParser.START_TAG:
|
||
95 | if (!(tag.compareTo(KmlTags.METADATA) == 0)){ |
||
96 | Object element = handler.getProfile().getElementBinding().parse(parser, handler, feature, null); |
||
97 | handler.getContentHandler().addElementToFeature(element, feature); |
||
98 | } |
||
99 | break;
|
||
100 | case KXmlParser.END_TAG:
|
||
101 | if (tag.compareTo(KmlTags.METADATA) == 0){ |
||
102 | endFeature = true;
|
||
103 | } |
||
104 | break;
|
||
105 | case KXmlParser.TEXT:
|
||
106 | |||
107 | break;
|
||
108 | } |
||
109 | if (!endFeature){
|
||
110 | currentTag = parser.next(); |
||
111 | tag = parser.getName(); |
||
112 | } |
||
113 | } |
||
114 | } |
||
115 | |||
116 | |||
117 | } |