org.openstreetmap.osmosis.core.mysql.v0_5.impl
Class EntitySnapshotReader<T extends Entity>

java.lang.Object
  extended by org.openstreetmap.osmosis.core.mysql.v0_5.impl.EntitySnapshotReader<T>
Type Parameters:
T - The data type to be read.
All Implemented Interfaces:
java.util.Iterator<T>, Releasable, ReleasableIterator<T>

public class EntitySnapshotReader<T extends Entity>
extends java.lang.Object
implements ReleasableIterator<T>

Reads a complete snapshot of an entity type based on the complete history of an entity type.

Author:
Brett Henderson

Constructor Summary
EntitySnapshotReader(PeekableIterator<EntityHistory<T>> entityIterator, java.util.Date snapshotInstant, java.util.Comparator<EntityHistory<T>> resultOrdering)
          Creates a new instance.
 
Method Summary
 boolean hasNext()
          
 T next()
          
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 void remove()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntitySnapshotReader

public EntitySnapshotReader(PeekableIterator<EntityHistory<T>> entityIterator,
                            java.util.Date snapshotInstant,
                            java.util.Comparator<EntityHistory<T>> resultOrdering)
Creates a new instance.

Parameters:
entityIterator - An iterator containing the full history for an entity type ordered by identifier.
snapshotInstant - The state of the entity at this point in time will be dumped. This ensures a consistent snapshot.
resultOrdering - This provides a way of sorting the history records for a single entity, it may be null if no sorting is required.
Method Detail

hasNext

public boolean hasNext()

Specified by:
hasNext in interface java.util.Iterator<T extends Entity>

next

public T next()

Specified by:
next in interface java.util.Iterator<T extends Entity>

remove

public void remove()

Specified by:
remove in interface java.util.Iterator<T extends Entity>

release

public void release()
Performs resource cleanup tasks such as closing files, or database connections. This must be called after all processing is complete and may be called multiple times. Implementations must call release on any nested Releasable objects. It should be called within a finally block to ensure it is called in exception scenarios.

Specified by:
release in interface Releasable