svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.api / oldcode / handler / SLDProtocolHandler.java @ 40781
History | View | Annotate | Download (3.73 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.handler; |
42 |
|
43 |
import java.io.File; |
44 |
import java.io.FileReader; |
45 |
import java.io.IOException; |
46 |
import java.util.ArrayList; |
47 |
|
48 |
import org.gvsig.sldsupport.exception.SLDReadException; |
49 |
import org.gvsig.sldsupport.layer.ISLDLayer; |
50 |
import org.gvsig.sldsupport.util.SLDTags; |
51 |
import org.xmlpull.v1.XmlPullParser; |
52 |
import org.xmlpull.v1.XmlPullParserException; |
53 |
|
54 |
/**
|
55 |
* Implements the main class for the SLD implementation specification (version 1.0.0)
|
56 |
* which starts the parsing of the styled layer descriptor document in order to store
|
57 |
* all the information that it has inside and transform it into objects.<p>
|
58 |
*
|
59 |
* An SLD document is defined as a sequence of styled layers.<p>
|
60 |
* The version attribute gives the SLD version an SLD document, to facilitate backward
|
61 |
* compatibility with static documents stored in various different versions of an SLD
|
62 |
* spec.<p>
|
63 |
*
|
64 |
* The Styled layers can correspond to either named layers or user-defined layers,
|
65 |
* which are described in subsequent sections. There may be any number of either type
|
66 |
* of styled layer, including zero, mixed in any order.
|
67 |
*
|
68 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188
|
69 |
*
|
70 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
71 |
*/
|
72 |
public abstract class SLDProtocolHandler { |
73 |
|
74 |
|
75 |
protected String name; |
76 |
private String version; |
77 |
protected ArrayList<ISLDLayer> layers = new ArrayList<ISLDLayer>(); ; |
78 |
|
79 |
public abstract void parse(File f) |
80 |
throws IOException, XmlPullParserException, SLDReadException; |
81 |
|
82 |
public String detectVersion(File f) |
83 |
throws XmlPullParserException, IOException, SLDReadException { |
84 |
|
85 |
int tag;
|
86 |
XmlPullParser parser = null;
|
87 |
// xmlSchemaParser = new XMLSchemaParser();
|
88 |
|
89 |
|
90 |
FileReader fr = new FileReader(f); |
91 |
parser.setInput(fr); |
92 |
parser.nextTag(); |
93 |
|
94 |
if ( parser.getEventType() != XmlPullParser.END_DOCUMENT ) {
|
95 |
|
96 |
String value = parser.getAttributeValue("",SLDTags.VERSION_ATTR); |
97 |
fr.close(); |
98 |
return value;
|
99 |
} |
100 |
fr.close(); |
101 |
throw new SLDReadException(new Exception("Unable to get SLD version" + |
102 |
" in file: " + f.getAbsolutePath()));
|
103 |
} |
104 |
|
105 |
public ArrayList<ISLDLayer> getLayers() { |
106 |
return layers;
|
107 |
} |
108 |
public void setLayers(ArrayList<ISLDLayer> layers) { |
109 |
this.layers = layers;
|
110 |
} |
111 |
|
112 |
public String getName() { |
113 |
return name;
|
114 |
} |
115 |
public void setName(String name) { |
116 |
this.name = name;
|
117 |
} |
118 |
public String getVersion() { |
119 |
return version;
|
120 |
} |
121 |
public void setVersion(String version) { |
122 |
this.version = version;
|
123 |
} |
124 |
} |