it.unimi.di.mg4j.document
Class AbstractDocument

java.lang.Object
  extended by it.unimi.di.mg4j.document.AbstractDocument
All Implemented Interfaces:
Document, SafelyCloseable, Closeable
Direct Known Subclasses:
CompositeDocumentFactory.CompositeDocument, HtmlDocumentFactory.HtmlDocument, ReplicatedDocumentFactory.ReplicatedDocument

public abstract class AbstractDocument
extends Object
implements Document, SafelyCloseable

An abstract, safely closeable implementation of a document.

This implementation provides also a toString() method that just returns the document title.

Note that even if your Document implementation does not allocate any document-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
AbstractDocument()
           
 
Method Summary
 void close()
          Closes this document, releasing all resources.
protected  void finalize()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.di.mg4j.document.Document
content, title, uri, wordReader
 

Constructor Detail

AbstractDocument

public AbstractDocument()
Method Detail

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

close

public void close()
           throws IOException
Description copied from interface: Document
Closes this document, releasing all resources.

You should always call this method after manipulating a document. 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 Document
Specified by:
close in interface Closeable
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object