svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.impl / src / main / java / org / gvsig / sldsupport / impl / sld1_0_0 / handler / Handler1_0_0.java @ 40787
History | View | Annotate | Download (3.74 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib��ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.sldsupport.impl.sld1_0_0.handler; |
42 |
|
43 |
|
44 |
import java.io.File; |
45 |
import java.io.FileReader; |
46 |
import java.io.IOException; |
47 |
import java.io.InputStream; |
48 |
|
49 |
import org.gvsig.sldsupport.exception.SLDReadException; |
50 |
import org.gvsig.sldsupport.impl.parser.ExtendedKXmlParser; |
51 |
import org.gvsig.sldsupport.impl.sld1_0_0.layers.SLDNamedLayer1_0_0; |
52 |
import org.gvsig.sldsupport.impl.sld1_0_0.layers.SLDUserLayer1_0_0; |
53 |
import org.gvsig.sldsupport.sld.SLDObject; |
54 |
import org.gvsig.sldsupport.sld.SLDRoot; |
55 |
import org.gvsig.sldsupport.sld.SLDTags; |
56 |
import org.gvsig.sldsupport.sld.layer.SLDLayer; |
57 |
import org.gvsig.sldsupport.sld.symbol.SLDSymbol; |
58 |
import org.kxml2.io.KXmlParser; |
59 |
import org.xmlpull.v1.XmlPullParser; |
60 |
import org.xmlpull.v1.XmlPullParserException; |
61 |
|
62 |
|
63 |
public class Handler1_0_0 { |
64 |
|
65 |
public Handler1_0_0() {
|
66 |
|
67 |
} |
68 |
|
69 |
public SLDObject parse(InputStream inStream, String encoding) |
70 |
throws XmlPullParserException, IOException, SLDReadException { |
71 |
|
72 |
int tag;
|
73 |
XmlPullParser parser = new ExtendedKXmlParser();
|
74 |
parser.setInput(inStream, encoding); |
75 |
|
76 |
tag = parser.next(); |
77 |
if (tag == XmlPullParser.START_DOCUMENT) {
|
78 |
parser.next(); |
79 |
parser.require(KXmlParser.START_TAG, null, SLDTags.SLD_ROOT);
|
80 |
// Now we are in root
|
81 |
} else {
|
82 |
if (tag != XmlPullParser.START_TAG) {
|
83 |
throw new SLDReadException( |
84 |
"Misplaced input stream (it's not before opening tag)");
|
85 |
} |
86 |
} |
87 |
|
88 |
String name = parser.getName();
|
89 |
if (name.compareToIgnoreCase(SLDTags.SLD_ROOT) == 0) { |
90 |
return parseRoot(parser);
|
91 |
} else {
|
92 |
if (name.compareToIgnoreCase(SLDTags.USERDEFINEDLAYER) == 0 |
93 |
|| name.compareToIgnoreCase(SLDTags.NAMEDLAYER) == 0) {
|
94 |
return parseLayer(parser);
|
95 |
} else {
|
96 |
if (name.compareToIgnoreCase(SLDTags.LINESYMBOLIZER) == 0 |
97 |
|| name.compareToIgnoreCase(SLDTags.POLYGONSYMBOLIZER) == 0
|
98 |
|| name.compareToIgnoreCase(SLDTags.POINTSYMBOLIZER) == 0
|
99 |
|| name.compareToIgnoreCase(SLDTags.TEXTSYMBOLIZER) == 0
|
100 |
|| name.compareToIgnoreCase(SLDTags.RASTERSYMBOLIZER) == 0) {
|
101 |
|
102 |
return parseSymbol(parser);
|
103 |
} |
104 |
} |
105 |
} |
106 |
throw new SLDReadException( |
107 |
"Misplaced input stream. Bad opening tag: " + name);
|
108 |
} |
109 |
|
110 |
private SLDSymbol parseSymbol(XmlPullParser parser) {
|
111 |
// TODO Auto-generated method stub
|
112 |
return null; |
113 |
} |
114 |
|
115 |
|
116 |
private SLDLayer parseLayer(XmlPullParser parser) {
|
117 |
// TODO Auto-generated method stub
|
118 |
return null; |
119 |
} |
120 |
|
121 |
private SLDRoot parseRoot(XmlPullParser parser) {
|
122 |
// TODO Auto-generated method stub
|
123 |
return null; |
124 |
} |
125 |
} |