it.unimi.dsi.archive4j
Class ArchiveLoader

java.lang.Object
  extended by it.unimi.dsi.archive4j.ArchiveLoader

public class ArchiveLoader
extends Object

Static container providing commodity methods to load archives.

This class contains methods to load easily Archive instances whose implementing classes adopt the following suggestion: they implement a getInstance() method accepting a basename (a CharSequence), a set of properties and an optional StringMap (acting as a URI list).

The file basename + PROPERTIES_EXTENSION should contain the properties of the archive, which will be passed on to the getInstance() method (possibly after some massaging). The property file must contain a property ArchiveLoader.PropertyKeys.CLASS, so that we can dispatch the appropriate getInstance() method by reflection.

An optional boolean parameter may be used to specify that an archive must be loaded entirely in core memory: in this case, this class will add the key ArchiveLoader.PropertyKeys.INMEMORY add to the archive property set. The key can also be set manually in the property file if necessary.

Author:
Alessio Orlandi, Sebastiano Vigna

Nested Class Summary
static class ArchiveLoader.PropertyKeys
          The (capitalized) names for archive properties.
 
Field Summary
static String PROPERTIES_EXTENSION
          The extension of a properties file.
 
Method Summary
static Archive<? extends DocumentSummary> getInstance(CharSequence basename)
          Creates a disk-based archive instance using the given basename (and no URI list).
static Archive<? extends DocumentSummary> getInstance(CharSequence basename, boolean inMemory)
          Creates an archive instance using the given basename (and no URI list).
static Archive<? extends DocumentSummary> getInstance(CharSequence basename, CharSequence uriList)
          Creates a disk-based archive instance using the given basename and loading the given URI list.
static Archive<? extends DocumentSummary> getInstance(CharSequence basename, CharSequence uriList, boolean inMemory)
          Creates an archive instance using the given basename and loading the given URI list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_EXTENSION

public static final String PROPERTIES_EXTENSION
The extension of a properties file.

See Also:
Constant Field Values
Method Detail

getInstance

public static Archive<? extends DocumentSummary> getInstance(CharSequence basename,
                                                             boolean inMemory)
                                                      throws IOException,
                                                             ConfigurationException
Creates an archive instance using the given basename (and no URI list).

Parameters:
basename - the basename of the archive.
inMemory - whether the archive should be loaded in core memory.
Returns:
an archive instance.
Throws:
IOException
ConfigurationException

getInstance

public static Archive<? extends DocumentSummary> getInstance(CharSequence basename,
                                                             CharSequence uriList,
                                                             boolean inMemory)
                                                      throws IOException,
                                                             ConfigurationException
Creates an archive instance using the given basename and loading the given URI list.

Parameters:
basename - the basename of the archive.
uriList - the filename of a URI list.
inMemory - whether the archive should be loaded in core memory.
Returns:
an archive instance.
Throws:
IOException
ConfigurationException

getInstance

public static Archive<? extends DocumentSummary> getInstance(CharSequence basename)
                                                      throws IOException,
                                                             ConfigurationException
Creates a disk-based archive instance using the given basename (and no URI list).

Parameters:
basename - the basename of the archive.
Returns:
an archive instance.
Throws:
IOException
ConfigurationException

getInstance

public static Archive<? extends DocumentSummary> getInstance(CharSequence basename,
                                                             CharSequence uriList)
                                                      throws IOException,
                                                             ConfigurationException
Creates a disk-based archive instance using the given basename and loading the given URI list.

Parameters:
basename - the basename of the archive.
uriList - the filename of a URI list.
Returns:
an archive instance.
Throws:
IOException
ConfigurationException