org.geotoolkit.image.io
Class FileImageWriter
Object
ImageWriter
SpatialImageWriter
StreamImageWriter
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:
File outputs are returned as-is.
String outputs 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, a temporary file is returned. When the
close() method is
invoked, the content of the temporary file is copied to the output stream and the file
is deleted.
- Since:
- 3.20
- Version:
- 3.20
- Author:
- Johann Sorel (Geomatys), Martin Desruisseaux (Geomatys)
- Module:
| 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 |
FileImageWriter
protected FileImageWriter(StreamImageWriter.Spi provider)
- Constructs a new image writer.
- Parameters:
provider - The ImageWriterSpi that is constructing this object, or null.
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:
- If the content was written to a temporary file, copy that content to the original
output stream.
- Deletes the temporary file (if any).
- 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.