Package org.esa.snap.core.dataio
Class AbstractProductWriter
java.lang.Object
org.esa.snap.core.dataio.AbstractProductWriter
- All Implemented Interfaces:
ProductWriter
- Direct Known Subclasses:
DimapProductWriter
The
AbstractProductWriter class can be used as a base class for new product writer implementations.- Version:
- $Revision$ $Date$
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractProductWriter(ProductWriterPlugIn writerPlugIn) Constructs aProductWriter. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidUtility method which ensures that an output is assigned to this writer.Retrives the current output destination object.protected ProductReturns the source product to be written ornullif thewriteProductNodeshas not be called so far.Returns the plug-in which created this product writer.booleanReturns whether this product writer writes only modified product nodes.protected booleanisInstanceOfValidOutputType(Object output) Checks if the given object is an instance of one of the valid output types for this product writer.voidremoveBand(Band band) Overwrite this method to physicaly delete aBandfrom the writer's output file.voidsetFormatName(String formatName) Sets selectable product format for writers which handle multiple formats.voidsetIncrementalMode(boolean enabled) Enables resp.booleanshouldWrite(ProductNode node) Returns wether the given product node is to be written.voidwriteProductNodes(Product product, Object output) Writes the in-memory representation of a data product.protected abstract voidWrites the in-memory representation of a data product.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.esa.snap.core.dataio.ProductWriter
close, deleteOutput, flush, writeBandRasterData
-
Constructor Details
-
AbstractProductWriter
Constructs aProductWriter. Since no output destination is set, thesetOutputmethod must be called before data can be written.- Parameters:
writerPlugIn- the plug-in which created this writer, must not benull- Throws:
IllegalArgumentException- See Also:
-
-
Method Details
-
getWriterPlugIn
Returns the plug-in which created this product writer.- Specified by:
getWriterPlugInin interfaceProductWriter- Returns:
- the product writer plug-in, should never be
null
-
getSourceProduct
Returns the source product to be written ornullif thewriteProductNodeshas not be called so far. -
getOutput
Retrives the current output destination object. Thie return value might benullif thesetOutputmethod has not been called so far.- Specified by:
getOutputin interfaceProductWriter- 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.
- Specified by:
writeProductNodesin interfaceProductWriter- 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- ifproductisnull.IllegalArgumentException- ifoutputisnullor it's type is none of the supported output types.IOException- if an I/O error occurs
-
writeProductNodesImpl
Writes the in-memory representation of a data product. This method was called bywriteProductNodes(product, output)of the AbstractProductWriter.- Throws:
IllegalArgumentException- ifoutputtype is not one of the supported output sources.IOException- if an I/O error occurs
-
checkOutput
Utility method which ensures that an output is assigned to this writer.- Throws:
IllegalStateException- if no output was set (output isnull).
-
isInstanceOfValidOutputType
Checks if the given object is an instance of one of the valid output types for this product writer.- Returns:
trueif so- See Also:
-
shouldWrite
Returns wether the given product node is to be written.- Specified by:
shouldWritein interfaceProductWriter- Parameters:
node- the product node- Returns:
trueif so
-
setIncrementalMode
public void setIncrementalMode(boolean enabled) Enables resp. disables incremental writing of this product writer. By default, a reader should enable progress listening.- Specified by:
setIncrementalModein interfaceProductWriter- Parameters:
enabled- enables or disables progress listening.
-
isIncrementalMode
public boolean isIncrementalMode()Returns whether this product writer writes only modified product nodes.- Specified by:
isIncrementalModein interfaceProductWriter- Returns:
trueif so
-
removeBand
Overwrite this method to physicaly delete aBandfrom the writer's output file.- Specified by:
removeBandin interfaceProductWriter- Parameters:
band- The band to delete.
-
setFormatName
Sets selectable product format for writers which handle multiple formats.- Specified by:
setFormatNamein interfaceProductWriter- Parameters:
formatName- The name of the file format.
-