Package org.openstreetmap.josm.io
Class DiffResultProcessor
- java.lang.Object
-
- org.openstreetmap.josm.io.DiffResultProcessor
-
public class DiffResultProcessor extends java.lang.Object
Helper class to process the OSM API server response to a "diff" upload.New primitives (uploaded with negative id) will be assigned a positive id, etc. The goal is to have a clean state, just like a fresh download (assuming no concurrent uploads by other users have happened in the meantime).
- See Also:
- API 0.6 diff upload response
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DiffResultProcessor.DiffResultEntry
private class
DiffResultProcessor.Parser
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<PrimitiveId,DiffResultProcessor.DiffResultEntry>
diffResults
mapping from old id to new id and version, the result of parsing the diff result replied by the serverprivate java.util.Collection<? extends OsmPrimitive>
primitives
the collection of primitives being uploadedprivate java.util.Set<OsmPrimitive>
processed
the set of processed primitives *after* the new id, the new version and the new changeset id is set
-
Constructor Summary
Constructors Constructor Description DiffResultProcessor(java.util.Collection<? extends OsmPrimitive> primitives)
Creates a diff result reader
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.util.Map<PrimitiveId,DiffResultProcessor.DiffResultEntry>
getDiffResults()
void
parse(java.lang.String diffUploadResponse, ProgressMonitor progressMonitor)
Parse the response from a diff upload to the OSM API.protected java.util.Set<OsmPrimitive>
postProcess(Changeset cs, ProgressMonitor monitor)
Postprocesses the diff result read and parsed from the server.
-
-
-
Field Detail
-
diffResults
private final java.util.Map<PrimitiveId,DiffResultProcessor.DiffResultEntry> diffResults
mapping from old id to new id and version, the result of parsing the diff result replied by the server
-
processed
private final java.util.Set<OsmPrimitive> processed
the set of processed primitives *after* the new id, the new version and the new changeset id is set
-
primitives
private final java.util.Collection<? extends OsmPrimitive> primitives
the collection of primitives being uploaded
-
-
Constructor Detail
-
DiffResultProcessor
public DiffResultProcessor(java.util.Collection<? extends OsmPrimitive> primitives)
Creates a diff result reader- Parameters:
primitives
- the collection of primitives which have been uploaded. If null, assumes an empty collection.
-
-
Method Detail
-
parse
public void parse(java.lang.String diffUploadResponse, ProgressMonitor progressMonitor) throws XmlParsingException
Parse the response from a diff upload to the OSM API.- Parameters:
diffUploadResponse
- the response. Must not be null.progressMonitor
- a progress monitor. Defaults toNullProgressMonitor.INSTANCE
if null- Throws:
java.lang.IllegalArgumentException
- if diffUploadRequest is nullXmlParsingException
- if the diffUploadRequest can't be parsed successfully
-
postProcess
protected java.util.Set<OsmPrimitive> postProcess(Changeset cs, ProgressMonitor monitor)
Postprocesses the diff result read and parsed from the server.Uploaded objects are assigned their new id (if they got assigned a new id by the server), their new version (if the version was incremented), and the id of the changeset to which they were uploaded.
- Parameters:
cs
- the current changeset. Ignored if null.monitor
- the progress monitor. Set toNullProgressMonitor.INSTANCE
if null- Returns:
- the collection of processed primitives
-
getDiffResults
final java.util.Map<PrimitiveId,DiffResultProcessor.DiffResultEntry> getDiffResults()
-
-