org.geotoolkit.image.io
Class FileImageReader
Object
ImageReader
SpatialImageReader
StreamImageReader
FileImageReader
- All Implemented Interfaces:
- Disposable, Localized, WarningProducer
- Direct Known Subclasses:
- NetcdfImageReader
public abstract class FileImageReader
- extends StreamImageReader
Base class for image readers that require File input source. This class is used with
image formats backed by some external API (typically C/C++ libraries) working only with files.
The input type can be any of the types documented in the
provider javadoc. The File
object can be obtained by a call to getInputFile(), which handles the various input
types as below:
File inputs are returned as-is.
String inputs are converted to File objects by a call to the
File.File(String) constructor.
URL and URI inputs are converted to File objects by a call to the
File.File(URI) constructor only if the protocol is "file". In the particular
case of URLs, the encoding is specified by getURLEncoding().
- For all other cases, the input content is copied to a temporary file and the corresponding
File object is returned. The temporary file is deleted by the close()
method.
- Since:
- 2.4
- Version:
- 3.20
- Author:
- Antoine Hnawia (IRD), Martin Desruisseaux (IRD, Geomatys)
- Module:
| Fields inherited from class ImageReader |
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales |
| Methods inherited from class SpatialImageReader |
checkBandIndex, checkImageIndex, collapseNoDataValues, createMetadata, dispose, getDefaultReadParam, getDestination, getDimension, getGridEnvelope, getImageMetadata, getImageType, getImageTypes, getNumBands, getNumImages, getRawDataType, getRawImageType, getStreamMetadata, hasColors, warningOccurred |
| Methods inherited from class ImageReader |
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDestination, getFormatName, getHeight, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setInput, setInput, setLocale |
FileImageReader
protected FileImageReader(StreamImageReader.Spi provider)
- Constructs a new image reader.
- Parameters:
provider - The ImageReaderSpi that is constructing this object, or null.
getURLEncoding
public String getURLEncoding()
- Returns the encoding used for URL inputs.
The default implementation returns
"UTF-8" in all cases. Subclasses
can override this method if getInputFile() should convert URL
to File objects using a different encoding.
- Returns:
- The encoding used for URL inputs.
getInputFile
protected File getInputFile()
throws FileNotFoundException,
IOException
- Returns the input as a file. If the input is not a file,
then its content is copied to a temporary file and the temporary file is returned.
- Returns:
- The input as a file.
- Throws:
FileNotFoundException - if the file is not found or can not be read.
IOException - if a copy was necessary but failed.
isTemporaryFile
protected boolean isTemporaryFile()
- Returns
true if the file given by getInputFile() is a temporary file.
- Returns:
true if the input file is a temporary one.
isRandomAccessEasy
public boolean isRandomAccessEasy(int imageIndex)
throws IOException
- Returns
true since image readers backed by File
object usually supports random access efficiently.
- Overrides:
isRandomAccessEasy in class ImageReader
- Throws:
IOException - If an error occurred while fetching the information.
close
protected void close()
throws IOException
- Closes the stream as documented in the super-class,
then deletes the temporary file (if any). This method is invoked automatically by
setInput(...), reset(),
dispose() or StreamImageReader.finalize() methods and doesn't need to be
invoked explicitly.
- Overrides:
close in class StreamImageReader
- Throws:
IOException - If an error occurred while disposing resources.- See Also:
StreamImageReader.closeOnReset
Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.