org.openstreetmap.josm.data.osm.history
Class HistoryDataSet

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.history.HistoryDataSet
All Implemented Interfaces:
MapView.LayerChangeListener

public class HistoryDataSet
extends java.lang.Object
implements MapView.LayerChangeListener

A data set holding histories of OSM primitives.


Field Summary
private  java.util.HashMap<PrimitiveId,java.util.ArrayList<HistoryOsmPrimitive>> data
          the history data
private static HistoryDataSet historyDataSet
          the unique instance
private  java.util.concurrent.CopyOnWriteArrayList<HistoryDataSetListener> listeners
           
 
Constructor Summary
HistoryDataSet()
           
 
Method Summary
 void activeLayerChange(Layer oldLayer, Layer newLayer)
          Notifies this listener that the active layer has changed.
 void addHistoryDataSetListener(HistoryDataSetListener listener)
           
protected  void fireCacheCleared()
           
protected  void fireHistoryUpdated(PrimitiveId id)
           
 HistoryOsmPrimitive get(long id, OsmPrimitiveType type, long version)
          Replies the history primitive for the primitive with id id and version version.
 History getHistory(long id, OsmPrimitiveType type)
          Replies the history for a given primitive with id id and type type.
 History getHistory(PrimitiveId pid)
          Replies the history for a primitive with id id.
static HistoryDataSet getInstance()
          Replies the unique instance of the history data set
 void layerAdded(Layer newLayer)
          Notifies this listener that a layer has been added.
 void layerRemoved(Layer oldLayer)
          Notifies this listener that a layer has been removed.
 void mergeInto(HistoryDataSet other)
          merges the histories from the HistoryDataSet other in this history data set
 void put(HistoryOsmPrimitive primitive)
          Adds a history primitive to the data set
 void removeHistoryDataSetListener(HistoryDataSetListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

historyDataSet

private static HistoryDataSet historyDataSet
the unique instance


data

private java.util.HashMap<PrimitiveId,java.util.ArrayList<HistoryOsmPrimitive>> data
the history data


listeners

private java.util.concurrent.CopyOnWriteArrayList<HistoryDataSetListener> listeners
Constructor Detail

HistoryDataSet

public HistoryDataSet()
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)

removeHistoryDataSetListener

public void removeHistoryDataSetListener(HistoryDataSetListener 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 id id and version version. 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, type type, and version version

put

public void put(HistoryOsmPrimitive primitive)
Adds a history primitive to the data set

Parameters:
primitive - the history primitive to add

getHistory

public History getHistory(long id,
                          OsmPrimitiveType type)
                   throws java.lang.IllegalArgumentException
Replies the history for a given primitive with id id and type type.

Parameters:
id - the id the if of the primitive. > 0 required
type - the type of the primitive. Must not be null.
Returns:
the history. null, if there isn't a history for id and type.
Throws:
java.lang.IllegalArgumentException - thrown if id <= 0
java.lang.IllegalArgumentException - thrown if type is null

getHistory

public History getHistory(PrimitiveId pid)
                   throws java.lang.IllegalArgumentException
Replies the history for a primitive with id id. 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.IllegalArgumentException - thrown if pid is null

mergeInto

public void mergeInto(HistoryDataSet other)
merges the histories from the HistoryDataSet other in this history data set

Parameters:
other - the other history data set. Ignored if null.

activeLayerChange

public void activeLayerChange(Layer oldLayer,
                              Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that the active layer has changed.

Specified by:
activeLayerChange in interface MapView.LayerChangeListener
Parameters:
oldLayer - The previous active layer
newLayer - The new activer layer

layerAdded

public void layerAdded(Layer newLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been added.

Specified by:
layerAdded in interface MapView.LayerChangeListener
Parameters:
newLayer - The new added layer

layerRemoved

public void layerRemoved(Layer oldLayer)
Description copied from interface: MapView.LayerChangeListener
Notifies this listener that a layer has been removed.

Specified by:
layerRemoved in interface MapView.LayerChangeListener
Parameters:
oldLayer - The old removed layer


JOSM