au.com.zip.cs
Class LoggedDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by au.com.zip.cs.LoggedDocument
All Implemented Interfaces:
Serializable, Document

public class LoggedDocument
extends PlainDocument

A PlainDocument that appends all inserts to a logging Writer.

Author:
Cameron Simpson <cs@zip.com.au> 28jun2002
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
 
Field Summary
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
LoggedDocument(Writer w)
          Constructs a new LoggedDocument that transcribes all insertString(int,String,AttributeSet)s to the specified Writer.
 
Method Summary
 void close()
          Close the LoggedDocument.
 Writer getLogWriter()
          Return the current log Writer.
 void insertString(int offset, String str, AttributeSet a)
          Insert the supplied String into the PlainDocument and log it.
 void setLogWriter(Writer w)
          Set the current log Writer, closing the previous one if any.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggedDocument

public LoggedDocument(Writer w)
               throws IOException
Constructs a new LoggedDocument that transcribes all insertString(int,String,AttributeSet)s to the specified Writer.

Parameters:
w - the log
Throws:
IOException
Method Detail

setLogWriter

public void setLogWriter(Writer w)
                  throws IOException
Set the current log Writer, closing the previous one if any.

Parameters:
w - the new Writer
Throws:
IOException

getLogWriter

public Writer getLogWriter()
Return the current log Writer.


close

public void close()
           throws IOException
Close the LoggedDocument.

Throws:
IOException

insertString

public void insertString(int offset,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Insert the supplied String into the PlainDocument and log it.

Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Parameters:
offset - the insertion location
str - the String to insert
a - the associated AttributeSet
Throws:
BadLocationException