source: josm/trunk/src/org/openstreetmap/josm/io/OsmWriterFactory.java@ 5299

Last change on this file since 5299 was 4645, checked in by framm, 12 years ago

Added three new hooks for plugins, allowing plugins to mess with JOSM's server I/O. Plugins can now add postprocessors to server reading (so they may change what JOSM receives from the OSM server), and they can add postprocessors to server writing (so they can react to an upload action *after* it happened and after IDs for new objects have been assigned - this is in addition to the existing UploadHook which is a server writing preprocessor). Thirdly, plugins can now substitute their own version of OsmWriter. Taken together, these changes make it possible for a plugin to introduce extra information from a non-OSM source into the JOSM editing process, and upon upload split away that extra information and send it to another destination. - Also made minor changes to CredentialDialog to allow plugins to subclass the dialog in case they need their own authentication.

File size: 1.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import java.io.PrintWriter;
5
6/**
7 * This factory is called by everyone who needs an OsmWriter object,
8 * instead of directly calling the OsmWriter constructor.
9 *
10 * This enables plugins to substitute the original OsmWriter with
11 * their own version, altering the way JOSM writes objects to the
12 * server, and to disk.
13 *
14 * @author Frederik Ramm
15 *
16 */
17public class OsmWriterFactory {
18
19 public static OsmWriterFactory theFactory;
20 public static OsmWriter createOsmWriter(PrintWriter out, boolean osmConform, String version) {
21 // pre-set factory with this default implementation; can still be overwritten
22 // later. note that the default factory may already be used for constructing
23 // OsmWriters during the startup process.
24 if (theFactory == null) {
25 theFactory = new OsmWriterFactory();
26 }
27 return theFactory.createOsmWriterImpl(out, osmConform, version);
28 }
29 protected OsmWriter createOsmWriterImpl(PrintWriter out, boolean osmConform, String version) {
30 return new OsmWriter(out, osmConform, version);
31 }
32}
Note: See TracBrowser for help on using the repository browser.