Statistics
| Revision:

root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / parser / v2 / geometries / PointPropertyTypeBinding.java @ 19366

History | View | Annotate | Download (3.45 KB)

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

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.gml.parser.GPEDefaultGmlParser;
6
import org.gvsig.gpe.gml.utils.CompareUtils;
7
import org.gvsig.gpe.gml.utils.GMLTags;
8
import org.kxml2.io.KXmlParser;
9
import org.xmlpull.v1.XmlPullParser;
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:PointPropertyTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
55
 * $Log$
56
 * Revision 1.2  2007/05/24 07:29:47  csanchez
57
 * A?adidos Alias GML2
58
 *
59
 * Revision 1.1  2007/05/15 07:30:38  jorpiell
60
 * Add the geometryProperties tags
61
 *
62
 *
63
 */
64
/**
65
 * It parses a gml:pointPropertyType object. Example:
66
 * <p>
67
 * <pre>
68
 * <code>
69
 * &lt;pointProperty&gt;
70
 * &lt;Point gid="P6776"&gt;
71
 * &lt;coord&gt;&lt;X&gt;50.0&lt;/X&gt;&lt;Y&gt;50.0&lt;/Y&gt;&lt;/coord&gt;
72
 * &lt;/Point&gt;
73
 * &lt;/pointProperty&gt;
74
 * </code>
75
 * </pre>
76
 * </p> 
77
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
78
 */
79
public class PointPropertyTypeBinding {
80

    
81
        /**
82
         * It parses the gml:pointProperty tag
83
         * @param parser
84
         * The XML parser
85
         * @param handler
86
         * The GPE parser that contains the content handler and
87
         * the error handler
88
         * @return
89
         * A point
90
         * @throws XmlPullParserException
91
         * @throws IOException
92
         */
93
        public Object parse(XmlPullParser parser,GPEDefaultGmlParser handler) throws XmlPullParserException, IOException {
94
                boolean endFeature = false;
95
                int currentTag;
96
                Object point = null;                
97

    
98
                String tag = parser.getName();
99
                currentTag = parser.getEventType();
100

    
101
                while (!endFeature){
102
                        switch(currentTag){
103
                        case KXmlParser.START_TAG:
104
                                if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POINT))
105
                                {
106
                                        point = handler.getProfile().getPointTypeBinding().
107
                                        parse(parser, handler);
108
                                }
109
                                break;
110
                        case KXmlParser.END_TAG:
111
                                if ((CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POINTPROPERTY))||
112
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_LOCATION))||
113
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_CENTEROF))||
114
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POSITION)))
115
                                {
116
                                                endFeature = true;                                                
117
                                }
118
                                break;
119
                        case KXmlParser.TEXT:                        
120

    
121
                                break;
122
                        }
123
                        if (!endFeature){                                        
124
                                currentTag = parser.next();
125
                                tag = parser.getName();
126
                        }
127
                }                        
128
                return point;        
129
        }
130
}
131