org.openstreetmap.osmosis.core.pgsql.v0_6.impl
Class EntityReader<T extends Entity>

java.lang.Object
  extended by org.openstreetmap.osmosis.core.pgsql.v0_6.impl.EntityReader<T>
Type Parameters:
T - The entity type to be supported.
All Implemented Interfaces:
java.util.Iterator<T>, Releasable, ReleasableIterator<T>
Direct Known Subclasses:
NodeReader, RelationReader, WayReader

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

Reads instances of an entity type from a database ordered by the identifier. It combines the output of the entity feature table readers to produce fully configured entity objects.

Author:
Brett Henderson

Constructor Summary
EntityReader(DatabaseContext dbCtx, EntityMapper<T> entityMapper)
          Creates a new instance.
EntityReader(DatabaseContext dbCtx, EntityMapper<T> entityMapper, java.lang.String constraintTable)
          Creates a new instance.
 
Method Summary
 boolean hasNext()
          
 T next()
          
protected  void populateEntityFeatures(T entity)
          Populates the entity with the its features.
 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

EntityReader

public EntityReader(DatabaseContext dbCtx,
                    EntityMapper<T> entityMapper)
Creates a new instance.

Parameters:
dbCtx - The database context to use for accessing the database.
entityMapper - The database mapper for the entity type.

EntityReader

public EntityReader(DatabaseContext dbCtx,
                    EntityMapper<T> entityMapper,
                    java.lang.String constraintTable)
Creates a new instance.

Parameters:
dbCtx - The database context to use for accessing the database.
entityMapper - The database mapper for the entity type.
constraintTable - The table containing a column named id defining the list of entities to be returned.
Method Detail

populateEntityFeatures

protected void populateEntityFeatures(T entity)
Populates the entity with the its features. These features will be read from related tables.

Parameters:
entity - The entity to be populated.

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