gnu.text
Class WriterManager

java.lang.Object
  extended by gnu.text.WriterManager
All Implemented Interfaces:
java.lang.Runnable

public class WriterManager
extends java.lang.Object
implements java.lang.Runnable

Manages a collection of Writers, handling automatic closing. This class is useful for making sure that a Writer is closed (and its buffers flushed) when a VM exits. A WriterManager can be usefully passed to the JDK 1.3 method addShutdownHook in Runtime.


Field Summary
static WriterManager instance
           
 
Constructor Summary
WriterManager()
           
 
Method Summary
 gnu.text.WriterRef register(java.io.Writer port)
          Register a Writer.
 boolean registerShutdownHook()
          Try to register this as a shutdown hook.
 void run()
           
 void unregister(java.lang.Object key)
          Unregister a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final WriterManager instance
Constructor Detail

WriterManager

public WriterManager()
Method Detail

register

public gnu.text.WriterRef register(java.io.Writer port)
Register a Writer.

Returns:
an object that can be passed to unregister(java.lang.Object).

unregister

public void unregister(java.lang.Object key)
Unregister a Writer.

Parameters:
key - the object returned by the correspodning register(java.io.Writer).

run

public void run()
Specified by:
run in interface java.lang.Runnable

registerShutdownHook

public boolean registerShutdownHook()
Try to register this as a shutdown hook.

Returns:
true on success; false if failure (e.g. if not JDK1.3-compatible).