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 interfaceChangesetDataSet.ChangesetDataSetEntryAn entry in the changeset dataset.static classChangesetDataSet.ChangesetModificationTypeType of primitive modification.static classChangesetDataSet.DefaultChangesetDataSetEntryClass to keep one entry of a changeset: the combination of modification type and primitive.private static classChangesetDataSet.DefaultIterator
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<PrimitiveId,java.lang.Object>entryMapmaps an id to either oneChangesetDataSet.ChangesetDataSetEntryor an array ofChangesetDataSet.ChangesetDataSetEntry
-
Constructor Summary
Constructors Constructor Description ChangesetDataSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(PrimitiveId id)Replies true if the changeset content contains the object with primitiveid.private ChangesetDataSet.ChangesetDataSetEntrygetEntry(PrimitiveId id, int n)ChangesetDataSet.ChangesetDataSetEntrygetFirstEntry(PrimitiveId id)Replies the firstChangesetDataSet.ChangesetDataSetEntrywith ididfrom this dataset.java.util.Set<PrimitiveId>getIds()Returns an unmodifiable set of all primitives in this dataset.ChangesetDataSet.ChangesetDataSetEntrygetLastEntry(PrimitiveId id)Replies the lastChangesetDataSet.ChangesetDataSetEntrywith ididfrom this dataset.ChangesetDataSet.ChangesetModificationTypegetModificationType(PrimitiveId id)Replies the last modification type for the object with idid.HistoryOsmPrimitivegetPrimitive(PrimitiveId id)Replies theHistoryOsmPrimitivewith ididfrom this dataset.booleanisCreated(PrimitiveId id)Replies true if the primitive with ididwas created in this changeset.booleanisDeleted(PrimitiveId id)Replies true if the primitive with ididwas deleted in this changeset.booleanisUpdated(PrimitiveId id)Replies true if the primitive with ididwas updated in this changeset.java.util.Iterator<ChangesetDataSet.ChangesetDataSetEntry>iterator()Returns an iterator over dataset entries.voidput(HistoryOsmPrimitive primitive, ChangesetDataSet.ChangesetModificationType cmt)Remembers a history primitive with the given modification typeintsize()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.ChangesetDataSetEntryor 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 ididisn'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 ididwas 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
idwas created in this changeset.
-
isUpdated
public boolean isUpdated(PrimitiveId id)
Replies true if the primitive with ididwas 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
idwas updated in this changeset.
-
isDeleted
public boolean isDeleted(PrimitiveId id)
Replies true if the primitive with ididwas 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
idwas 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 theHistoryOsmPrimitivewith ididfrom 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
HistoryOsmPrimitivewith ididfrom 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.ChangesetDataSetEntrywith ididfrom this dataset. null, if there is no such primitive in the data set.- Parameters:
id- the id- Returns:
- the first
ChangesetDataSet.ChangesetDataSetEntrywith ididfrom this dataset or null. - Since:
- 14946
-
getLastEntry
public ChangesetDataSet.ChangesetDataSetEntry getLastEntry(PrimitiveId id)
Replies the lastChangesetDataSet.ChangesetDataSetEntrywith ididfrom this dataset. null, if there is no such primitive in the data set.- Parameters:
id- the id- Returns:
- the last
ChangesetDataSet.ChangesetDataSetEntrywith ididfrom 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.
-
-