org.geotools.image.io
Class FileImageReader

java.lang.Object
  extended by javax.imageio.ImageReader
      extended by org.geotools.image.io.GeographicImageReader
          extended by org.geotools.image.io.StreamImageReader
              extended by org.geotools.image.io.FileImageReader
Direct Known Subclasses:
NetcdfImageReader

public abstract class FileImageReader
extends StreamImageReader

Base class for image readers that require File input source. If the input source is of other kind, then the content will be copied to a temporary file. This class is used for image formats backed by some external API (typically C/C++ libraries) working only with files.

Since:
2.4
Version:
$Id: FileImageReader.java 30679 2008-06-13 10:19:41Z acuster $
Author:
Antoine Hnawia, Martin Desruisseaux (IRD)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.geotools.image.io.StreamImageReader
StreamImageReader.Spi
 
Field Summary
 
Fields inherited from class org.geotools.image.io.StreamImageReader
closeOnReset
 
Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Constructor Summary
FileImageReader(javax.imageio.spi.ImageReaderSpi spi)
          Constructs a new image reader.
 
Method Summary
protected  void close()
          Deletes the temporary file, if any.
protected  java.io.File getInputFile()
          Returns the input as a file.
 java.lang.String getURLEncoding()
          Returns the encoding used for URL input.
 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 org.geotools.image.io.StreamImageReader
dispose, finalize, getInputStream, getStreamLength, reset, setInput
 
Methods inherited from class org.geotools.image.io.GeographicImageReader
checkBandIndex, checkImageIndex, collapseNoDataValues, flipVertically, getDefaultReadParam, getDestination, getDimension, getGeographicMetadata, getImageMetadata, getImageTypes, getNumBands, getNumImages, getRawDataType, getRawImageType, getRawImageType, getStreamMetadata, read, warningOccurred
 
Methods inherited from class javax.imageio.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, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileImageReader

public FileImageReader(javax.imageio.spi.ImageReaderSpi spi)
Constructs a new image reader.

Parameters:
provider - The ImageReaderSpi that is invoking this constructor, or null if none.
Method Detail

getURLEncoding

public java.lang.String getURLEncoding()
Returns the encoding used for URL input. The default implementation returns "UTF-8" in all cases. Subclasses should override this method if getInputFile() should converts URL to File objects using a different encoding.


getInputFile

protected java.io.File getInputFile()
                             throws java.io.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:
java.io.FileNotFoundException - if the file is not found or can not be read.
java.io.IOException - if a copy was necessary but failed.

isTemporaryFile

protected boolean isTemporaryFile()
Returns true if the file given by getInputFile() is a temporary file.


isRandomAccessEasy

public boolean isRandomAccessEasy(int imageIndex)
                           throws java.io.IOException
Returns true since image readers backed by File object usually supports random access efficiently.

Overrides:
isRandomAccessEasy in class javax.imageio.ImageReader
Throws:
java.io.IOException

close

protected void close()
              throws java.io.IOException
Deletes the temporary file, if any.

Overrides:
close in class StreamImageReader
Throws:
java.io.IOException - if an error occured while closing the stream.
See Also:
StreamImageReader.closeOnReset


Copyright © 1996-2010 Geotools. All Rights Reserved.