Class DataReaderFactory


  • public final class DataReaderFactory
    extends java.lang.Object
    This class returns a specific DataReader object that can read in the specified file. This class implements a pluggable architecture. A new DataReader class can be added by simply creating a subclass of DataReader, creating a datareader.properties file that refers to it, and putting that properties file somewhere in the Java search path.

    Modified by: Joseph A. Huwaldt

    Version:
    February 23, 2025
    Author:
    Joseph A. Huwaldt, Date: March 25, 2003
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.ResourceBundle RESOURCES
      The resource bundle for this package.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static DataReader[] getAllReaders()
      Method that returns a list of all the DataReader objects found by this factory.
      static DataReader getReader​(java.io.BufferedInputStream inputStream, java.lang.String pathName)
      Method that attempts to find a DataReader object that might be able to read the data in the specified input stream.
      static DataReader getReader​(java.io.File theFile)
      Method that attempts to find an DataReader object that might be able to read the data in the specified file.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RESOURCES

        public static final java.util.ResourceBundle RESOURCES
        The resource bundle for this package.
    • Method Detail

      • getReader

        public static DataReader getReader​(java.io.BufferedInputStream inputStream,
                                           java.lang.String pathName)
                                    throws java.io.IOException
        Method that attempts to find a DataReader object that might be able to read the data in the specified input stream.
        Parameters:
        inputStream - An input stream to the file that a reader is to be returned for.
        pathName - The path or file name for the file that a reader is to be returned for.
        Returns:
        A reader that is appropriate for the specified file, or null if the user cancels the multiple reader selection dialog.
        Throws:
        java.io.IOException - if an appropriate reader for the file could not be found.
      • getReader

        public static DataReader getReader​(java.io.File theFile)
                                    throws java.io.IOException
        Method that attempts to find an DataReader object that might be able to read the data in the specified file.
        Parameters:
        theFile - The file to find a reader for.
        Returns:
        A reader that is appropriate for the specified file, or null if the user cancels the multiple reader selection dialog.
        Throws:
        java.io.IOException - if an appropriate reader for the file could not be found.
      • getAllReaders

        public static DataReader[] getAllReaders()
        Method that returns a list of all the DataReader objects found by this factory.
        Returns:
        An array of DataReader objects (can be null if static initialization failed).