it.unimi.di.mg4j.document
Class AbstractDocumentSequence

java.lang.Object
  extended by it.unimi.di.mg4j.document.AbstractDocumentSequence
All Implemented Interfaces:
DocumentSequence, SafelyCloseable, Closeable
Direct Known Subclasses:
AbstractDocumentCollection, CompositeDocumentSequence, ConcatenatedDocumentSequence, CSVDocumentCollection, SubsetDocumentSequence

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 to close() will be easier to detect.


Constructor Summary
AbstractDocumentSequence()
           
 
Method Summary
 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.mg4j.document.DocumentSequence
factory, iterator
 

Constructor Detail

AbstractDocumentSequence

public AbstractDocumentSequence()
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 interface DocumentSequence
Parameters:
filename - the filename of this document sequence.
Throws:
IOException

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
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 interface DocumentSequence
Specified by:
close in interface Closeable
Throws:
IOException