public abstract class AbstractDocument extends Object implements Document, SafelyCloseable
safely closeableimplementation of a document.
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.
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 and Description|
|Modifier and Type||Method and Description|
Closes this document, releasing all resources.
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
protected void finalize() throws Throwable
public void close() throws IOException
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,
SafelyCloseable), but since there
is no guarantee as to when finalisers are invoked, you should not depend on this behaviour.