Compoze Software, Inc.

com.compoze.util
Class TextLineFilterWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.FilterWriter
          extended bycom.compoze.util.TextLineFilterWriter
Direct Known Subclasses:
HtmlLinkFilterWriter, SubstitutionWriter

public abstract class TextLineFilterWriter
extends java.io.FilterWriter

This class is a filter writer that allows subclasses to process the text that comes through a line at a time. This makes it easier for filter writers that wish to process text to do their work. Subclasses must only implement filterLine() to do their work. As data is written to this writer, it is buffered until a full line of text is obtained. A line is considered to be any amount of text followed by a newline, or a carriage return then a newline. Once a full line of text is obtained filterLine() is called, and the result is written to the underlying reader. The platform's default line separator is always used. flush() must be called to insure that any remaining text is written. Since this class works on text line-by-line it is less appropriate for classes that need to filter multiple lines.


Field Summary
 
Fields inherited from class java.io.FilterWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TextLineFilterWriter(java.io.Writer out)
          Constructor.
 
Method Summary
protected abstract  java.lang.String filterLine(java.lang.String sLine)
          Filter a line of text.
 void flush()
          Flush the buffer and the underlying output writer.
 void write(char[] cBuffer, int iOffset, int iLength)
          Write an array of characters.
 void write(int iChar)
          Write a single character.
 void write(java.lang.String sString, int iOffset, int iLength)
          Write a portion of a string.
 
Methods inherited from class java.io.FilterWriter
close
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextLineFilterWriter

public TextLineFilterWriter(java.io.Writer out)
Constructor.

Parameters:
out - the underlying writer
Method Detail

write

public void write(char[] cBuffer,
                  int iOffset,
                  int iLength)
           throws java.io.IOException
Write an array of characters.

Parameters:
cBuffer - the character buffer
iOffset - the offset in the buffer
iLength - the length of the buffer
Throws:
java.io.IOException - if an i/o exception occurred

write

public void write(int iChar)
           throws java.io.IOException
Write a single character.

Parameters:
iChar - the character to write
Throws:
java.io.IOException - if an i/o exception occurred

write

public void write(java.lang.String sString,
                  int iOffset,
                  int iLength)
           throws java.io.IOException
Write a portion of a string.

Parameters:
sString - the string to write
iOffset - the offset in the buffer
iLength - the length of the buffer
Throws:
java.io.IOException - if an i/o exception occurred

flush

public void flush()
           throws java.io.IOException
Flush the buffer and the underlying output writer.

Throws:
java.io.IOException - if an i/o exception occurred

filterLine

protected abstract java.lang.String filterLine(java.lang.String sLine)
Filter a line of text. Subclasses must implement this to do their work.

Parameters:
sLine - the line to write (does not include line termination characters)
Returns:
the filtered line

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.