svn-gvsig-desktop / branches / v10 / libraries / libGPE-KML / src / org / gvsig / gpe / kml / parser / v21 / header / HeaderBinding.java @ 18284
History | View | Annotate | Download (3.16 KB)
1 |
package org.gvsig.gpe.kml.parser.v21.header; |
---|---|
2 |
|
3 |
import org.gvsig.gpe.kml.GPEDeafultKmlParser; |
4 |
import org.gvsig.gpe.kml.KmlTags; |
5 |
import org.gvsig.gpe.kml.exceptions.KmlHeaderParseException; |
6 |
import org.gvsig.gpe.kml.exceptions.KmlNotRootTagException; |
7 |
import org.xmlpull.v1.XmlPullParser; |
8 |
|
9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
10 |
*
|
11 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
12 |
*
|
13 |
* This program is free software; you can redistribute it and/or
|
14 |
* modify it under the terms of the GNU General Public License
|
15 |
* as published by the Free Software Foundation; either version 2
|
16 |
* of the License, or (at your option) any later version.
|
17 |
*
|
18 |
* This program is distributed in the hope that it will be useful,
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
* GNU General Public License for more details.
|
22 |
*
|
23 |
* You should have received a copy of the GNU General Public License
|
24 |
* along with this program; if not, write to the Free Software
|
25 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
26 |
*
|
27 |
* For more information, contact:
|
28 |
*
|
29 |
* Generalitat Valenciana
|
30 |
* Conselleria d'Infraestructures i Transport
|
31 |
* Av. Blasco Ib??ez, 50
|
32 |
* 46010 VALENCIA
|
33 |
* SPAIN
|
34 |
*
|
35 |
* +34 963862235
|
36 |
* gvsig@gva.es
|
37 |
* www.gvsig.gva.es
|
38 |
*
|
39 |
* or
|
40 |
*
|
41 |
* IVER T.I. S.A
|
42 |
* Salamanca 50
|
43 |
* 46005 Valencia
|
44 |
* Spain
|
45 |
*
|
46 |
* +34 963163400
|
47 |
* dac@iver.es
|
48 |
*/
|
49 |
/* CVS MESSAGES:
|
50 |
*
|
51 |
* $Id:HeaderBinding.java 357 2008-01-09 17:50:08Z jpiera $
|
52 |
* $Log$
|
53 |
* Revision 1.1 2007/07/02 09:59:44 jorpiell
|
54 |
* The generated xsd schemas have to be valid
|
55 |
*
|
56 |
* Revision 1.2 2007/06/07 14:53:59 jorpiell
|
57 |
* Add the schema support
|
58 |
*
|
59 |
* Revision 1.1 2007/05/11 07:06:29 jorpiell
|
60 |
* Refactoring of some package names
|
61 |
*
|
62 |
* Revision 1.3 2007/05/08 09:28:17 jorpiell
|
63 |
* Add comments to create javadocs
|
64 |
*
|
65 |
* Revision 1.2 2007/04/20 08:38:59 jorpiell
|
66 |
* Tests updating
|
67 |
*
|
68 |
* Revision 1.1 2007/04/13 13:16:21 jorpiell
|
69 |
* Add KML reading support
|
70 |
*
|
71 |
* Revision 1.1 2007/03/07 08:19:10 jorpiell
|
72 |
* Pasadas las clases de KML de libGPE-GML a libGPE-KML
|
73 |
*
|
74 |
* Revision 1.1 2007/02/28 11:48:31 csanchez
|
75 |
* *** empty log message ***
|
76 |
*
|
77 |
* Revision 1.1 2007/02/20 10:53:20 jorpiell
|
78 |
* A?adidos los proyectos de kml y gml antiguos
|
79 |
*
|
80 |
* Revision 1.1 2007/02/12 13:49:18 jorpiell
|
81 |
* A?adido el driver de KML
|
82 |
*
|
83 |
*
|
84 |
*/
|
85 |
/**
|
86 |
* This class parses the KML header and retrieves
|
87 |
* the namespace that will be used to obtain the
|
88 |
* kml version
|
89 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
90 |
*/
|
91 |
public class HeaderBinding { |
92 |
|
93 |
/**
|
94 |
* This method parses the kml header file
|
95 |
* @throws KmlHeaderParseException
|
96 |
*/
|
97 |
public String parse(XmlPullParser parser,GPEDeafultKmlParser handler) throws KmlHeaderParseException{ |
98 |
String namespace = KmlTags.UNKNOWN_VERSION;
|
99 |
try {
|
100 |
String name = parser.getName();
|
101 |
if (name.compareTo(KmlTags.ROOT) != 0){ |
102 |
throw new KmlNotRootTagException(name); |
103 |
} |
104 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
105 |
namespace = parser.getAttributeValue(i); |
106 |
} |
107 |
} catch (Exception e) { |
108 |
throw new KmlHeaderParseException(e); |
109 |
} |
110 |
return namespace;
|
111 |
} |
112 |
} |