Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / kml / bindings / FolderBinding.java @ 10269

History | View | Annotate | Download (3.1 KB)

1
package org.gvsig.remoteClient.kml.bindings;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.remoteClient.gml.engine.readers.IReaderFile;
6
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory;
7
import org.gvsig.remoteClient.kml.KmlTags;
8
import org.gvsig.remoteClient.kml.exceptions.KmlBodyParseException;
9
import org.kxml2.io.KXmlParser;
10
import org.xmlpull.v1.XmlPullParserException;
11

    
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id: FolderBinding.java 10269 2007-02-12 13:51:08Z jorpiell $
55
 * $Log$
56
 * Revision 1.1  2007-02-12 13:49:18  jorpiell
57
 * A?adido el driver de KML
58
 *
59
 *
60
 */
61
/**
62
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
63
 */
64
public class FolderBinding extends AbstractComplexBinding {
65

    
66
        public FolderBinding(IGeometriesFactory gFactory) {
67
                super(gFactory);                
68
        }
69

    
70
        /*
71
         *  (non-Javadoc)
72
         * @see org.gvsig.remoteClient.kml.bindings.ComplexBinding#parse(org.gvsig.remoteClient.gmlEngine.readers.IReaderFile)
73
         */
74
        public Object parse(IReaderFile reader) throws KmlBodyParseException {
75
                boolean endFeature = false;
76
                int currentTag;
77
                String folderName = null;
78
                        
79
                try {
80
                        String tag = reader.getName();
81
                        currentTag = reader.getEventType();
82
                        
83
                        while (!endFeature){
84
                                switch(currentTag){
85
                                case KXmlParser.START_TAG:
86
                                        if (tag.compareTo(KmlTags.PLACEMARK) == 0){
87
                                                endFeature = true;
88
                                        }else if (tag.compareTo(KmlTags.NAME) == 0){
89
                                                reader.next();
90
                                                folderName = reader.getText();
91
                                                endFeature = true;
92
                                        }else if (tag.compareTo(KmlTags.LOOKAT) == 0){
93
                                                new LookAtBinding(getGFactory()).parse(reader);
94
                                        }
95
                                        break;
96
                                case KXmlParser.END_TAG:
97
                                        if (tag.compareTo(KmlTags.FOLDER) == 0){
98
                                                endFeature = true;
99
                                        }
100
                                        break;
101
                                case KXmlParser.TEXT:                                        
102
                                        
103
                                        break;
104
                                }
105
                                if (!endFeature){                                        
106
                                        currentTag = reader.next();
107
                                        tag = reader.getName();
108
                                }
109
                        }                        
110
                } catch (XmlPullParserException e) {
111
                        throw new KmlBodyParseException(e);
112
                } catch (IOException e) {
113
                        throw new KmlBodyParseException(e);
114
                }
115
                return folderName;
116
        }
117

    
118
}