root / branches / v2_0_0_prep / libraries / libGPE-GML / src / org / gvsig / gpe / gml / writer / v2 / features / FeatureCollectionWriter.java @ 28113
History | View | Annotate | Download (5.39 KB)
1 |
package org.gvsig.gpe.gml.writer.v2.features; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import javax.xml.namespace.QName; |
6 |
|
7 |
import org.gvsig.gpe.GPELocator; |
8 |
import org.gvsig.gpe.GPEManager; |
9 |
import org.gvsig.gpe.gml.utils.GMLTags; |
10 |
import org.gvsig.gpe.gml.utils.GMLUtilsParser; |
11 |
import org.gvsig.gpe.gml.writer.GPEGmlWriterHandlerImplementor; |
12 |
import org.gvsig.gpe.xml.XmlProperties; |
13 |
import org.gvsig.gpe.xml.stream.IXmlStreamWriter; |
14 |
import org.gvsig.gpe.xml.utils.XMLTags; |
15 |
|
16 |
|
17 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
18 |
*
|
19 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
20 |
*
|
21 |
* This program is free software; you can redistribute it and/or
|
22 |
* modify it under the terms of the GNU General Public License
|
23 |
* as published by the Free Software Foundation; either version 2
|
24 |
* of the License, or (at your option) any later version.
|
25 |
*
|
26 |
* This program is distributed in the hope that it will be useful,
|
27 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
28 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
29 |
* GNU General Public License for more details.
|
30 |
*
|
31 |
* You should have received a copy of the GNU General Public License
|
32 |
* along with this program; if not, write to the Free Software
|
33 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
34 |
*
|
35 |
* For more information, contact:
|
36 |
*
|
37 |
* Generalitat Valenciana
|
38 |
* Conselleria d'Infraestructures i Transport
|
39 |
* Av. Blasco Ib??ez, 50
|
40 |
* 46010 VALENCIA
|
41 |
* SPAIN
|
42 |
*
|
43 |
* +34 963862235
|
44 |
* gvsig@gva.es
|
45 |
* www.gvsig.gva.es
|
46 |
*
|
47 |
* or
|
48 |
*
|
49 |
* IVER T.I. S.A
|
50 |
* Salamanca 50
|
51 |
* 46005 Valencia
|
52 |
* Spain
|
53 |
*
|
54 |
* +34 963163400
|
55 |
* dac@iver.es
|
56 |
*/
|
57 |
/* CVS MESSAGES:
|
58 |
*
|
59 |
* $Id$
|
60 |
* $Log$
|
61 |
*
|
62 |
*/
|
63 |
/**
|
64 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es)
|
65 |
*/
|
66 |
public class FeatureCollectionWriter { |
67 |
private static GPEManager gpeManager = GPELocator.getGPEManager(); |
68 |
|
69 |
/**
|
70 |
* It writes the FeatureCollection init tag
|
71 |
* @param writer
|
72 |
* Writer to write the labels
|
73 |
* @param handler
|
74 |
* The writer handler implementor
|
75 |
* @param id
|
76 |
* Feature id
|
77 |
* @param namespace
|
78 |
* Feature namespace
|
79 |
* @param name
|
80 |
* Feature name
|
81 |
* @throws IOException
|
82 |
*/
|
83 |
public void start(IXmlStreamWriter writer, GPEGmlWriterHandlerImplementor handler, String fid, |
84 |
String namespace, String name) throws IOException{ |
85 |
String myName = GMLUtilsParser.addBlancSymbol(name);
|
86 |
String myNamespace = namespace;
|
87 |
if (name == null){ |
88 |
QName qname = GMLUtilsParser.createDefaultFeatureCollection();
|
89 |
myName = qname.getLocalPart(); |
90 |
myNamespace = qname.getNamespaceURI(); |
91 |
}else if (namespace == null){ |
92 |
myNamespace = gpeManager.getStringProperty(XmlProperties.DEFAULT_NAMESPACE_URI); |
93 |
} |
94 |
writer.writeStartElement(myNamespace, myName); |
95 |
if (fid != null){ |
96 |
writer.writeStartAttribute(GMLTags.GML_FID); |
97 |
writer.writeValue(fid); |
98 |
} |
99 |
//Write namespaces: this functionality must be implemented on the writer, not here!!!
|
100 |
writer.writeStartAttribute(XMLTags.XML_NAMESPACE_URI, |
101 |
XMLTags.XML_NAMESPACE_PREFIX + ":" + XMLTags.XML_SCHEMA_INSTANCE_NAMESPACE_PREFIX);
|
102 |
writer.writeValue(XMLTags.XML_SCHEMA_INSTANCE_NAMESPACE_URI); |
103 |
|
104 |
writer.writeStartAttribute(XMLTags.XML_NAMESPACE_URI, |
105 |
XMLTags.XML_NAMESPACE_PREFIX + ":" + XMLTags.XML_XLINK_NAMESPACE_PREFIX);
|
106 |
writer.writeValue(XMLTags.XML_XLINK_NAMESPACE_URI); |
107 |
|
108 |
writer.writeStartAttribute(XMLTags.XML_NAMESPACE_URI, |
109 |
XMLTags.XML_NAMESPACE_PREFIX + ":" + GMLTags.GML_NAMESPACE_PREFIX);
|
110 |
writer.writeValue(GMLTags.GML_NAMESPACE_URI); |
111 |
|
112 |
writer.writeStartAttribute(XMLTags.XML_NAMESPACE_URI, |
113 |
XMLTags.XML_NAMESPACE_PREFIX + ":" + gpeManager.getStringProperty(XmlProperties.DEFAULT_NAMESPACE_PREFIX));
|
114 |
writer.writeValue(gpeManager.getStringProperty(XmlProperties.DEFAULT_NAMESPACE_URI)); |
115 |
|
116 |
writer.writeStartAttribute(XMLTags.XML_SCHEMA_INSTANCE_NAMESPACE_URI, |
117 |
XMLTags.XML_SCHEMA_INSTANCE_NAMESPACE_PREFIX + ":" + XMLTags.XML_SCHEMA_LOCATION);
|
118 |
String schemaLocation = gpeManager.getStringProperty(XmlProperties.DEFAULT_NAMESPACE_URI) +
|
119 |
" " + gpeManager.getStringProperty(XmlProperties.XSD_SCHEMA_FILE);
|
120 |
writer.writeValue(schemaLocation); |
121 |
} |
122 |
|
123 |
/**
|
124 |
* It writes the FeatureCollection init tag
|
125 |
* @param writer
|
126 |
* Writer to write the labels
|
127 |
* @param handler
|
128 |
* The writer handler implementor
|
129 |
* @param id
|
130 |
* Feature id
|
131 |
* @param namespace
|
132 |
* Feature namespace
|
133 |
* @param name
|
134 |
* Feature name
|
135 |
* @param description
|
136 |
* The feature collection decription
|
137 |
* @param srs
|
138 |
* The feature collection srs
|
139 |
* @throws IOException
|
140 |
*/
|
141 |
public void start(IXmlStreamWriter writer, GPEGmlWriterHandlerImplementor handler, String fid, |
142 |
String namespace, String name, String description, String srs) throws IOException{ |
143 |
start(writer, handler, fid, namespace, name); |
144 |
writer.writeEndAttributes(); |
145 |
handler.getProfile().getNameWriter().write(writer, handler, name); |
146 |
handler.getProfile().getDescriptionWriter().write(writer, handler, description); |
147 |
} |
148 |
|
149 |
/**
|
150 |
* It writes a Feature end tag
|
151 |
* @param writer
|
152 |
* Writer to write the labels
|
153 |
* @param handler
|
154 |
* The writer handler implementor
|
155 |
* @param namespace
|
156 |
* Feature namespace
|
157 |
* @param name
|
158 |
* Feature name
|
159 |
* @throws IOException
|
160 |
*/
|
161 |
public void end(IXmlStreamWriter writer, GPEGmlWriterHandlerImplementor handler) throws IOException{ |
162 |
writer.writeEndElement(); |
163 |
} |
164 |
|
165 |
|
166 |
} |