source: osm/applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsOsmWriter.java@ 30737

Last change on this file since 30737 was 30737, checked in by donvip, 11 years ago

[josm_plugins] fix Java 7 / unused code warnings

File size: 2.0 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.hot.sds;
3
4import java.io.PrintWriter;
5import java.util.ArrayList;
6import java.util.Collections;
7import java.util.List;
8import java.util.Map.Entry;
9
10import org.openstreetmap.josm.data.osm.Changeset;
11import org.openstreetmap.josm.data.osm.Tagged;
12import org.openstreetmap.josm.io.OsmWriter;
13import org.openstreetmap.josm.io.XmlWriter;
14
15/**
16 * This is a special version of JOSM's OsmWriter that makes
17 * sure that special tags are never written to JOSM's standard
18 * output channels.
19 *
20 * In the context of HOT's separate data store, this is very
21 * important as otherwise private/confidential information could
22 * end up on public servers.
23 *
24 * @author Frederik Ramm
25 *
26 */
27public class SdsOsmWriter extends OsmWriter {
28
29 private SeparateDataStorePlugin plugin;
30
31 public SdsOsmWriter(SeparateDataStorePlugin plugin, PrintWriter out, boolean osmConform, String version) {
32 super(out, osmConform, version);
33 this.plugin = plugin;
34 }
35
36 @Override
37 protected void addTags(Tagged osm, String tagname, boolean tagOpen) {
38 if (osm.hasKeys()) {
39 if (tagOpen) {
40 out.println(">");
41 }
42 List<Entry<String, String>> entries = new ArrayList<>(osm.getKeys().entrySet());
43 Collections.sort(entries, byKeyComparator);
44 for (Entry<String, String> e : entries) {
45 String key = e.getKey();
46 if (!(osm instanceof Changeset) && ("created_by".equals(key))) continue;
47 if (key.startsWith(plugin.getIgnorePrefix())) continue;
48 out.println(" <tag k='"+ XmlWriter.encode(e.getKey()) +
49 "' v='"+XmlWriter.encode(e.getValue())+ "' />");
50 }
51 out.println(" </" + tagname + ">");
52 } else if (tagOpen) {
53 out.println(" />");
54 } else {
55 out.println(" </" + tagname + ">");
56 }
57 }
58}
Note: See TracBrowser for help on using the repository browser.