Package it.unimi.di.big.mg4j.document
Class AbstractDocumentSequence
- java.lang.Object
-
- it.unimi.di.big.mg4j.document.AbstractDocumentSequence
-
- All Implemented Interfaces:
DocumentSequence
,SafelyCloseable
,Closeable
,AutoCloseable
- Direct Known Subclasses:
AbstractDocumentCollection
,CompositeDocumentSequence
,ConcatenatedDocumentSequence
,CSVDocumentCollection
,SubsetDocumentSequence
,WarcDocumentSequence
,WikipediaDocumentSequence
public abstract class AbstractDocumentSequence extends Object implements DocumentSequence, SafelyCloseable
An abstract,safely closeable
implementation of a document sequence.Note that even if your
DocumentSequence
implementation does not allocate any specific resource, it is nonetheless a good idea to inherit from this class, as tracking missing calls toclose()
will be easier to detect.
-
-
Constructor Summary
Constructors Constructor Description AbstractDocumentSequence()
-
Method Summary
Modifier and Type Method Description void
close()
Closes this document sequence, releasing all resources.void
filename(CharSequence filename)
Does nothing.protected void
finalize()
static DocumentSequence
load(CharSequence filename)
Loads a sequence.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.document.DocumentSequence
factory, iterator
-
-
-
-
Method Detail
-
load
public static DocumentSequence load(CharSequence filename) throws IOException, ClassNotFoundException, IllegalArgumentException, SecurityException
Loads a sequence.This method first deserialises the object specified by the given filename, and then invokes
DocumentSequence.filename(CharSequence)
to ensure proper relativisation of serialised filenames.- Parameters:
filename
- a filename that will be used to load a serialised sequence.- Throws:
IOException
ClassNotFoundException
IllegalArgumentException
SecurityException
-
filename
public void filename(CharSequence filename) throws IOException
Does nothing.- Specified by:
filename
in interfaceDocumentSequence
- Parameters:
filename
- the filename of this document sequence.- Throws:
IOException
-
finalize
protected void finalize() throws Throwable
-
close
public void close() throws IOException
Description copied from interface:DocumentSequence
Closes this document sequence, releasing all resources.You should always call this method after having finished with this document sequence. Implementations are invited to call this method in a finaliser as a safety net (even better, implement
SafelyCloseable
), but since there is no guarantee as to when finalisers are invoked, you should not depend on this behaviour.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceDocumentSequence
- Throws:
IOException
-
-