svn-gvsig-desktop / tags / v1_0_2_RELEASE / libraries / libRemoteServices / src / org / gvsig / remoteClient / wfs / WFSSchemaParser.java @ 11432
History | View | Annotate | Download (3.03 KB)
1 | 5215 | jorpiell | package org.gvsig.remoteClient.wfs; |
---|---|---|---|
2 | |||
3 | import java.io.IOException; |
||
4 | |||
5 | import org.kxml2.io.KXmlParser; |
||
6 | import org.xmlpull.v1.XmlPullParserException; |
||
7 | |||
8 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
9 | *
|
||
10 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
11 | *
|
||
12 | * This program is free software; you can redistribute it and/or
|
||
13 | * modify it under the terms of the GNU General Public License
|
||
14 | * as published by the Free Software Foundation; either version 2
|
||
15 | * of the License, or (at your option) any later version.
|
||
16 | *
|
||
17 | * This program is distributed in the hope that it will be useful,
|
||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
20 | * GNU General Public License for more details.
|
||
21 | *
|
||
22 | * You should have received a copy of the GNU General Public License
|
||
23 | * along with this program; if not, write to the Free Software
|
||
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
25 | *
|
||
26 | * For more information, contact:
|
||
27 | *
|
||
28 | * Generalitat Valenciana
|
||
29 | * Conselleria d'Infraestructures i Transport
|
||
30 | * Av. Blasco Ib??ez, 50
|
||
31 | * 46010 VALENCIA
|
||
32 | * SPAIN
|
||
33 | *
|
||
34 | * +34 963862235
|
||
35 | * gvsig@gva.es
|
||
36 | * www.gvsig.gva.es
|
||
37 | *
|
||
38 | * or
|
||
39 | *
|
||
40 | * IVER T.I. S.A
|
||
41 | * Salamanca 50
|
||
42 | * 46005 Valencia
|
||
43 | * Spain
|
||
44 | *
|
||
45 | * +34 963163400
|
||
46 | * dac@iver.es
|
||
47 | */
|
||
48 | /* CVS MESSAGES:
|
||
49 | *
|
||
50 | * $Id$
|
||
51 | * $Log$
|
||
52 | * Revision 1.1 2006-05-16 14:12:56 jorpiell
|
||
53 | * A?adido el parseador de Esquemas
|
||
54 | *
|
||
55 | *
|
||
56 | */
|
||
57 | /**
|
||
58 | *
|
||
59 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
60 | */
|
||
61 | public class WFSSchemaParser extends KXmlParser { |
||
62 | private String schema = ""; |
||
63 | |||
64 | public WFSSchemaParser(){
|
||
65 | super();
|
||
66 | } |
||
67 | |||
68 | public WFSSchemaParser(String schema){ |
||
69 | this.schema = schema;
|
||
70 | } |
||
71 | |||
72 | /**
|
||
73 | * It gets the schema from a tag. The schema is separated
|
||
74 | * of the tag name by ":".
|
||
75 | * @param tag
|
||
76 | */
|
||
77 | public void setSchemaFromMainTag(String tag){ |
||
78 | int pos = tag.indexOf(":"); |
||
79 | if (pos > 0){ |
||
80 | this.schema = tag.substring(0,pos); |
||
81 | }else{
|
||
82 | this.schema = ""; |
||
83 | } |
||
84 | } |
||
85 | |||
86 | /**
|
||
87 | * @return Returns the schema.
|
||
88 | */
|
||
89 | public String getSchema() { |
||
90 | return schema;
|
||
91 | } |
||
92 | |||
93 | /**
|
||
94 | * @param schema The schema to set.
|
||
95 | */
|
||
96 | public void setSchema(String schema) { |
||
97 | this.schema = schema;
|
||
98 | } |
||
99 | |||
100 | /**
|
||
101 | * Returns a SCHEMA:TAG
|
||
102 | * @param tag
|
||
103 | * @return SCHEMA:TAG
|
||
104 | */
|
||
105 | private String getTag(String tag){ |
||
106 | if (tag == null){ |
||
107 | return null; |
||
108 | } |
||
109 | if ((schema == null) || (schema.equals(""))){ |
||
110 | return tag;
|
||
111 | } |
||
112 | return schema + ":" + tag; |
||
113 | } |
||
114 | |||
115 | /*
|
||
116 | * (non-Javadoc)
|
||
117 | * @see org.xmlpull.v1.XmlPullParser#require(int, java.lang.String, java.lang.String)
|
||
118 | */
|
||
119 | public void require(int type, String namespace, String name) |
||
120 | throws XmlPullParserException, IOException{ |
||
121 | super.require(type,namespace,getTag(name));
|
||
122 | } |
||
123 | |||
124 | /*
|
||
125 | * (non-Javadoc)
|
||
126 | * @see org.xmlpull.v1.XmlPullParser#getName()
|
||
127 | */
|
||
128 | public String getName(){ |
||
129 | try{
|
||
130 | String name = super.getName(); |
||
131 | if ((schema != null) || (!(schema.equals("")))){ |
||
132 | return name.substring(name.indexOf(":") + 1,name.length()); |
||
133 | } |
||
134 | return name;
|
||
135 | }catch (NullPointerException e){ |
||
136 | return ""; |
||
137 | } |
||
138 | } |
||
139 | |||
140 | } |