org.esa.beam.framework.dataio
Class AbstractProductWriter

java.lang.Object
  extended by org.esa.beam.framework.dataio.AbstractProductWriter
All Implemented Interfaces:
ProductWriter

public abstract class AbstractProductWriter
extends Object
implements ProductWriter

The AbstractProductWriter class can be used as a base class for new product writer implementations.

Version:
$Revision$ $Date$
Author:
Norman Fomferra, Sabine Embacher
See Also:
writeProductNodes(org.esa.beam.framework.datamodel.Product, java.lang.Object)

Constructor Summary
AbstractProductWriter(ProductWriterPlugIn writerPlugIn)
          Constructs a ProductWriter.
 
Method Summary
protected  void checkOutput()
          Utility method which ensures that an output is assigned to this writer.
 Object getOutput()
          Retrives the current output destination object.
protected  Product getSourceProduct()
          Returns the source product to be written or null if the writeProductNodes has not be called so far.
 ProductWriterPlugIn getWriterPlugIn()
          Returns the plug-in which created this product writer.
 boolean isIncrementalMode()
          Returns whether this product writer writes only modified product nodes.
protected  boolean isInstanceOfValidOutputType(Object output)
          Checks if the given object is an instance of one of the valid output types for this product writer.
 void removeBand(Band band)
          Overwrite this method to physicaly delete a Band from the writer's output file.
 void setIncrementalMode(boolean enabled)
          Enables resp.
 boolean shouldWrite(ProductNode node)
          Returns wether the given product node is to be written.
 void writeProductNodes(Product product, Object output)
          Writes the in-memory representation of a data product.
protected abstract  void writeProductNodesImpl()
          Writes 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, wait
 
Methods inherited from interface org.esa.beam.framework.dataio.ProductWriter
close, deleteOutput, flush, writeBandRasterData
 

Constructor Detail

AbstractProductWriter

public AbstractProductWriter(ProductWriterPlugIn writerPlugIn)
Constructs a ProductWriter. Since no output destination is set, the setOutput method must be called before data can be written.

Parameters:
writerPlugIn - the plug-in which created this writer, must not be null
Throws:
IllegalArgumentException
See Also:
writeProductNodes(org.esa.beam.framework.datamodel.Product, java.lang.Object)
Method Detail

getWriterPlugIn

public ProductWriterPlugIn getWriterPlugIn()
Returns the plug-in which created this product writer.

Specified by:
getWriterPlugIn in interface ProductWriter
Returns:
the product writer plug-in, should never be null

getSourceProduct

protected Product getSourceProduct()
Returns the source product to be written or null if the writeProductNodes has not be called so far.


getOutput

public Object getOutput()
Retrives the current output destination object. Thie return value might be null if the setOutput method has not been called so far.

Specified by:
getOutput in interface ProductWriter
Returns:
the output

writeProductNodes

public 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.

Specified by:
writeProductNodes in interface ProductWriter
Parameters:
product - the in-memory representation of the data product
output - an object representing a valid output for this writer, might be a ImageOutputStream or other Object to use for future decoding.
Throws:
IllegalArgumentException - if product is null.
IllegalArgumentException - if output is null or it's type is none of the supported output types.
IOException - if an I/O error occurs

writeProductNodesImpl

protected abstract void writeProductNodesImpl()
                                       throws IOException
Writes the in-memory representation of a data product. This method was called by writeProductNodes(product, output) of the AbstractProductWriter.

Throws:
IllegalArgumentException - if output type is not one of the supported output sources.
IOException - if an I/O error occurs

checkOutput

protected void checkOutput()
                    throws IllegalStateException
Utility method which ensures that an output is assigned to this writer.

Throws:
IllegalStateException - if no output was set (output is null).

isInstanceOfValidOutputType

protected boolean isInstanceOfValidOutputType(Object output)
Checks if the given object is an instance of one of the valid output types for this product writer.

Returns:
true if so
See Also:
ProductWriterPlugIn.getOutputTypes()

shouldWrite

public boolean shouldWrite(ProductNode node)
Returns wether the given product node is to be written.

Specified by:
shouldWrite in interface ProductWriter
Parameters:
node - the product node
Returns:
true if 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:
setIncrementalMode in interface ProductWriter
Parameters:
enabled - enables or disables progress listening.

isIncrementalMode

public boolean isIncrementalMode()
Returns whether this product writer writes only modified product nodes.

Specified by:
isIncrementalMode in interface ProductWriter
Returns:
true if so

removeBand

public void removeBand(Band band)
Overwrite this method to physicaly delete a Band from the writer's output file.

Specified by:
removeBand in interface ProductWriter
Parameters:
band - The band to delete.


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.