Class TileDeliveryOperation

java.lang.Object
java.util.Observable
noaa.coastwatch.io.tile.TileDeliveryOperation

public class TileDeliveryOperation extends Observable
A TileDeliveryOperation represents an asynchronous process for delivering tiles of data from a TileSource to a number of Observer objects. Each observer receives a TilingScheme.Tile object after each tile has been read from the source. If an exception is encountered while delivering tiles, the observer object will be null, and the getLastReadException() method will return the latest exception received.
Since:
3.3.1
Author:
Peter Hollemans
  • Constructor Details

    • TileDeliveryOperation

      public TileDeliveryOperation(TileSource source, Iterable<TilingScheme.TilePosition> positions)
      Creates a new delivery operation that reads tiles from a source. The operation is created but not started.
      Parameters:
      source - the source to read tile data from.
      positions - the positions to read.
      See Also:
  • Method Details

    • getSource

      public TileSource getSource()
      Gets the source for this delivery operation.
      Returns:
      the tile source.
    • getLastReadException

      public IOException getLastReadException()
      Gets the last exception received from reading tiles from the source.
      Returns:
      the last exception, or null if no exception has occurred.
    • start

      public void start()
      Starts the operation. Tiles will begin to be read in a parallel thread, and observers notified when tiles are ready. This method returns immediately, and may only be called once.
      See Also:
    • waitUntilFinished

      public void waitUntilFinished() throws InterruptedException
      Waits for the operation to finish. This method should only be called to synchronize the operation, and will exit when the delivery operation is complete. If no operation is in progress, the method exits immediately.
      Throws:
      InterruptedException - if the current thread is interrupted waiting for the operation to finish.
    • cancel

      public void cancel()
      Cancels this operation. This method may only be called if the start() method has been called.
    • isFinished

      public boolean isFinished()
      Checks if this operation is finished.
      Returns:
      the finished flag, true if finished (either because the operation was cancelled, or ran out of tiles to deliver), or false if running or not started yet.
      See Also:
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception