Package noaa.coastwatch.io
Class EarthDataWriter
java.lang.Object
noaa.coastwatch.io.EarthDataWriter
- Direct Known Subclasses:
BinaryWriter
,CFNC4Writer
,CFNCWriter
,GeoTIFFDataWriter
,HDFWriter
,TextWriter
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:
- Constructs from some type of file or data stream, and an
EarthDataInfo
object. - Accepts a series of
DataVariable
objects to be added to the output contents viaaddVariable(noaa.coastwatch.util.DataVariable)
. - Flushes the contents to the destination in
flush()
. - Closes the destination when no longer needed in
close()
.
- Since:
- 3.1.0
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionprotected 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
ModifierConstructorDescriptionprotected
EarthDataWriter
(String destination) Constructs a new earth data writer and initializes the variables to an empty list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addVariable
(DataVariable var) Adds a data variable to the writer.void
cancel()
Cancels a flush operation in progress.abstract void
close()
Closes the writer and frees any resources.protected void
finalize()
Closes the resources associated with the data destination.abstract void
flush()
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.
-
Field Details
-
info
Earth data info object. -
variables
Earth data variables. -
writeVariables
protected int writeVariablesThe number of variables written so far during the current flush operation. -
writeProgress
protected int writeProgressThe current variable progress as a value in the range [0..100]. -
writeVariableName
The name of the variable currently being written. -
isCanceled
protected boolean isCanceledThe canceled flag, true if the current flush is canceled.
-
-
Constructor Details
-
EarthDataWriter
Constructs a new earth data writer and initializes the variables to an empty list.- Parameters:
destination
- the data destination.
-
-
Method Details
-
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 theflush()
method will not work. -
getDestination
Gets the earth data destination. -
addVariable
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
Flushes all unwritten data to the destination.- Throws:
IOException
- if the data destination had I/O errors.
-
close
Closes the writer and frees any resources. Theflush
method is called prior to closing.- Throws:
IOException
- if the data destination had I/O errors.
-
finalize
Closes the resources associated with the data destination.
-