Class DfltFileMgr

  • All Implemented Interfaces:
    IQBPFileMgr

    public class DfltFileMgr
    extends java.lang.Object
    implements IQBPFileMgr
    Default file manager for the Query Builder Platform. This handles standard files. By default it has no restrictions. Optionally the files can be restricted to appearing under a specific directory (path).
    • Constructor Summary

      Constructors 
      Constructor Description
      DfltFileMgr()
      Create a default file manager.
      DfltFileMgr​(java.io.File allowed_directory)
      Create a file manager that restricts files to a directory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.InputStream getReaderFor​(java.io.File file_id)
      Get an input stream reader for a file identified by a File object.
      java.io.InputStream getReaderFor​(java.lang.String data_source)
      Get an input stream reader for a file identified by a string value.
      java.lang.String verify​(java.io.File data_file)
      Check if a File is a valid data source.
      java.lang.String verify​(java.lang.String data_source)
      Check if the given data source is valid.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DfltFileMgr

        public DfltFileMgr()
        Create a default file manager. The default manager has no restrictions.
      • DfltFileMgr

        public DfltFileMgr​(java.io.File allowed_directory)
                    throws java.io.IOError,
                           java.lang.SecurityException,
                           java.lang.IllegalArgumentException
        Create a file manager that restricts files to a directory. This creates a file manager that only allows files that appear under a particular directory. They may appear anywhere in the directory tree under the given directory.
        Parameters:
        allowed_directory - all files must appear under this directory.
        Throws:
        java.lang.IllegalArgumentException - if allowed_directory is null.
        java.io.IOError - for errors accessing directory information.
        java.lang.SecurityException - if access to the allowed_directory is denied for security reasons.
    • Method Detail

      • verify

        public java.lang.String verify​(java.lang.String data_source)
        Check if the given data source is valid. This checks if the file is readable. This includes checking access restrictions applied by this file manager.
        Specified by:
        verify in interface IQBPFileMgr
        Parameters:
        data_source - this must be a file path.
        Returns:
        null if this is a valid readable file. an error string if not.
      • verify

        public java.lang.String verify​(java.io.File data_file)
        Check if a File is a valid data source. This includes checking any access restrictions applied by this file manager.
        Specified by:
        verify in interface IQBPFileMgr
        Parameters:
        data_file - a file object identifying the data source.
        Returns:
        if the File appears valid null is returned, if the File is invalid a descriptive string is returned.
      • getReaderFor

        public java.io.InputStream getReaderFor​(java.lang.String data_source)
                                         throws java.io.FileNotFoundException,
                                                java.lang.IllegalArgumentException
        Get an input stream reader for a file identified by a string value. This assumes data_source is a file name and opens it. If this object was created with a configuration file directory, and the given file is not under the directory, an IllegalArgumentException is thrown.
        Specified by:
        getReaderFor in interface IQBPFileMgr
        Parameters:
        data_source - the path name of a standard file.
        Returns:
        an open InputStream for the data_source. The position of the stream is on the first byte of data.
        Throws:
        java.io.FileNotFoundException - if there is no such file, it is a directory, or could not be opened for some other reason.
        java.lang.IllegalArgumentException - if data_source is null, empty, or if it doesn't meet the current sub-directory restrictions or if access is denied for security reasons.
      • getReaderFor

        public java.io.InputStream getReaderFor​(java.io.File file_id)
                                         throws java.io.FileNotFoundException,
                                                java.lang.IllegalArgumentException
        Get an input stream reader for a file identified by a File object. This provides an input stream for the given file. This implementation imposes no restrictions.
        Specified by:
        getReaderFor in interface IQBPFileMgr
        Parameters:
        file_id - the file to be read.
        Returns:
        an open InputStream for the file. The position of the stream is on the first byte of data.
        Throws:
        java.io.FileNotFoundException - if there is no such file.
        java.lang.IllegalArgumentException - if file_id is null, or if access is denied for security reasons.