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

Last change on this file since 13795 was 11851, checked in by Don-vip, 7 years ago

sonar - squid:S1444 - "public static" fields should be constant

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import java.io.PrintWriter;
5import java.util.Objects;
6
7/**
8 * This factory is called by everyone who needs an OsmWriter object,
9 * instead of directly calling the OsmWriter constructor.
10 *
11 * This enables plugins to substitute the original OsmWriter with
12 * their own version, altering the way JOSM writes objects to the
13 * server, and to disk.
14 *
15 * @author Frederik Ramm
16 *
17 */
18public class OsmWriterFactory {
19
20 private static volatile OsmWriterFactory theFactory;
21
22 /**
23 * Creates new {@code OsmWriter}.
24 * @param out print writer
25 * @param osmConform if {@code true}, prevents modification attributes to be written to the common part
26 * @param version OSM API version (0.6)
27 * @return new {@code OsmWriter}
28 */
29 public static OsmWriter createOsmWriter(PrintWriter out, boolean osmConform, String version) {
30 // pre-set factory with this default implementation; can still be overwritten
31 // later. note that the default factory may already be used for constructing
32 // OsmWriters during the startup process.
33 if (theFactory == null) {
34 theFactory = new OsmWriterFactory();
35 }
36 return theFactory.createOsmWriterImpl(out, osmConform, version);
37 }
38
39 /**
40 * Sets the default factory.
41 * @param factory new default factory
42 * @since 11851
43 */
44 public static void setDefaultFactory(OsmWriterFactory factory) {
45 theFactory = Objects.requireNonNull(factory);
46 }
47
48 /**
49 * Creates new {@code OsmWriter}.
50 * @param out print writer
51 * @param osmConform if {@code true}, prevents modification attributes to be written to the common part
52 * @param version OSM API version (0.6)
53 * @return new {@code OsmWriter}
54 */
55 protected OsmWriter createOsmWriterImpl(PrintWriter out, boolean osmConform, String version) {
56 return new OsmWriter(out, osmConform, version);
57 }
58}
Note: See TracBrowser for help on using the repository browser.