Package org.ctan.site.services.postings
Class PostingCache
java.lang.Object
org.ctan.site.services.postings.PostingCache
- Direct Known Subclasses:
PostingsService
This class provides a container for
Postings.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method is the getter for the postings according to its id.protected FilegetBase()The methodgetBaseprovides means to access the base directory.booleanThis method checks whether postings for a package key have been read and cached.booleanisEmpty()The methodisEmptychecks whether postings are contained.listByDate(@NonNull LocalDateTime start, int max) The methodlistByDatereturns 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 methodlistPagedprovides means to retrieve a paged list of postings.packages()This method is a getter for the keys of the packages.intsize()This method is a getter for the number of mails in the cache.summaryCountByPkg(String pkg) This method is a getter for the monthly count by package.inttotal()The methodtotalprovides means to retrieve the total number of mails.voidupdate()This method scans all files in the base directory and reads in the new or changed mail archive files.
-
Constructor Details
-
PostingCache
This is the constructor forPostingCache. The argument is considered as directory which is scanned for appropriate files. If the directory isnullthen the scanning is omitted and the cache is left empty.- Parameters:
base- the base directory- Throws:
FileNotFoundException- in case the file does not existIOException- in case of an I/O error
-
-
Method Details
-
get
This method is the getter for the postings according to its id.- Parameters:
key- the mail id- Returns:
- the mail found or
nullfor none
-
getBase
The methodgetBaseprovides means to access the base directory.- Returns:
- the base directory
-
hasPostingForPackage
This method checks whether postings for a package key have been read and cached.- Parameters:
pkg- the key of the package- Returns:
trueiff a posting for the package has been encountered
-
isEmpty
public boolean isEmpty()The methodisEmptychecks whether postings are contained.- Returns:
trueiff no postings are contained
-
listByDate
The methodlistByDatereturns a list sorted by date which starts at a given date and contains at most a given number of items.- Parameters:
start- the start datemax- the maximal number of items- Returns:
- a list of postings
-
listByPackage
This method retrieves a list of postings associated to a package.- Parameters:
pkg- the key of the packagemax- the maximal length- Returns:
- the requested list of postings. The list is a new list. It is sorted increasingly.
-
listNewest
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
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 packagemax- the truncation limit- Returns:
- the requested list of postings
-
listPaged
The methodlistPagedprovides means to retrieve a paged list of postings.- Parameters:
page- the start pagesize- the maximal number of items- Returns:
- a list of postings
-
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
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 methodtotalprovides means to retrieve the total number of mails.- Returns:
- total number of mails
-
update
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
-