Class FSFileArchive

  • Direct Known Subclasses:
    ClasspathArchive, FolderArchive, ZipArchive

    public abstract class FSFileArchive
    extends Object
    Wrapper structure that is used to create a common interface with all files. A wrapper class should be used to wrap an archive or directory type in order for the file system to be able to read it without needing to know what kind of file it is looking in.
    Author:
    Matthew Tropiano
    • Constructor Detail

      • FSFileArchive

        public FSFileArchive()
    • Method Detail

      • getFile

        public abstract FSFile getFile​(String path)
                                throws IOException
        Returns an FSFile reference of a file within this wrapped file.
        Parameters:
        path - the abstract path of a file inside this file.
        Returns:
        a new reference to the file requested, or null if the path refers to a location that is not inside this file.
        Throws:
        IOException - if a read error occurs during the fetch.
      • getAllFiles

        public abstract FSFile[] getAllFiles()
                                      throws IOException
        Retrieves all of the files within this object as FSFile objects.
        Returns:
        an array of FSFiles, each entry representing a particular file in this object.
        Throws:
        IOException - if a read error occurs during the fetch.
      • getAllFilesInDir

        public abstract FSFile[] getAllFilesInDir​(String path)
                                           throws IOException
        Retrieves all of the files within a directory as FSFile objects.
        Parameters:
        path - the abstract path of a directory inside this file.
        Returns:
        an array of FSFiles, each entry representing a particular file in this object.
        Throws:
        IOException - if a read error occurs during the fetch.
      • getAllFilesInDir

        public abstract FSFile[] getAllFilesInDir​(String path,
                                                  FSFileFilter filter)
                                           throws IOException
        Retrieves all of the files within this object as FSFile objects that pass the filter test.
        Parameters:
        path - the abstract path of a directory inside this file.
        filter - the file filter to use.
        Returns:
        an array of FSFiles, each entry representing a particular file in this object.
        Throws:
        IOException - if a read error occurs during the fetch.
      • getAllFiles

        public abstract FSFile[] getAllFiles​(FSFileFilter filter)
                                      throws IOException
        Retrieves all of the files within this object that pass the filter test as FSFile objects.
        Parameters:
        filter - the file filter to use.
        Returns:
        an array of FSFiles, each entry representing a particular file in this object.
        Throws:
        IOException - if a read error occurs during the fetch.
      • canCreateFiles

        public abstract boolean canCreateFiles()
        Can this archive create a new file within itself?
        Returns:
        true if it can, false if it is read-only.
      • createFile

        public abstract OutputStream createFile​(String path)
                                         throws IOException
        Creates a file in this archive using the name and path provided.
        Parameters:
        path - the path of the file to create.
        Returns:
        an acceptable OutputStream for filling the file with data.
        Throws:
        UnsupportedOperationException - if this is called on an archive that does not support writing.
        IOException - if a read error occurs during the fetch.
      • setArchiveName

        protected void setArchiveName​(String name)
        Sets the name of this archive.
        Parameters:
        name - the new archive name.
      • setPath

        protected void setPath​(String path)
        Sets the path of this archive.
        Parameters:
        path - the new archive name.
      • getArchiveName

        public String getArchiveName()
        Gets the name of this archive.
        Returns:
        the archive name.
      • getPath

        public String getPath()
        Gets the path of this archive.
        Returns:
        the path.