Class PostingCache

java.lang.Object
org.ctan.site.services.postings.PostingCache
Direct Known Subclasses:
PostingsService

public class PostingCache extends Object
This class provides a container for Postings.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PostingCache(@NonNull File base)
    This is the constructor for PostingCache.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String key)
    This method is the getter for the postings according to its id.
    protected File
    The method getBase provides means to access the base directory.
    boolean
    This method checks whether postings for a package key have been read and cached.
    boolean
    The method isEmpty checks whether postings are contained.
    listByDate(@NonNull Date start, int max)
    The method listByDate returns a list sorted by date which starts at a given date and contains at most a given number of items.
    listByPackage(@NonNull String pkg, int max)
    This method retrieves a list of postings associated to a package.
    listNewest(int max)
    This method retrieves the newest postings up to a maximal number.
    listNewest(@NonNull String pkg, int max)
    This method retrieves the newest postings up to a maximal number for a given package.
    listPaged(int page, int size)
    The method listPaged provides means to retrieve a paged list of postings.
    This method is a getter for the keys of the packages.
    int
    This method is a getter for the number of mails in the cache.
    This method is a getter for the monthly count by package.
    int
    The method total provides means to retrieve the total number of mails.
    void
    This method scans all files in the base directory and reads in the new or changed mail archive files.

    Methods inherited from class java.lang.Object

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

    • PostingCache

      public PostingCache(@NonNull @NonNull File base) throws FileNotFoundException, IOException
      This is the constructor for PostingCache. The argument is considered as directory which is scanned for appropriate files. If the directory is null then the scanning is omitted and the cache is left empty.
      Parameters:
      base - the base directory
      Throws:
      FileNotFoundException - in case the file does not exist
      IOException - in case of an I/O error
  • Method Details

    • get

      public Posting get(String key)
      This method is the getter for the postings according to its id.
      Parameters:
      key - the mail id
      Returns:
      the mail found or null for none
    • getBase

      protected File getBase()
      The method getBase provides means to access the base directory.
      Returns:
      the base directory
    • hasPostingForPackage

      public boolean hasPostingForPackage(String pkg)
      This method checks whether postings for a package key have been read and cached.
      Parameters:
      pkg - the key of the package
      Returns:
      true iff a posting for the package has been encountered
    • isEmpty

      public boolean isEmpty()
      The method isEmpty checks whether postings are contained.
      Returns:
      true iff no postings are contained
    • listByDate

      public List<Posting> listByDate(@NonNull @NonNull Date start, int max)
      The method listByDate returns a list sorted by date which starts at a given date and contains at most a given number of items.
      Parameters:
      start - the start date
      max - the maximal number of items
      Returns:
      a list of postings
    • listByPackage

      public List<Posting> listByPackage(@NonNull @NonNull String pkg, int max)
      This method retrieves a list of postings associated to a package.
      Parameters:
      pkg - the key of the package
      max - the maximal length
      Returns:
      the requested list of postings. The list is a new list. It is sorted increasingly.
    • listNewest

      public Iterable<Posting> listNewest(int max)
      This method retrieves the newest postings up to a maximal number. If the maximal number is reached then additional older postings are not contained in the result.
      Parameters:
      max - the truncation limit
      Returns:
      the requested list of mails
    • listNewest

      public Iterable<Posting> listNewest(@NonNull @NonNull String pkg, int max)
      This method retrieves the newest postings up to a maximal number for a given package. If the maximal number is reached then additional older postings are not contained in the result.
      Parameters:
      pkg - the CTAN name of the package
      max - the truncation limit
      Returns:
      the requested list of postings
    • listPaged

      public List<Posting> listPaged(int page, int size)
      The method listPaged provides means to retrieve a paged list of postings.
      Parameters:
      page - the start page
      size - the maximal number of items
      Returns:
      a list of postings
    • packages

      public Set<String> packages()
      This method is a getter for the keys of the packages.
      Returns:
      the set of keys of packages
    • size

      public int size()
      This method is a getter for the number of mails in the cache.
      Returns:
      the number of mails in the cache
    • summaryCountByPkg

      public List<Integer[]> summaryCountByPkg(String pkg)
      This method is a getter for the monthly count by package.
      Parameters:
      pkg - the key of the package
      Returns:
      the list of counts
    • total

      public int total()
      The method total provides means to retrieve the total number of mails.
      Returns:
      total number of mails
    • update

      public void update() throws IOException
      This method scans all files in the base directory and reads in the new or changed mail archive files.
      Throws:
      IOException - in case of an I/O error