Class EarthDataReaderFactory

java.lang.Object
noaa.coastwatch.io.EarthDataReaderFactory

public class EarthDataReaderFactory extends Object
The earth data reader factory class creates an appropriate earth data reader object based on a file name. The default list of readers is as follows: Additional readers may be appended to the list using the addReader() method, or by adding the class name to the reader.properties resource file.
Since:
3.1.0
Author:
Peter Hollemans
  • Constructor Details

    • EarthDataReaderFactory

      public EarthDataReaderFactory()
  • Method Details

    • addReader

      public static void addReader(Class readerClass)
      Adds a new reader to the list. When the factory creates a new reader from a file name, the new reader will be among those tried when opening the file. The reader should throw a java.io.IOException if an error is encountered reading the initial parts of the file, and/or if the file format is not recognized. By convention, the reader should have a constructor that takes a single String parameter as the file name.
      Parameters:
      readerClass - the new reader class to add to the list.
    • setVerbose

      public static void setVerbose(boolean flag)
      Sets the verbose mode. If verbose mode is on, the errors encountered while trying to create the reader object are printed.
      Parameters:
      flag - the verbose flag.
    • create

      public static EarthDataReader create(String file) throws IOException
      Creates an earth data reader object.
      Parameters:
      file - the file name. The file will be opened using the different earth data reader classes in the list until the correct constructor is found.
      Returns:
      an earth data reader object specific to the file format.
      Throws:
      IOException - if the reader could not be created. Either the file was not found, or the format was not recognized by any reader.