Statistics
| Revision:

root / org.gvsig.gpe / library / trunk / org.gvsig.gpe / org.gvsig.gpe.prov / org.gvsig.gpe.prov.gml / src / org / gvsig / gpe / prov / gml / parser / v2 / geometries / LineStringMemberTypeBinding.java @ 110

History | View | Annotate | Download (3.47 KB)

1
package org.gvsig.gpe.prov.gml.parser.v2.geometries;
2

    
3
import java.io.IOException;
4

    
5
import javax.xml.namespace.QName;
6

    
7
import org.gvsig.gpe.prov.gml.parser.GPEDefaultGmlParser;
8
import org.gvsig.gpe.prov.gml.utils.GMLTags;
9
import org.gvsig.gpe.prov.xml.utils.CompareUtils;
10
import org.gvsig.xml.lib.api.stream.IXmlStreamReader;
11
import org.gvsig.xml.lib.api.stream.XmlStreamException;
12

    
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
/* CVS MESSAGES:
54
 *
55
 * $Id:LineStringMemberTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
56
 * $Log$
57
 * Revision 1.2  2007/05/14 09:31:06  jorpiell
58
 * Add the a new class to compare tags
59
 *
60
 * Revision 1.1  2007/05/07 12:58:42  jorpiell
61
 * Add some methods to manage the multigeometries
62
 *
63
 *
64
 */
65
/**
66
 * It parses a gml:LineStringMemberType object. Example:
67
 * <p>
68
 * <pre>
69
 * <code>
70
 * &lt;lineStringMember&gt;
71
 * &lt;LineString&gt;
72
 * &lt;coord&gt;&lt;X&gt;56.1&lt;/X&gt;&lt;Y&gt;0.45&lt;/Y&gt;&lt;/coord&gt;
73
 * &lt;coord&gt;&lt;X&gt;67.23&lt;/X&gt;&lt;Y&gt;0.98&lt;/Y&gt;&lt;/coord&gt;
74
 * &lt;/LineString&gt;
75
 * &lt;/lineStringMember&gt;
76
 * </code>
77
 * </pre>
78
 * </p> 
79
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
80
 */
81
public class LineStringMemberTypeBinding {
82
        
83
        /**
84
         * It parses the gml:LineStringMember tag
85
         * @param parser
86
         * The XML parser
87
         * @param handler
88
         * The GPE parser that contains the content handler and
89
         * the error handler
90
         * @return
91
         * A line
92
         * @throws XmlStreamException
93
         * @throws IOException
94
         */
95
        public Object parse(IXmlStreamReader parser,GPEDefaultGmlParser handler) throws XmlStreamException, IOException {
96
                boolean endFeature = false;
97
                int currentTag;
98
                Object lineString = null;                
99
                
100
                QName tag = parser.getName();
101
                currentTag = parser.getEventType();
102

    
103
                while (!endFeature){
104
                        switch(currentTag){
105
                        case IXmlStreamReader.START_ELEMENT:
106
                                        if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_LINESTRING)){
107
                                                lineString = handler.getProfile().getLineStringTypeBinding().
108
                                                parse(parser, handler);
109
                                        }
110
                                        break;
111
                                case IXmlStreamReader.END_ELEMENT:
112
                                        if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_LINESTRINGMEMBER)){                                                
113
                                                endFeature = true;                                                
114
                                        }
115
                                        break;
116
                                case IXmlStreamReader.CHARACTERS:                        
117
                                        
118
                                        break;
119
                                }
120
                                if (!endFeature){                                        
121
                                        currentTag = parser.next();
122
                                        tag = parser.getName();
123
                                }
124
                        }                        
125
                return lineString;        
126
        }
127
}