Package org.openstreetmap.josm.data.osm
Class ChangesetDataSet
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.ChangesetDataSet
-
public class ChangesetDataSet extends java.lang.Object
A ChangesetDataSet holds the content of a changeset. Typically, a primitive is modified only once in a changeset, but if there are multiple modifications, the first and last are kept. Further intermediate versions are not kept.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ChangesetDataSet.ChangesetDataSetEntry
An entry in the changeset dataset.static class
ChangesetDataSet.ChangesetModificationType
Type of primitive modification.static class
ChangesetDataSet.DefaultChangesetDataSetEntry
Class to keep one entry of a changeset: the combination of modification type and primitive.private static class
ChangesetDataSet.DefaultIterator
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<PrimitiveId,java.lang.Object>
entryMap
maps an id to either oneChangesetDataSet.ChangesetDataSetEntry
or an array ofChangesetDataSet.ChangesetDataSetEntry
-
Constructor Summary
Constructors Constructor Description ChangesetDataSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(PrimitiveId id)
Replies true if the changeset content contains the object with primitiveid
.private ChangesetDataSet.ChangesetDataSetEntry
getEntry(PrimitiveId id, int n)
ChangesetDataSet.ChangesetDataSetEntry
getFirstEntry(PrimitiveId id)
Replies the firstChangesetDataSet.ChangesetDataSetEntry
with idid
from this dataset.java.util.Set<PrimitiveId>
getIds()
Returns an unmodifiable set of all primitives in this dataset.ChangesetDataSet.ChangesetDataSetEntry
getLastEntry(PrimitiveId id)
Replies the lastChangesetDataSet.ChangesetDataSetEntry
with idid
from this dataset.ChangesetDataSet.ChangesetModificationType
getModificationType(PrimitiveId id)
Replies the last modification type for the object with idid
.HistoryOsmPrimitive
getPrimitive(PrimitiveId id)
Replies theHistoryOsmPrimitive
with idid
from this dataset.boolean
isCreated(PrimitiveId id)
Replies true if the primitive with idid
was created in this changeset.boolean
isDeleted(PrimitiveId id)
Replies true if the primitive with idid
was deleted in this changeset.boolean
isUpdated(PrimitiveId id)
Replies true if the primitive with idid
was updated in this changeset.java.util.Iterator<ChangesetDataSet.ChangesetDataSetEntry>
iterator()
Returns an iterator over dataset entries.void
put(HistoryOsmPrimitive primitive, ChangesetDataSet.ChangesetModificationType cmt)
Remembers a history primitive with the given modification typeint
size()
Replies the number of primitives in the dataset.
-
-
-
Field Detail
-
entryMap
private final java.util.Map<PrimitiveId,java.lang.Object> entryMap
maps an id to either oneChangesetDataSet.ChangesetDataSetEntry
or an array ofChangesetDataSet.ChangesetDataSetEntry
-
-
Constructor Detail
-
ChangesetDataSet
public ChangesetDataSet()
-
-
Method Detail
-
put
public void put(HistoryOsmPrimitive primitive, ChangesetDataSet.ChangesetModificationType cmt)
Remembers a history primitive with the given modification type- Parameters:
primitive
- the primitive. Must not be null.cmt
- the modification type. Must not be null.- Throws:
java.lang.IllegalArgumentException
- if primitive is nulljava.lang.IllegalArgumentException
- if cmt is nulljava.lang.IllegalArgumentException
- if the same primitive was already stored with a higher or equal version
-
contains
public boolean contains(PrimitiveId id)
Replies true if the changeset content contains the object with primitiveid
.- Parameters:
id
- the id.- Returns:
- true if the changeset content contains the object with primitive
id
-
getModificationType
public ChangesetDataSet.ChangesetModificationType getModificationType(PrimitiveId id)
Replies the last modification type for the object with idid
. Replies null, if id is null or if the object with idid
isn't in the changeset content.- Parameters:
id
- the id- Returns:
- the last modification type or null
-
isCreated
public boolean isCreated(PrimitiveId id)
Replies true if the primitive with idid
was created in this changeset. Replies false, if id is null or not in the dataset.- Parameters:
id
- the id- Returns:
- true if the primitive with id
id
was created in this changeset.
-
isUpdated
public boolean isUpdated(PrimitiveId id)
Replies true if the primitive with idid
was updated in this changeset. Replies false, if id is null or not in the dataset.- Parameters:
id
- the id- Returns:
- true if the primitive with id
id
was updated in this changeset.
-
isDeleted
public boolean isDeleted(PrimitiveId id)
Replies true if the primitive with idid
was deleted in this changeset. Replies false, if id is null or not in the dataset.- Parameters:
id
- the id- Returns:
- true if the primitive with id
id
was deleted in this changeset.
-
size
public int size()
Replies the number of primitives in the dataset.- Returns:
- the number of primitives in the dataset.
-
getPrimitive
public HistoryOsmPrimitive getPrimitive(PrimitiveId id)
Replies theHistoryOsmPrimitive
with idid
from this dataset. null, if there is no such primitive in the data set. If the primitive was modified multiple times, the last version is returned.- Parameters:
id
- the id- Returns:
- the
HistoryOsmPrimitive
with idid
from this dataset
-
getIds
public java.util.Set<PrimitiveId> getIds()
Returns an unmodifiable set of all primitives in this dataset.- Returns:
- an unmodifiable set of all primitives in this dataset.
- Since:
- 14946
-
getFirstEntry
public ChangesetDataSet.ChangesetDataSetEntry getFirstEntry(PrimitiveId id)
Replies the firstChangesetDataSet.ChangesetDataSetEntry
with idid
from this dataset. null, if there is no such primitive in the data set.- Parameters:
id
- the id- Returns:
- the first
ChangesetDataSet.ChangesetDataSetEntry
with idid
from this dataset or null. - Since:
- 14946
-
getLastEntry
public ChangesetDataSet.ChangesetDataSetEntry getLastEntry(PrimitiveId id)
Replies the lastChangesetDataSet.ChangesetDataSetEntry
with idid
from this dataset. null, if there is no such primitive in the data set.- Parameters:
id
- the id- Returns:
- the last
ChangesetDataSet.ChangesetDataSetEntry
with idid
from this dataset or null. - Since:
- 14946
-
getEntry
private ChangesetDataSet.ChangesetDataSetEntry getEntry(PrimitiveId id, int n)
-
iterator
public java.util.Iterator<ChangesetDataSet.ChangesetDataSetEntry> iterator()
Returns an iterator over dataset entries. The elements are returned in no particular order.- Returns:
- an iterator over dataset entries. If a primitive was changed multiple times, only the last entry is returned.
-
-