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
Posting
s.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method is the getter for the postings according to its id.protected File
getBase()
The methodgetBase
provides means to access the base directory.boolean
This method checks whether postings for a package key have been read and cached.boolean
isEmpty()
The methodisEmpty
checks whether postings are contained.listByDate
(@NonNull Date start, int max) The methodlistByDate
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 methodlistPaged
provides means to retrieve a paged list of postings.packages()
This method is a getter for the keys of the packages.int
size()
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.int
total()
The methodtotal
provides means to retrieve the total number of mails.void
update()
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 isnull
then 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
null
for none
-
getBase
The methodgetBase
provides 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:
true
iff a posting for the package has been encountered
-
isEmpty
public boolean isEmpty()The methodisEmpty
checks whether postings are contained.- Returns:
true
iff no postings are contained
-
listByDate
The methodlistByDate
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 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 methodlistPaged
provides 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 methodtotal
provides 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
-