org.geotoolkit.image.io
Class FileImageWriter

Object
  extended by ImageWriter
      extended by SpatialImageWriter
          extended by StreamImageWriter
              extended by FileImageWriter
All Implemented Interfaces:
ImageTranscoder, WarningProducer, Disposable, Localized

public abstract class FileImageWriter
extends StreamImageWriter

Base class for image writers that require File output destination. This class is used with image formats backed by some external API (typically C/C++ libraries) working only with files.

The output type can be any of the types documented in the provider javadoc. The File object can be obtained by a call to getOutputFile(), which handles the various output types as below:

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

Nested Class Summary
 
Nested classes/interfaces inherited from class StreamImageWriter
StreamImageWriter.Spi
 
Field Summary
 
Fields inherited from class StreamImageWriter
closeOnReset
 
Fields inherited from class ImageWriter
availableLocales, locale, originatingProvider, output, progressListeners, warningListeners, warningLocales
 
Fields inherited from interface WarningProducer
LOGGER
 
Constructor Summary
protected FileImageWriter(StreamImageWriter.Spi provider)
          Constructs a new image writer.
 
Method Summary
protected  void close()
          Flushes the image content to the output stream, closes the stream and deletes the temporary file (if any).
protected  File getOutputFile()
          Returns the output as a file.
 String getURLEncoding()
          Returns the encoding used for URL outputs.
protected  boolean isTemporaryFile()
          Returns true if the file given by getOutputFile() is a temporary file.
 
Methods inherited from class StreamImageWriter
finalize, getOutputStream, setOutput
 
Methods inherited from class SpatialImageWriter
canWriteRasters, computeSize, convertImageMetadata, convertStreamMetadata, createRectIter, dispose, getDefaultImageMetadata, getDefaultStreamMetadata, getDefaultWriteParam, getSampleModel, processImageComplete, processImageStarted, processThumbnailComplete, processThumbnailStarted, processWarningOccurred, processWarningOccurred, warningOccurred
 
Methods inherited from class ImageWriter
abort, abortRequested, addIIOWriteProgressListener, addIIOWriteWarningListener, canInsertEmpty, canInsertImage, canRemoveImage, canReplaceImageMetadata, canReplacePixels, canReplaceStreamMetadata, canWriteEmpty, canWriteSequence, clearAbortRequest, endInsertEmpty, endReplacePixels, endWriteEmpty, endWriteSequence, getAvailableLocales, getLocale, getNumThumbnailsSupported, getOriginatingProvider, getOutput, getPreferredThumbnailSizes, prepareInsertEmpty, prepareReplacePixels, prepareWriteEmpty, prepareWriteSequence, processImageProgress, processImageStarted, processThumbnailProgress, processThumbnailStarted, processWarningOccurred, processWarningOccurred, processWriteAborted, removeAllIIOWriteProgressListeners, removeAllIIOWriteWarningListeners, removeIIOWriteProgressListener, removeIIOWriteWarningListener, removeImage, replaceImageMetadata, replacePixels, replacePixels, replaceStreamMetadata, reset, setLocale, write, write, write, writeInsert, writeToSequence
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Localized
getLocale
 

Constructor Detail

FileImageWriter

protected FileImageWriter(StreamImageWriter.Spi provider)
Constructs a new image writer.

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

getURLEncoding

public String getURLEncoding()
Returns the encoding used for URL outputs. The default implementation returns "UTF-8" in all cases. Subclasses can override this method if getOutputFile() should convert URL to File objects using a different encoding.

Returns:
The encoding used for URL outputs.

getOutputFile

protected File getOutputFile()
                      throws IOException
Returns the output as a file. If the output is not a file, then a temporary file is returned. The content of the file will be send to the original output when closing this image writer.

Returns:
The output as a file.
Throws:
IOException - If the output can not be converted to a file, or a failure occurred while creating a temporary file.

isTemporaryFile

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

Returns:
true if the output file is a temporary one.

close

protected void close()
              throws IOException
Flushes the image content to the output stream, closes the stream and deletes the temporary file (if any). More specifically, this method performs the following steps:

  1. If the content was written to a temporary file, copy that content to the original output stream.
  2. Deletes the temporary file (if any).
  3. Closes the output stream as documented in the super-class

This method is invoked automatically by StreamImageWriter.setOutput(Object), ImageWriter.reset(), SpatialImageWriter.dispose() or StreamImageWriter.finalize() methods and doesn't need to be invoked explicitly. It has protected access only in order to allow overriding by subclasses.

Overrides:
close in class StreamImageWriter
Throws:
IOException - If an error occurred while disposing resources.
See Also:
StreamImageWriter.closeOnReset


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.