Package org.esa.snap.core.dataio
Interface ProductWriter
- All Known Implementing Classes:
AbstractProductWriter,DimapProductWriter
public interface ProductWriter
An interface that supports writing a complete data product tree and single band rasters.
- Version:
- $Revision$ $Date$
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes all output streams currently open.voidComplete deletes the physical representation of the given product from the file system.voidflush()Writes all data in memory to the data sink(s) associated with this writer.Retrives the current output destination object.Returns the plug-in which created this product writer.booleanReturns whether this product writer writes only modified product nodes.voidremoveBand(Band band) Physically deletes aBandin a product writer's output.voidsetFormatName(String formatName) Sets selectable product format for writers which handle multiple formats.voidsetIncrementalMode(boolean enabled) Enables resp.booleanshouldWrite(ProductNode node) Returns whether the given product node is to be written.voidwriteBandRasterData(Band sourceBand, int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, ProductData sourceBuffer, ProgressMonitor pm) Writes raster data from the given in-memory source buffer into the data sink specified by the given source band and region.voidwriteProductNodes(Product product, Object output) Writes the in-memory representation of a data product.
-
Method Details
-
getWriterPlugIn
ProductWriterPlugIn getWriterPlugIn()Returns the plug-in which created this product writer.- Returns:
- the product writer plug-in, should never be
null
-
getOutput
Object getOutput()Retrives the current output destination object. Thie return value might benullif thesetOutputhas not been called so far.- Returns:
- the output
-
writeProductNodes
Writes the in-memory representation of a data product.Whether the band data - the actual pixel values - is written out immediately or later when pixels are flushed, is up to the implementation.
- Parameters:
product- the in-memory representation of the data productoutput- an object representing a valid output for this writer, might be aImageOutputStreamor otherObjectto use for future decoding.- Throws:
IllegalArgumentException- ifoutputisnullor it's type is not one of the supported output sources.IOException- if an I/O error occurs
-
writeBandRasterData
void writeBandRasterData(Band sourceBand, int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, ProductData sourceBuffer, ProgressMonitor pm) throws IOException Writes raster data from the given in-memory source buffer into the data sink specified by the given source band and region.Source band
The source band is used to identify the data sink in which this method transfers the sample values given in the source buffer. The method does not modify the pixel data of the given source band at all.Source buffer
The first element of the source buffer corresponds to the givensourceOffsetXandsourceOffsetYof the source region. These parameters are an offset within the band's raster data and not an offset within the source buffer.
The number of elements in the buffer must be exactly besourceWidth * sourceHeight. The pixel values to be writte are considered to be stored in line-by-line order, so the raster X co-ordinate varies faster than the Y.Source region
The given destination region specified by thesourceOffsetX,sourceOffsetY,sourceWidthandsourceHeightparameters is given in the source band's raster co-ordinates. These co-ordinates are identical with the destination raster co-ordinates since product writers do not support spectral or spatial subsets.- Parameters:
sourceBand- the source band which identifies the data sink to which to write the sample valuessourceOffsetX- the X-offset in the band's raster co-ordinatessourceOffsetY- the Y-offset in the band's raster co-ordinatessourceWidth- the width of region to be written given in the band's raster co-ordinatessourceHeight- the height of region to be written given in the band's raster co-ordinatessourceBuffer- the source buffer which provides the sample values to be writtenpm- a monitor to inform the user about progress- Throws:
IOException- if an I/O error occursIllegalArgumentException- if the number of elements source buffer not equalssourceWidth * sourceHeightor the source region is out of the band's raster- See Also:
-
flush
Writes all data in memory to the data sink(s) associated with this writer.- Throws:
IOException- if an I/O error occurs
-
close
Closes all output streams currently open. A concrete implementation should callflushbefore performing the actual close-operation.- Throws:
IOException- if an I/O error occurs
-
shouldWrite
Returns whether the given product node is to be written.- Parameters:
node- the product node- Returns:
trueif so
-
isIncrementalMode
boolean isIncrementalMode()Returns whether this product writer writes only modified product nodes.- Returns:
trueif so
-
setIncrementalMode
void setIncrementalMode(boolean enabled) Enables resp. disables incremental writing of this product writer. By default, a reader should enable progress listening.- Parameters:
enabled- enables or disables progress listening.
-
deleteOutput
Complete deletes the physical representation of the given product from the file system.- Throws:
IOException- if an I/O error occurs
-
removeBand
Physically deletes aBandin a product writer's output.- Parameters:
band- The band to delete.
-
setFormatName
Sets selectable product format for writers which handle multiple formats.- Parameters:
formatName- The name of the file format.
-