Package org.openstreetmap.josm.io
Class OsmChangeBuilder
- java.lang.Object
-
- org.openstreetmap.josm.io.OsmChangeBuilder
-
public class OsmChangeBuilder extends java.lang.Object
Creates an OsmChange document from JOSM edits. See http://wiki.openstreetmap.org/index.php/OsmChange for a documentation of the OsmChange format.- Since:
- 1071
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringapiVersionprivate java.lang.StringcurrentModestatic java.lang.StringDEFAULT_API_VERSIONDefault OSM API versionprivate OsmWriterosmwriterprivate booleanprologWrittenprivate java.io.StringWriterswriterprivate java.io.PrintWriterwriter
-
Constructor Summary
Constructors Constructor Description OsmChangeBuilder(Changeset changeset)Constructs a newOsmChangeBuilder.OsmChangeBuilder(Changeset changeset, java.lang.String apiVersion)Constructs a newOsmChangeBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(java.util.Collection<? extends IPrimitive> primitives)Appends a collection of Primitives to the OsmChange document.voidappend(IPrimitive p)Appends an Primitive to the OsmChange document.private voidcheckProlog()voidfinish()Writes the epilog of the OsmChange documentjava.lang.StringgetDocument()Returns XML document.voidstart()Writes the prolog of the OsmChange documentprivate voidswitchMode(java.lang.String newMode)protected voidwrite(IPrimitive p)
-
-
-
Field Detail
-
DEFAULT_API_VERSION
public static final java.lang.String DEFAULT_API_VERSION
Default OSM API version- See Also:
- Constant Field Values
-
currentMode
private java.lang.String currentMode
-
writer
private final java.io.PrintWriter writer
-
swriter
private final java.io.StringWriter swriter
-
apiVersion
private java.lang.String apiVersion
-
prologWritten
private boolean prologWritten
-
-
Constructor Detail
-
OsmChangeBuilder
public OsmChangeBuilder(Changeset changeset)
Constructs a newOsmChangeBuilder.- Parameters:
changeset- changeset
-
OsmChangeBuilder
public OsmChangeBuilder(Changeset changeset, java.lang.String apiVersion)
Constructs a newOsmChangeBuilder.- Parameters:
changeset- changesetapiVersion- OSM API version
-
-
Method Detail
-
write
protected void write(IPrimitive p)
-
switchMode
private void switchMode(java.lang.String newMode)
-
start
public void start()
Writes the prolog of the OsmChange document- Throws:
java.lang.IllegalStateException- if the prologs has already been written
-
append
public void append(java.util.Collection<? extends IPrimitive> primitives)
Appends a collection of Primitives to the OsmChange document.- Parameters:
primitives- the collection of primitives. Ignored if null.- Throws:
java.lang.IllegalStateException- if the prologs has not been written yet- See Also:
start(),append(IPrimitive)
-
checkProlog
private void checkProlog()
-
append
public void append(IPrimitive p)
Appends an Primitive to the OsmChange document.- Parameters:
p- the primitive. Ignored if null.- Throws:
java.lang.IllegalStateException- if the prologs has not been written yet- See Also:
start(),append(Collection)
-
finish
public void finish()
Writes the epilog of the OsmChange document- Throws:
java.lang.IllegalStateException- if the prologs has not been written yet
-
getDocument
public java.lang.String getDocument()
Returns XML document.- Returns:
- XML document
-
-