Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / utils / KMLUtilsParser.java @ 19680

History | View | Annotate | Download (4.5 KB)

1
package org.gvsig.gpe.kml.utils;
2

    
3
import java.util.Hashtable;
4

    
5
import org.gvsig.gpe.GPEDefaults;
6
import org.gvsig.gpe.utils.StringUtils;
7
import org.gvsig.gpe.xml.stream.IXmlStreamReader;
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: GMLUtilsParser.java 189 2007-11-21 12:45:56Z csanchez $
52
 * $Log$
53
 * Revision 1.8  2007/06/28 13:05:09  jorpiell
54
 * The Qname has been updated to the 1.5 JVM machine. The schema validation is made in the GPEWriterHandlerImplementor class
55
 *
56
 * Revision 1.7  2007/05/18 10:41:01  csanchez
57
 * Actualizaci?n libGPE-GML eliminaci?n de clases inecesarias
58
 *
59
 * Revision 1.6  2007/05/16 13:00:48  csanchez
60
 * Actualizaci?n de libGPE-GML
61
 *
62
 * Revision 1.5  2007/05/16 09:29:12  jorpiell
63
 * The polygons has to be closed
64
 *
65
 * Revision 1.4  2007/05/15 10:14:45  jorpiell
66
 * The element and the feature is managed like a Stack
67
 *
68
 * Revision 1.3  2007/05/15 09:35:09  jorpiell
69
 * the tag names cant have blanc spaces
70
 *
71
 * Revision 1.2  2007/05/07 12:58:42  jorpiell
72
 * Add some methods to manage the multigeometries
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.3  2007/01/15 13:11:00  csanchez
81
 * Sistema de Warnings y Excepciones adaptado a BasicException
82
 *
83
 * Revision 1.2  2006/12/22 11:25:44  csanchez
84
 * Nuevo parser GML 2.x para gml's sin esquema
85
 *
86
 * Revision 1.1  2006/08/10 12:00:49  jorpiell
87
 * Primer commit del driver de Gml
88
 *
89
 *
90
 */
91
/**
92
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
93
 * @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
94
 */
95
public class KMLUtilsParser {
96

    
97
        /**
98
         * It returns a HashTable with the XML attributes. It has been 
99
         * created because the parser doesn't has a getAttribiute(AttributeName)
100
         * method.
101

102
         * @param parser
103
         * @return
104
         */
105
        public static Hashtable getAttributes(IXmlStreamReader parser){
106
                Hashtable hash = new Hashtable();
107
                int num_atributos = parser.getAttributeCount();
108
                for (int i=0 ; i<parser.getAttributeCount() ; i++){
109
                        String atributo=parser.getAttributeName(i);
110
                        String valor=parser.getAttributeValue(i);
111
                        if (valor!=null)
112
                                hash.put(parser.getAttributeName(i),parser.getAttributeValue(i));
113
                }
114
                return hash;
115
        }        
116
        
117
        /**
118
         * Remove the blanc symbol from a tag
119
         * @param tag
120
         * Tag name
121
         * @return
122
         * The tag without blancs
123
         */
124
        public static String removeBlancSymbol(String tag){
125
                if (tag == null){
126
                        return null;
127
                }
128
                String blancSpace = GPEDefaults.getStringProperty(GPEDefaults.DEFAULT_BLANC_SPACE);
129
                if (blancSpace == null){
130
                        blancSpace = KmlTags.DEFAULT_BLANC_SPACE;
131
                }
132
                // PROBLEM WITH COMPATIBILITY OF "replaceAll()" WITH IBM J9 JAVA MICROEDITION
133
                return StringUtils.replaceAllString(tag, blancSpace, " ");
134
                // return tag.replaceAll(blancSpace," ");
135
        }
136
        
137
        /**
138
         * Replace the blancs of a tag with the
139
         * deafult blanc symbol
140
         * @param tag
141
         * @return
142
         * A tag with blancs
143
         */
144
        public static String addBlancSymbol(String tag){
145
                if (tag == null){
146
                        return null;
147
                }
148
                String blancSpace = GPEDefaults.getStringProperty(GPEDefaults.DEFAULT_BLANC_SPACE);
149
                if (blancSpace == null){
150
                        blancSpace = KmlTags.DEFAULT_BLANC_SPACE;
151
                }
152
                // PROBLEM WITH COMPATIBILITY OF "replaceAll()" WITH IBM J9 JAVA MICROEDITION
153
                return StringUtils.replaceAllString(tag," ",blancSpace);
154
                //return tag.replaceAll(" ",blancSpace);
155
        }
156
}
157