svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / WFSSchemaParser.java @ 40769
History | View | Annotate | Download (2.65 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
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 | 40435 | jjdelcerro | 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 | /**
|
||
32 | *
|
||
33 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
34 | */
|
||
35 | public class WFSSchemaParser extends KXmlParser { |
||
36 | private String schema = ""; |
||
37 | |||
38 | public WFSSchemaParser(){
|
||
39 | super();
|
||
40 | } |
||
41 | |||
42 | public WFSSchemaParser(String schema){ |
||
43 | this.schema = schema;
|
||
44 | } |
||
45 | |||
46 | /**
|
||
47 | * It gets the schema from a tag. The schema is separated
|
||
48 | * of the tag name by ":".
|
||
49 | * @param tag
|
||
50 | */
|
||
51 | public void setSchemaFromMainTag(String tag){ |
||
52 | int pos = tag.indexOf(":"); |
||
53 | if (pos > 0){ |
||
54 | this.schema = tag.substring(0,pos); |
||
55 | }else{
|
||
56 | this.schema = ""; |
||
57 | } |
||
58 | } |
||
59 | |||
60 | /**
|
||
61 | * @return Returns the schema.
|
||
62 | */
|
||
63 | public String getSchema() { |
||
64 | return schema;
|
||
65 | } |
||
66 | |||
67 | /**
|
||
68 | * @param schema The schema to set.
|
||
69 | */
|
||
70 | public void setSchema(String schema) { |
||
71 | this.schema = schema;
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * Returns a SCHEMA:TAG
|
||
76 | * @param tag
|
||
77 | * @return SCHEMA:TAG
|
||
78 | */
|
||
79 | private String getTag(String tag){ |
||
80 | if (tag == null){ |
||
81 | return null; |
||
82 | } |
||
83 | if ((schema == null) || (schema.equals(""))){ |
||
84 | return tag;
|
||
85 | } |
||
86 | return schema + ":" + tag; |
||
87 | } |
||
88 | |||
89 | /*
|
||
90 | * (non-Javadoc)
|
||
91 | * @see org.xmlpull.v1.XmlPullParser#require(int, java.lang.String, java.lang.String)
|
||
92 | */
|
||
93 | public void require(int type, String namespace, String name) |
||
94 | throws XmlPullParserException, IOException{ |
||
95 | super.require(type,namespace,getTag(name));
|
||
96 | } |
||
97 | |||
98 | /*
|
||
99 | * (non-Javadoc)
|
||
100 | * @see org.xmlpull.v1.XmlPullParser#getName()
|
||
101 | */
|
||
102 | public String getName(){ |
||
103 | try{
|
||
104 | String name = super.getName(); |
||
105 | if ((schema != null) || (!(schema.equals("")))){ |
||
106 | return name.substring(name.indexOf(":") + 1,name.length()); |
||
107 | } |
||
108 | return name;
|
||
109 | }catch (NullPointerException e){ |
||
110 | return ""; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | } |