Package org.apache.sis.util
Interface Disposable
-
public interface Disposable
A resource that can be disposed when waiting for the garbage collector would be overly conservative. Invoking thedispose()
method allows any resources held by this object to be released. The result of calling any other method subsequent to a call to this method is undefined.Data integrity shall not depend on
dispose()
method invocation. If some data may need to be flushed to a stream or committed to a database, then aclose()
method should be used instead.Relationship withSome classes may implement both theCloseable
Disposeable
andCloseable
interfaces. While very similar, those two interfaces serve slightly different purposes. TheCloseable
interface closes a stream or a connection, but some classes allow the object to be reused with a different stream. However once an object has been disposed, it can not be used anymore.Example:Another difference is thatImageReader
andImageWriter
allow to reuse the same instance many times for reading or writing different images in the same format. New streams can be created, given to theImageReader
orImageWriter
and closed many times as long asdispose()
has not been invoked.dispose()
does not throw any checked exception. That method may be invoked in a background thread performing cleanup tasks, which would not know what to do in case of failure. Error duringdispose()
execution should not result in any lost of data.- Since:
- 0.3
- See Also:
Graphics.dispose()
,ImageReader.dispose()
,ImageWriter.dispose()
Defined in the
sis-utility
module
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
dispose()
Allows any resources held by this object to be released.
-