Class AbstractDocument
- java.lang.Object
-
- it.unimi.di.big.mg4j.document.AbstractDocument
-
- All Implemented Interfaces:
Document
,SafelyCloseable
,Closeable
,AutoCloseable
- 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 toclose()
will be easier to detect.Warning: if you do not close an instance of this class, a warning will be logged at some point during garbage collection. The warning will use the document title: you must be sure to never leave the document in a state in which calling
Document.title()
is dangerous (i.e., a document coming from a streaming source which retains a handle to the source for lazy parsing), or bad things will happen.
-
-
Constructor Summary
Constructors Constructor Description AbstractDocument()
-
-
-
Method Detail
-
finalize
protected void finalize() 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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceDocument
- Throws:
IOException
-
-