org.openstreetmap.osmosis.core.store
Class IndexedObjectStoreReader<T>

java.lang.Object
  extended by org.openstreetmap.osmosis.core.store.IndexedObjectStoreReader<T>
Type Parameters:
T - The object type being stored.
All Implemented Interfaces:
Releasable

public class IndexedObjectStoreReader<T>
extends java.lang.Object
implements Releasable

Provides read-only access to an indexed object store. Each thread accessing the object store must create its own reader. The reader maintains all references to heavyweight resources such as file handles used to access the store eliminating the need for objects such as object iterators to be cleaned up explicitly.

Author:
Brett Henderson

Constructor Summary
IndexedObjectStoreReader(RandomAccessObjectStoreReader<T> objectStoreReader, IndexStoreReader<java.lang.Long,LongLongIndexElement> indexStoreReader)
          Creates a new instance.
 
Method Summary
 T get(long id)
          Returns the object identified by id.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexedObjectStoreReader

public IndexedObjectStoreReader(RandomAccessObjectStoreReader<T> objectStoreReader,
                                IndexStoreReader<java.lang.Long,LongLongIndexElement> indexStoreReader)
Creates a new instance.

Parameters:
objectStoreReader - Provides access to the object data.
indexStoreReader - Provides access to the index data.
Method Detail

get

public T get(long id)
Returns the object identified by id.

Parameters:
id - The identifier for the object to be retrieved.
Returns:
The requested object.

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