Class EarthDataWriter

java.lang.Object
noaa.coastwatch.io.EarthDataWriter
Direct Known Subclasses:
BinaryWriter, CFNC4Writer, CFNCWriter, GeoTIFFDataWriter, HDFWriter, TextWriter

public abstract class EarthDataWriter extends Object

The EarthDataWriter interface is for classes that obtain data from EarthDataInfo and DataVariable objects and format the information to some output destination. A writer has the following lifecycle:

Since:
3.1.0
Author:
Peter Hollemans
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected EarthDataInfo
    Earth data info object.
    protected boolean
    The canceled flag, true if the current flush is canceled.
    protected List<DataVariable>
    Earth data variables.
    protected int
    The current variable progress as a value in the range [0..100].
    protected String
    The name of the variable currently being written.
    protected int
    The number of variables written so far during the current flush operation.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    EarthDataWriter(String destination)
    Constructs a new earth data writer and initializes the variables to an empty list.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a data variable to the writer.
    void
    Cancels a flush operation in progress.
    abstract void
    Closes the writer and frees any resources.
    protected void
    Closes the resources associated with the data destination.
    abstract void
    Flushes all unwritten data to the destination.
    Gets the earth data destination.
    int
    Gets the current flush progress.
    int
    Gets the progress length.
    Gets the name of the current variable being written in a flush operation.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • info

      protected EarthDataInfo info
      Earth data info object.
    • variables

      protected List<DataVariable> variables
      Earth data variables.
    • writeVariables

      protected int writeVariables
      The number of variables written so far during the current flush operation.
    • writeProgress

      protected int writeProgress
      The current variable progress as a value in the range [0..100].
    • writeVariableName

      protected String writeVariableName
      The name of the variable currently being written.
    • isCanceled

      protected boolean isCanceled
      The canceled flag, true if the current flush is canceled.
  • Constructor Details

    • EarthDataWriter

      protected EarthDataWriter(String destination)
      Constructs a new earth data writer and initializes the variables to an empty list.
      Parameters:
      destination - the data destination.
  • Method Details

    • getProgressVariable

      public String getProgressVariable()
      Gets the name of the current variable being written in a flush operation.
      Returns:
      the variable name, or null if no variable is being written.
    • getProgressLength

      public int getProgressLength()
      Gets the progress length. This may be used in a progress monitor to measure the progress of a flush operation.
      Returns:
      the progress length.
    • getProgress

      public int getProgress()
      Gets the current flush progress. This may be used in a progress monitor to measure the progress of a flush operation.
      Returns:
      the progress so far in the current flush operation.
      See Also:
    • cancel

      public void cancel()
      Cancels a flush operation in progress. When a flush is canceled, the writer is no longer usable and subsequent calls to the flush() method will not work.
    • getDestination

      public String getDestination()
      Gets the earth data destination.
    • addVariable

      public void addVariable(DataVariable var)
      Adds a data variable to the writer. The variable is added to the list of variables to write, but no data is actually written until a flush is performed.
      Parameters:
      var - the data variable to add.
      See Also:
    • flush

      public abstract void flush() throws IOException
      Flushes all unwritten data to the destination.
      Throws:
      IOException - if the data destination had I/O errors.
    • close

      public abstract void close() throws IOException
      Closes the writer and frees any resources. The flush method is called prior to closing.
      Throws:
      IOException - if the data destination had I/O errors.
    • finalize

      protected void finalize() throws Throwable
      Closes the resources associated with the data destination.
      Overrides:
      finalize in class Object
      Throws:
      Throwable