frysk.util
Class WordWrapWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by frysk.util.WordWrapWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class WordWrapWriter
extends PrintWriter

This class is a PrintWriter which word-wraps the output. It provides settings which control over the number of columns and indentation of wrapped lines.


Constructor Summary
WordWrapWriter(Writer outStream)
          Create a new WordWrapWriter using the defaults.
WordWrapWriter(Writer outStream, int columns)
          Create a new WordWrapWriter, specifying just the number of columns.
WordWrapWriter(Writer outStream, int columns, int wrapIndent, Locale locale)
          Create a new WordWrapWriter, specifying all parameters.
 
Method Summary
 void setColumns(int columns)
          Set the number of columns of output.
 void setWrapIndent(int wrapIndent)
          Set the amount of indentation after wrapping.
 void setWrapIndentFromColumn()
          Like setWrapIndent(int), but sets the indentation column based on the current column known to this writer.
 void write(char[] buf, int offset, int len)
           
 void write(int b)
           
 void write(String str, int offset, int len)
           
 
Methods inherited from class java.io.PrintWriter
append, append, append, append, append, append, append, append, append, checkError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordWrapWriter

public WordWrapWriter(Writer outStream,
                      int columns,
                      int wrapIndent,
                      Locale locale)
Create a new WordWrapWriter, specifying all parameters.

Parameters:
outStream - the output writer to wrap
columns - the number of columns to allow before wrapping
wrapIndent - the number of columns to indent after wrapping
locale - the locale to use for determining word breaks

WordWrapWriter

public WordWrapWriter(Writer outStream,
                      int columns)
Create a new WordWrapWriter, specifying just the number of columns. By default there will be no indentation after a wrap, and the default locale will be used.

Parameters:
outStream - the output writer to wrap
columns - the number of columns to allow before wrapping

WordWrapWriter

public WordWrapWriter(Writer outStream)
Create a new WordWrapWriter using the defaults. Wrapping will happen at column 72. By default there will be no indentation after a wrap, and the default locale will be used.

Parameters:
outStream - the output writer to wrap
Method Detail

setColumns

public void setColumns(int columns)
Set the number of columns of output. The writer will try to break a line before a word that would go past this column.

Parameters:
columns - the number of columns to allow before wrapping

setWrapIndent

public void setWrapIndent(int wrapIndent)
Set the amount of indentation after wrapping. This can be used to line up some text if it wraps past the end of the line. Indentation is accomplished by emitting spaces. Tabs in the output are considered to move to the next column that is a multiple of 8 ("unix style"). An argument of 0 means that no indentation will be applied after wrapping.

Parameters:
wrapIndent - the number of columns to indent after wrapping

setWrapIndentFromColumn

public void setWrapIndentFromColumn()
Like setWrapIndent(int), but sets the indentation column based on the current column known to this writer. This can be useful for aligning text when the precise formatting is not known -- you can emit a prefix for a line, mark the indentation level, and then emit the remainder of the text, which will all line up at the marked position.


write

public void write(char[] buf,
                  int offset,
                  int len)
Overrides:
write in class PrintWriter

write

public void write(int b)
Overrides:
write in class PrintWriter

write

public void write(String str,
                  int offset,
                  int len)
Overrides:
write in class PrintWriter