Package org.openstreetmap.josm.io
Class OsmChangeBuilder
- java.lang.Object
-
- org.openstreetmap.josm.io.OsmChangeBuilder
-
public class OsmChangeBuilder extends 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 String
apiVersion
private String
currentMode
static String
DEFAULT_API_VERSION
Default OSM API versionprivate OsmWriter
osmwriter
private boolean
prologWritten
private StringWriter
swriter
private PrintWriter
writer
-
Constructor Summary
Constructors Constructor Description OsmChangeBuilder(Changeset changeset)
Constructs a newOsmChangeBuilder
.OsmChangeBuilder(Changeset changeset, String apiVersion)
Constructs a newOsmChangeBuilder
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(Collection<? extends IPrimitive> primitives)
Appends a collection of Primitives to the OsmChange document.void
append(IPrimitive p)
Appends an Primitive to the OsmChange document.private void
checkProlog()
void
finish()
Writes the epilog of the OsmChange documentString
getDocument()
Returns XML document.void
start()
Writes the prolog of the OsmChange documentprivate void
switchMode(String newMode)
protected void
write(IPrimitive p)
-
-
-
Field Detail
-
DEFAULT_API_VERSION
public static final String DEFAULT_API_VERSION
Default OSM API version- See Also:
- Constant Field Values
-
currentMode
private String currentMode
-
writer
private final PrintWriter writer
-
swriter
private final StringWriter swriter
-
apiVersion
private String apiVersion
-
prologWritten
private boolean prologWritten
-
-
Constructor Detail
-
OsmChangeBuilder
public OsmChangeBuilder(Changeset changeset)
Constructs a newOsmChangeBuilder
.- Parameters:
changeset
- changeset
-
OsmChangeBuilder
public OsmChangeBuilder(Changeset changeset, String apiVersion)
Constructs a newOsmChangeBuilder
.- Parameters:
changeset
- changesetapiVersion
- OSM API version
-
-
Method Detail
-
write
protected void write(IPrimitive p)
-
switchMode
private void switchMode(String newMode)
-
start
public void start()
Writes the prolog of the OsmChange document- Throws:
IllegalStateException
- if the prologs has already been written
-
append
public void append(Collection<? extends IPrimitive> primitives)
Appends a collection of Primitives to the OsmChange document.- Parameters:
primitives
- the collection of primitives. Ignored if null.- Throws:
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:
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:
IllegalStateException
- if the prologs has not been written yet
-
getDocument
public String getDocument()
Returns XML document.- Returns:
- XML document
-
-