org.openstreetmap.osmosis.core.database
Class ReleasableStatementContainer

java.lang.Object
  extended by org.openstreetmap.osmosis.core.database.ReleasableStatementContainer
All Implemented Interfaces:
Releasable

public class ReleasableStatementContainer
extends java.lang.Object
implements Releasable

A container for database statement objects that must be freed. This implementation simplifies the management of many statements that must be released as a group.

Author:
Brett Henderson

Constructor Summary
ReleasableStatementContainer()
          Creates a new instance.
 
Method Summary
<T extends java.sql.Statement>
T
add(T statement)
          Adds a new object to be managed.
 void clear()
          Removes all objects.
 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

ReleasableStatementContainer

public ReleasableStatementContainer()
Creates a new instance.

Method Detail

add

public <T extends java.sql.Statement> T add(T statement)
Adds a new object to be managed. The object is returned to allow method chaining.

Type Parameters:
T - The type of statement being stored.
Parameters:
statement - The statement to be stored.
Returns:
The statement that was stored.

clear

public void clear()
Removes all objects. They will no longer be released.


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