Class HistoryDataSet
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.history.HistoryDataSet
-
- All Implemented Interfaces:
LayerManager.LayerChangeListener
public class HistoryDataSet extends java.lang.Object implements LayerManager.LayerChangeListener
A data set holding histories of OSM primitives.- Since:
- 1670, 10386 (new LayerChangeListener interface)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Long,Changeset>
changesets
private java.util.Map<PrimitiveId,java.util.ArrayList<HistoryOsmPrimitive>>
data
the history dataprivate static HistoryDataSet
historyDataSet
the unique instanceprivate java.util.concurrent.CopyOnWriteArrayList<HistoryDataSetListener>
listeners
-
Constructor Summary
Constructors Constructor Description HistoryDataSet()
Constructs a newHistoryDataSet
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHistoryDataSetListener(HistoryDataSetListener listener)
Adds a listener that listens to history data set events.void
clear()
Clear the history data.protected void
fireCacheCleared()
protected void
fireHistoryUpdated(PrimitiveId id)
HistoryOsmPrimitive
get(long id, OsmPrimitiveType type, long version)
Replies the history primitive for the primitive with idid
and versionversion
.java.util.Collection<java.lang.Long>
getChangesetIds()
Gets a unsorted set of all changeset ids that were used by the primitives in this data setHistory
getHistory(long id, OsmPrimitiveType type)
Replies the history for a given primitive with idid
and typetype
.History
getHistory(PrimitiveId pid)
Replies the history for a primitive with idid
.static HistoryDataSet
getInstance()
Replies the unique instance of the history data setvoid
layerAdded(LayerManager.LayerAddEvent e)
Notifies this listener that a layer has been added.void
layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Notifies this listener that the order of layers was changed.void
layerRemoving(LayerManager.LayerRemoveEvent e)
Notifies this listener that a layer was just removed.void
mergeInto(HistoryDataSet other)
merges the histories from theHistoryDataSet
other in this history data setvoid
put(HistoryOsmPrimitive primitive)
Adds a history primitive to the data setvoid
putChangeset(Changeset changeset)
Adds a changeset to the data setvoid
removeHistoryDataSetListener(HistoryDataSetListener listener)
Removes a listener that listens to history data set events.
-
-
-
Field Detail
-
historyDataSet
private static HistoryDataSet historyDataSet
the unique instance
-
data
private final java.util.Map<PrimitiveId,java.util.ArrayList<HistoryOsmPrimitive>> data
the history data
-
listeners
private final java.util.concurrent.CopyOnWriteArrayList<HistoryDataSetListener> listeners
-
changesets
private final java.util.Map<java.lang.Long,Changeset> changesets
-
-
Constructor Detail
-
HistoryDataSet
public HistoryDataSet()
Constructs a newHistoryDataSet
.
-
-
Method Detail
-
getInstance
public static HistoryDataSet getInstance()
Replies the unique instance of the history data set- Returns:
- the unique instance of the history data set
-
addHistoryDataSetListener
public void addHistoryDataSetListener(HistoryDataSetListener listener)
Adds a listener that listens to history data set events.- Parameters:
listener
- The listener
-
removeHistoryDataSetListener
public void removeHistoryDataSetListener(HistoryDataSetListener listener)
Removes a listener that listens to history data set events.- Parameters:
listener
- The listener
-
fireHistoryUpdated
protected void fireHistoryUpdated(PrimitiveId id)
-
fireCacheCleared
protected void fireCacheCleared()
-
get
public HistoryOsmPrimitive get(long id, OsmPrimitiveType type, long version)
Replies the history primitive for the primitive with idid
and versionversion
. null, if no such primitive exists.- Parameters:
id
- the id of the primitive. > 0 required.type
- the primitive type. Must not be null.version
- the version of the primitive. > 0 required- Returns:
- the history primitive for the primitive with id
id
, typetype
, and versionversion
-
put
public void put(HistoryOsmPrimitive primitive)
Adds a history primitive to the data set- Parameters:
primitive
- the history primitive to add
-
putChangeset
public void putChangeset(Changeset changeset)
Adds a changeset to the data set- Parameters:
changeset
- the changeset to add
-
getHistory
public History getHistory(long id, OsmPrimitiveType type)
Replies the history for a given primitive with idid
and typetype
.- Parameters:
id
- the id the if of the primitive. > 0 requiredtype
- the type of the primitive. Must not be null.- Returns:
- the history. null, if there isn't a history for
id
andtype
. - Throws:
java.lang.IllegalArgumentException
- if id <= 0java.lang.IllegalArgumentException
- if type is null
-
getHistory
public History getHistory(PrimitiveId pid)
Replies the history for a primitive with idid
. null, if no such history exists.- Parameters:
pid
- the primitive id. Must not be null.- Returns:
- the history for a primitive with id
id
. null, if no such history exists - Throws:
java.lang.NullPointerException
- if pid is null
-
mergeInto
public void mergeInto(HistoryDataSet other)
merges the histories from theHistoryDataSet
other in this history data set- Parameters:
other
- the other history data set. Ignored if null.
-
getChangesetIds
public java.util.Collection<java.lang.Long> getChangesetIds()
Gets a unsorted set of all changeset ids that were used by the primitives in this data set- Returns:
- The ids
-
layerOrderChanged
public void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that the order of layers was changed.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerOrderChanged
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The order change event.
-
layerAdded
public void layerAdded(LayerManager.LayerAddEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that a layer has been added.Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
- Specified by:
layerAdded
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The new added layer event
-
layerRemoving
public void layerRemoving(LayerManager.LayerRemoveEvent e)
Description copied from interface:LayerManager.LayerChangeListener
Notifies this listener that a layer was just removed.Listeners are called in the EDT thread after the layer was removed. Use
LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)
to remove more layers. You should not do blocking or long-running tasks in this method.- Specified by:
layerRemoving
in interfaceLayerManager.LayerChangeListener
- Parameters:
e
- The layer to be removed (as event)
-
clear
public void clear()
Clear the history data.- Since:
- 17471
-
-