|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectImageReader
SpatialImageReader
StreamImageReader
public abstract class StreamImageReader
Base class for image readers that expect an InputStream or channel input source. This
class provides a getInputStream() method, which return the input
as an InputStream for convenience.
Different kinds of outputs are automatically handled. The default implementation handles all the following types:
Note theString,File,URI,URL,URLConnection,InputStream,ImageInputStream,ReadableByteChannel.
TextImageReader subclass can go one step further by wrapping the
InputStream into a BufferedReader using some character encoding.
StreamImageWriter
| coverage/geotk-coverageio (download) | View source code for this class |
| Nested Class Summary | |
|---|---|
protected static class |
StreamImageReader.Spi
Service provider interface (SPI) for StreamImageReaders. |
| Field Summary | |
|---|---|
protected Closeable |
closeOnReset
The stream to close on setInput(...), ImageReader.reset() or SpatialImageReader.dispose() method invocation. |
| Fields inherited from class ImageReader |
|---|
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
| Fields inherited from interface WarningProducer |
|---|
LOGGER |
| Constructor Summary | |
|---|---|
protected |
StreamImageReader(StreamImageReader.Spi provider)
Constructs a new image reader. |
| Method Summary | |
|---|---|
protected void |
close()
Closes the input stream created by getInputStream(). |
protected void |
finalize()
Invokes the close() method when this reader is garbage-collected. |
protected ReadableByteChannel |
getChannel()
Returns the input as an readable byte channel. |
protected InputStream |
getInputStream()
Returns the input as an input stream object. |
protected long |
getStreamLength()
Returns the stream length in bytes, or -1 if unknown. |
void |
setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
Sets the input source to use. |
| Methods inherited from class Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface Localized |
|---|
getLocale |
| Field Detail |
|---|
protected Closeable closeOnReset
setInput(...), ImageReader.reset() or SpatialImageReader.dispose() method invocation. This stream
is typically an input stream or a reader
created by getInputStream() or similar methods in subclasses.
This field is never equal to the user-specified input, since the
usual ImageReader contract is to not close the
user-provided stream. It is set to a non-null value only if a stream has been created
from an other user object like File or URL.
getInputStream(),
TextImageReader.getReader(),
close()| Constructor Detail |
|---|
protected StreamImageReader(StreamImageReader.Spi provider)
provider - The ImageReaderSpi that is invoking this constructor,
or null if none.| Method Detail |
|---|
public void setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
String, File,
URI, URL, URLConnection, InputStream, ImageInputStream
or ReadableByteChannel.
If the given input is null, then any currently set input source will be
removed.
setInput in class SpatialImageReaderinput - The input object to use for future decoding.seekForwardOnly - If true, images and metadata may only be read
in ascending order from this input source.ignoreMetadata - If true, metadata may be ignored during reads.ImageReader.getInput(),
getInputStream()
protected long getStreamLength()
throws IOException
-1 if unknown. This method checks the
input type and invokes one of File.length(),
ImageInputStream.length() or URLConnection.getContentLength()
method accordingly.
IOException - if an I/O error occurred.
protected InputStream getInputStream()
throws IllegalStateException,
IOException
File, URI,
URL, URLConnection, ImageInputStream or ReadableByteChannel
inputs.
This method creates a new input stream only when first invoked.
All subsequent calls will return the same instance. Consequently, the returned stream
should never be closed by the caller. It will be closed automatically
(if the stream was not given directly by the user) when setInput(...),
reset() or dispose() methods are invoked.
ImageReader.getInput() as an InputStream. This input stream is usually
not buffered.
IllegalStateException - if the input is not set.
IOException - If the input stream can't be created for an other reason.ImageReader.getInput(),
getChannel(),
TextImageReader.getReader()
protected ReadableByteChannel getChannel()
throws IllegalStateException,
IOException
getInputStream().
This method creates a new channel only when first invoked. All subsequent calls will return
the same instance. Consequently, the returned channel should never be closed by the caller.
It will be closed automatically (if the channel was not given directly
by the user) when setInput(...), reset() or
dispose() methods are invoked.
ImageReader.getInput() as a ReadableByteChannel.
IllegalStateException - if the input is not set.
IOException - If the input stream can't be created for an other reason.ImageReader.getInput(),
getInputStream()
protected void close()
throws IOException
getInputStream(). This method does nothing
if the input stream is the input instance given by the user rather
than a stream created by this class from a File or URL input.
This method is invoked automatically by setInput(...), reset(), dispose() or
finalize() methods and doesn't need to be invoked explicitly.
It has protected access only in order to allow overriding by subclasses.
Overriding methods shall make sure that super.close() is invoked
even if their own code fail.
close in class SpatialImageReaderIOException - if an error occurred while closing the stream.closeOnReset
protected void finalize()
throws Throwable
close() method when this reader is garbage-collected.
Note that this will actually close the stream only if it has been created
by this reader, rather than supplied by the user.
finalize in class ObjectThrowable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||