Class CopiesList


  • public class CopiesList
    extends java.lang.Object
    A file that contains the desired number of copies of different components in a deck task. Can be queried with a file name to retrieve the number of copies of that item to include.
    Since:
    3.0
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      CopiesList()
      Creates an empty list that returns 1 copy for all cards.
      CopiesList​(Task taskFolder)
      Creates a copies list using the standard copies list file for a task folder.
      CopiesList​(java.io.File copiesListFile)
      Creates a copies list using the entries stored in an arbitrary file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCopyCount​(java.io.File file)
      Return the number of copies for a file with the same file name as the specified file.
      int getCopyCount​(java.lang.String name)
      Returns the number of copies for a file with the specified name.
      java.lang.String[] getListEntries()
      Returns the name part of each entry explicitly included in the copies list.
      void setCopyCount​(java.io.File file, int copies)
      Sets the number of copies to include for a file with the same name as the specified file.
      void setCopyCount​(java.lang.String name, int copies)
      Sets the number of copies to include for a file with the specified name.
      void store()
      Write the copies data to the file used to construct this list.
      • Methods inherited from class java.lang.Object

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

      • CopiesList

        public CopiesList()
        Creates an empty list that returns 1 copy for all cards. This list cannot be stored.
      • CopiesList

        public CopiesList​(Task taskFolder)
                   throws java.io.IOException
        Creates a copies list using the standard copies list file for a task folder.
        Parameters:
        taskFolder - the folder to fetch the copies list from
        Throws:
        java.io.IOException - if an error occurs while reading the file
      • CopiesList

        public CopiesList​(java.io.File copiesListFile)
                   throws java.io.IOException
        Creates a copies list using the entries stored in an arbitrary file.
        Parameters:
        copiesListFile - the file containing the copy information
        Throws:
        java.io.IOException - if an error occurs while reading the file
    • Method Detail

      • getCopyCount

        public int getCopyCount​(java.io.File file)
        Return the number of copies for a file with the same file name as the specified file.
        Parameters:
        file - the file to determine the copy count of
        Returns:
        the number of copies of the file to include
      • getCopyCount

        public int getCopyCount​(java.lang.String name)
        Returns the number of copies for a file with the specified name. If the name ends with the suffix ".eon", and the copies list does not contain a matching entry but does contain an entry for the same file name without a suffix, then the ".eon" suffix will be ignored.
        Parameters:
        name - the file name to fetch a copy count for
        Returns:
        the number of copies of the file to include
      • setCopyCount

        public void setCopyCount​(java.io.File file,
                                 int copies)
        Sets the number of copies to include for a file with the same name as the specified file.
        Parameters:
        file - the file to modify the copy count for
        copies - the new copy count
        Throws:
        java.lang.NullPointerException - if the file is null
        java.lang.IllegalArgumentException - if the number of copies is negative
      • setCopyCount

        public void setCopyCount​(java.lang.String name,
                                 int copies)
        Sets the number of copies to include for a file with the specified name.
        Parameters:
        name - the file name to modify the copy count for
        copies - the new copy count
        Throws:
        java.lang.NullPointerException - if the name is null
        java.lang.IllegalArgumentException - if the number of copies is negative
      • getListEntries

        public java.lang.String[] getListEntries()
        Returns the name part of each entry explicitly included in the copies list.
        Returns:
        the file names included in the copies list
      • store

        public void store()
                   throws java.io.IOException
        Write the copies data to the file used to construct this list.
        Throws:
        java.io.IOException - if an error occurs
        java.lang.IllegalStateException - if the list was not created from a file