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

java.lang.Object
  extended by org.openstreetmap.osmosis.core.pgsql.common.BaseDao
      extended by org.openstreetmap.osmosis.core.pgsql.v0_6.impl.EntityDao<T>
Type Parameters:
T - The entity type to be supported.
All Implemented Interfaces:
Releasable
Direct Known Subclasses:
NodeDao, RelationDao, WayDao

public abstract class EntityDao<T extends Entity>
extends BaseDao

Provides functionality common to all top level entity daos.

Author:
Brett Henderson

Constructor Summary
protected EntityDao(DatabaseContext dbCtx, EntityMapper<T> entityMapper, ActionDao actionDao)
          Creates a new instance.
 
Method Summary
 void addEntity(T entity)
          Adds the specified entity to the database.
 boolean exists(long entityId)
          Checks if the specified entity exists in the database.
 T getEntity(long entityId)
          Loads the specified entity from the database.
abstract  ReleasableIterator<T> iterate()
          Returns an iterator providing access to all entities in the database.
protected abstract  void loadFeatures(long entityId, T entity)
          Adds the type specific features to the entity.
 void modifyEntity(T entity)
          Updates the specified entity details in the database.
 void removeEntity(long entityId)
          Removes the specified entity from the database.
 
Methods inherited from class org.openstreetmap.osmosis.core.pgsql.common.BaseDao
getDatabaseContext, prepareStatement, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityDao

protected EntityDao(DatabaseContext dbCtx,
                    EntityMapper<T> entityMapper,
                    ActionDao actionDao)
Creates a new instance.

Parameters:
dbCtx - The database context to use for accessing the database.
entityMapper - Provides entity type specific JDBC support.
actionDao - The dao to use for adding action records to the database.
Method Detail

exists

public boolean exists(long entityId)
Checks if the specified entity exists in the database.

Parameters:
entityId - The unique identifier of the entity.
Returns:
True if the entity exists in the database.

getEntity

public T getEntity(long entityId)
Loads the specified entity from the database.

Parameters:
entityId - The unique identifier of the entity.
Returns:
The loaded entity.

loadFeatures

protected abstract void loadFeatures(long entityId,
                                     T entity)
Adds the type specific features to the entity.

Parameters:
entityId - The entity id.
entity - The entity requiring features to be added.

addEntity

public void addEntity(T entity)
Adds the specified entity to the database.

Parameters:
entity - The entity to add.

modifyEntity

public void modifyEntity(T entity)
Updates the specified entity details in the database.

Parameters:
entity - The entity to update.

removeEntity

public void removeEntity(long entityId)
Removes the specified entity from the database.

Parameters:
entityId - The id of the entity to remove.

iterate

public abstract ReleasableIterator<T> iterate()
Returns an iterator providing access to all entities in the database.

Returns:
The entity iterator.