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:
ProductReader
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes all output streams currently open.void
deleteOutput()
Complete deletes the physical representation of the given product from the file system.void
flush()
Writes all data in memory to the data sink(s) associated with this writer.Object
getOutput()
Retrives the current output destination object.ProductWriterPlugIn
getWriterPlugIn()
Returns the plug-in which created this product writer.boolean
isIncrementalMode()
Returns whether this product writer writes only modified product nodes.void
removeBand(Band band)
Physically deletes aBand
in a product writer's output.void
setFormatName(String formatName)
Sets selectable product format for writers which handle multiple formats.void
setIncrementalMode(boolean enabled)
Enables resp.boolean
shouldWrite(ProductNode node)
Returns whether the given product node is to be written.void
writeBandRasterData(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.void
writeProductNodes(Product product, Object output)
Writes the in-memory representation of a data product.
-
-
-
Method Detail
-
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 benull
if thesetOutput
has not been called so far.- Returns:
- the output
-
writeProductNodes
void writeProductNodes(Product product, Object output) throws IOException
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 aImageOutputStream
or otherObject
to use for future decoding.- Throws:
IllegalArgumentException
- ifoutput
isnull
or 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 givensourceOffsetX
andsourceOffsetY
of 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
,sourceWidth
andsourceHeight
parameters 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 * sourceHeight
or the source region is out of the band's raster- See Also:
AbstractBand.getRasterWidth()
,AbstractBand.getRasterHeight()
-
flush
void flush() throws IOException
Writes all data in memory to the data sink(s) associated with this writer.- Throws:
IOException
- if an I/O error occurs
-
close
void close() throws IOException
Closes all output streams currently open. A concrete implementation should callflush
before performing the actual close-operation.- Throws:
IOException
- if an I/O error occurs
-
shouldWrite
boolean shouldWrite(ProductNode node)
Returns whether the given product node is to be written.- Parameters:
node
- the product node- Returns:
true
if so
-
isIncrementalMode
boolean isIncrementalMode()
Returns whether this product writer writes only modified product nodes.- Returns:
true
if 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
void deleteOutput() throws IOException
Complete deletes the physical representation of the given product from the file system.- Throws:
IOException
- if an I/O error occurs
-
removeBand
void removeBand(Band band)
Physically deletes aBand
in a product writer's output.- Parameters:
band
- The band to delete.
-
setFormatName
void setFormatName(String formatName)
Sets selectable product format for writers which handle multiple formats.- Parameters:
formatName
- The name of the file format.
-
-