com.ctc.wstx.util
Class LineSuppressWriter

java.lang.Object
  extended byjava.io.Writer
      extended bycom.ctc.wstx.util.LineSuppressWriter

public class LineSuppressWriter
extends java.io.Writer

Simple decorator Writer, that can optionally suppress empty lines (lines with only white space content); configuration is done by specifying what is the maximum number of consequtive empty lines allowed. Setting this value to 0 will filter out all lines; setting it to, say, Integer.MAX_VALUE essentially does nothing.

Note: only ascii white space (space char and below) are considered white space.


Field Summary
protected  int mCurrEmptyLines
           
protected  boolean mCurrIsEmpty
           
protected  char[] mCurrLine
           
protected  int mCurrPtr
           
protected  int mMaxEmptyLines
           
protected  char[] mSingleCharBuf
           
protected  boolean mTrimLeading
           
protected  boolean mTrimTrailing
           
protected  java.io.Writer mWriter
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
LineSuppressWriter(java.io.Writer sink)
           
 
Method Summary
 void close()
           
 void flush()
           
 void setMaxConsequtiveEmptyLines(int max)
           
 void setTrim(boolean lead, boolean trail)
           
 void setTrimLeading(boolean state)
           
 void setTrimTrailing(boolean state)
           
 void write(char[] cbuf)
           
 void write(char[] cbuf, int off, int len)
           
 void write(int c)
           
 void write(java.lang.String str)
           
 void write(java.lang.String str, int off, int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mWriter

protected final java.io.Writer mWriter

mMaxEmptyLines

protected int mMaxEmptyLines

mTrimLeading

protected boolean mTrimLeading

mTrimTrailing

protected boolean mTrimTrailing

mCurrEmptyLines

protected int mCurrEmptyLines

mCurrLine

protected char[] mCurrLine

mCurrPtr

protected int mCurrPtr

mCurrIsEmpty

protected boolean mCurrIsEmpty

mSingleCharBuf

protected char[] mSingleCharBuf
Constructor Detail

LineSuppressWriter

public LineSuppressWriter(java.io.Writer sink)
Method Detail

setMaxConsequtiveEmptyLines

public void setMaxConsequtiveEmptyLines(int max)

setTrim

public void setTrim(boolean lead,
                    boolean trail)

setTrimLeading

public void setTrimLeading(boolean state)

setTrimTrailing

public void setTrimTrailing(boolean state)

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(char[] cbuf)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(int c)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.lang.String str)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.lang.String str,
                  int off,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException