Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / WFSSchemaParser.java @ 40559

History | View | Annotate | Download (4.02 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wfs;
25

    
26
import java.io.IOException;
27

    
28
import org.kxml2.io.KXmlParser;
29
import org.xmlpull.v1.XmlPullParserException;
30

    
31
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
32
 *
33
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
34
 *
35
 * This program is free software; you can redistribute it and/or
36
 * modify it under the terms of the GNU General Public License
37
 * as published by the Free Software Foundation; either version 2
38
 * of the License, or (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
48
 *
49
 * For more information, contact:
50
 *
51
 *  Generalitat Valenciana
52
 *   Conselleria d'Infraestructures i Transport
53
 *   Av. Blasco Ib??ez, 50
54
 *   46010 VALENCIA
55
 *   SPAIN
56
 *
57
 *      +34 963862235
58
 *   gvsig@gva.es
59
 *      www.gvsig.gva.es
60
 *
61
 *    or
62
 *
63
 *   IVER T.I. S.A
64
 *   Salamanca 50
65
 *   46005 Valencia
66
 *   Spain
67
 *
68
 *   +34 963163400
69
 *   dac@iver.es
70
 */
71
/* CVS MESSAGES:
72
 *
73
 * $Id: WFSSchemaParser.java 29650 2009-06-29 17:07:18Z jpiera $
74
 * $Log$
75
 * Revision 1.1  2006-05-16 14:12:56  jorpiell
76
 * A?adido el parseador de Esquemas
77
 *
78
 *
79
 */
80
/**
81
 * 
82
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
83
 */
84
public class WFSSchemaParser extends KXmlParser {
85
        private String schema = "";
86
        
87
        public WFSSchemaParser(){
88
                super();
89
        }
90
        
91
        public WFSSchemaParser(String schema){
92
                this.schema = schema;
93
        }
94
        
95
        /**
96
         * It gets the schema from a tag. The schema is separated
97
         * of the tag name by ":".
98
         * @param tag
99
         */
100
        public void setSchemaFromMainTag(String tag){
101
                int pos = tag.indexOf(":");
102
                if (pos > 0){
103
                        this.schema = tag.substring(0,pos);
104
                }else{
105
                        this.schema = "";
106
                }
107
        }        
108

    
109
        /**
110
         * @return Returns the schema.
111
         */
112
        public String getSchema() {
113
                return schema;
114
        }
115

    
116
        /**
117
         * @param schema The schema to set.
118
         */
119
        public void setSchema(String schema) {
120
                this.schema = schema;
121
        }        
122
        
123
        /**
124
         * Returns a SCHEMA:TAG
125
         * @param tag
126
         * @return SCHEMA:TAG
127
         */
128
        private String getTag(String tag){
129
                if (tag == null){
130
                        return null;
131
                }
132
                if ((schema == null) || (schema.equals(""))){
133
                        return tag;
134
                }
135
                return schema + ":" + tag;
136
        }
137
        
138
        /*
139
         *  (non-Javadoc)
140
         * @see org.xmlpull.v1.XmlPullParser#require(int, java.lang.String, java.lang.String)
141
         */
142
        public void require(int type, String namespace, String name)
143
                throws XmlPullParserException, IOException{
144
                super.require(type,namespace,getTag(name));
145
        }
146
        
147
        /*
148
         *  (non-Javadoc)
149
         * @see org.xmlpull.v1.XmlPullParser#getName()
150
         */
151
        public String getName(){
152
                try{
153
                String name = super.getName();
154
                if ((schema != null) || (!(schema.equals("")))){
155
                        return name.substring(name.indexOf(":") + 1,name.length());
156
                }
157
                return name;
158
                }catch (NullPointerException e){
159
                        return "";
160
                }
161
        }
162
        
163
}