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

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.history.History

public class History
extends java.lang.Object

Represents the history of an OSM primitive. The history consists of a list of object snapshots with a specific version.


Nested Class Summary
private static interface History.FilterPredicate
           
 
Field Summary
private  long id
          the object id
private  OsmPrimitiveType type
           
private  java.util.ArrayList<HistoryOsmPrimitive> versions
          the list of object snapshots
 
Constructor Summary
protected History(long id, OsmPrimitiveType type, java.util.List<HistoryOsmPrimitive> versions)
          Creates a new history for an OSM primitive
 
Method Summary
 History between(java.util.Date fromDate, java.util.Date untilDate)
           
 History between(long fromVersion, long untilVersion)
           
 boolean contains(long version)
           
private static History filter(History history, History.FilterPredicate predicate)
           
 History forUserId(long uid)
           
 History from(java.util.Date fromDate)
           
 History from(long fromVersion)
           
 HistoryOsmPrimitive get(int idx)
           
 HistoryOsmPrimitive getByDate(java.util.Date date)
           
 HistoryOsmPrimitive getByVersion(long version)
          Replies the history primitive with version version.
 HistoryOsmPrimitive getEarliest()
           
 long getId()
           
 HistoryOsmPrimitive getLatest()
           
 int getNumVersions()
           
 PrimitiveId getPrimitiveId()
          Replies the primitive id for this history.
 OsmPrimitiveType getType()
           
 boolean isEmpty()
           
 History sortAscending()
           
 History sortDescending()
           
 java.lang.String toString()
           
 History until(java.util.Date untilDate)
           
 History until(long untilVersion)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

versions

private java.util.ArrayList<HistoryOsmPrimitive> versions
the list of object snapshots


id

private final long id
the object id


type

private final OsmPrimitiveType type
Constructor Detail

History

protected History(long id,
                  OsmPrimitiveType type,
                  java.util.List<HistoryOsmPrimitive> versions)
Creates a new history for an OSM primitive

Parameters:
id - the id. >0 required.
type - the primitive type. Must not be null.
versions - a list of versions. Can be null.
Throws:
java.lang.IllegalArgumentException - thrown if id <= 0
java.lang.IllegalArgumentException - if type is null
Method Detail

filter

private static History filter(History history,
                              History.FilterPredicate predicate)

sortAscending

public History sortAscending()

sortDescending

public History sortDescending()

from

public History from(java.util.Date fromDate)

until

public History until(java.util.Date untilDate)

between

public History between(java.util.Date fromDate,
                       java.util.Date untilDate)

from

public History from(long fromVersion)

until

public History until(long untilVersion)

between

public History between(long fromVersion,
                       long untilVersion)

forUserId

public History forUserId(long uid)

getId

public long getId()

getPrimitiveId

public PrimitiveId getPrimitiveId()
Replies the primitive id for this history.

Returns:
the primitive id

contains

public boolean contains(long version)

getByVersion

public HistoryOsmPrimitive getByVersion(long version)
Replies the history primitive with version version. null, if no such primitive exists.

Parameters:
version - the version
Returns:
the history primitive with version version

getByDate

public HistoryOsmPrimitive getByDate(java.util.Date date)

get

public HistoryOsmPrimitive get(int idx)

getEarliest

public HistoryOsmPrimitive getEarliest()

getLatest

public HistoryOsmPrimitive getLatest()

getNumVersions

public int getNumVersions()

isEmpty

public boolean isEmpty()

getType

public OsmPrimitiveType getType()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


JOSM