org.geotoolkit.image.io
Class FileImageReader

Object
  extended by ImageReader
      extended by SpatialImageReader
          extended by StreamImageReader
              extended by 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:

Since:
2.4
Version:
3.20
Author:
Antoine Hnawia (IRD), Martin Desruisseaux (IRD, Geomatys)
Module:
coverage/geotk-coverageio (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class StreamImageReader
StreamImageReader.Spi
 
Field Summary
 
Fields inherited from class StreamImageReader
closeOnReset
 
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 FileImageReader(StreamImageReader.Spi provider)
          Constructs a new image reader.
 
Method Summary
protected  void close()
          Closes the stream as documented in the super-class, then deletes the temporary file (if any).
protected  File getInputFile()
          Returns the input as a file.
 String getURLEncoding()
          Returns the encoding used for URL inputs.
 boolean isRandomAccessEasy(int imageIndex)
          Returns true since image readers backed by File object usually supports random access efficiently.
protected  boolean isTemporaryFile()
          Returns true if the file given by getInputFile() is a temporary file.
 
Methods inherited from class StreamImageReader
finalize, getChannel, getInputStream, getStreamLength, setInput
 
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
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Localized
getLocale
 

Constructor Detail

FileImageReader

protected FileImageReader(StreamImageReader.Spi provider)
Constructs a new image reader.

Parameters:
provider - The ImageReaderSpi that is constructing this object, or null.
Method Detail

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.