Class VirtualFolder

java.lang.Object
com.jackmeng.locale.PhysicalFolder
com.jackmeng.locale.VirtualFolder

public class VirtualFolder extends PhysicalFolder
A class that represents a virtual folder, this virtual folder does not exist on the user's actual hard drive and is used to represent a virtual folder that may be used to hold files from different stuffs.

The entirety of the methods from FolderInfo are overriden in order to completely encompass a "virtual" folder

Since:
3.1
Author:
Jack Meng
  • Field Details

  • Constructor Details

    • VirtualFolder

      public VirtualFolder(String name, File... files)
      A VirtualFolder takes a varargs of file objects in order to represent the folder with files.

      The absolute path of the folder is replaced by a generic name.

      Parameters:
      name - The name of the virtual folder.
      files - The files in the virtual folder.
  • Method Details

    • getFilesAsStr

      public String[] getFilesAsStr()
      Description copied from class: PhysicalFolder
      Returns the Files (not sub-folders) in the folder-info object or the folder as the file's names.
      Overrides:
      getFilesAsStr in class PhysicalFolder
      Returns:
      String[] A list of files of their absolute paths in string form
    • getFiles

      public File[] getFiles()
      Description copied from class: PhysicalFolder
      Returns all of the files within the folder
      Overrides:
      getFiles in class PhysicalFolder
      Returns:
      File[] A list of files of their File object instances (created on call)
    • getFilesAsStr

      public String[] getFilesAsStr(String... rules)
      Applies a check against the list of avaliable files.
      Overrides:
      getFilesAsStr in class PhysicalFolder
      Parameters:
      rules - A set of rules to be used to compare the ending of the file (endsWith)
      Returns:
      String[] A list of file of their absolute paths in string form
    • getFiles

      public File[] getFiles(String... rules)
      Applies a check against the list of avaliable files.

      This uses the method getFilesAsStr(String...) method for validation.

      Overrides:
      getFiles in class PhysicalFolder
      Parameters:
      rules - A set of rules to be used to comapre the ending of the file (endsWith)
      Returns:
      File[] A list of file of their respective absolute paths
    • addFile

      public void addFile(File f)
      Insert a file into this virtual folder instance.

      This method does not handle if this file instance exists or not.

      The implementation must handle this by themselves.

      Parameters:
      f - A file to insert.
    • getAsListFiles

      public List<File> getAsListFiles()
      Returns the absolute list.
      Returns:
      A List
    • removeFile

      public boolean removeFile(File f)
      Removes a file from the absolute list.
      Parameters:
      f - The file instance to remove.
      Returns:
      (true | | false) if the action was a success
    • toString

      public String toString()
      Description copied from class: PhysicalFolder
      Represents the folder-info object as a string.
      Overrides:
      toString in class PhysicalFolder
      Returns:
      String