Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javatest.util
Class WrapWriter

    java.lang.Object
      java.io.Writer
          com.sun.javatest.util.WrapWriter

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable, java.lang.Appendable

    public class WrapWriter

extends java.io.Writer

A writer that will automatically word wrap lines to fit within left and right margins.

Field Summary

Fields inherited from class java.io.Writer
`lock`

Constructor Summary
`WrapWriter(java.io.OutputStream out)` Create a WrapWriter object that will write to a given stream.
`WrapWriter(java.io.Writer out)` Create a WrapWriter object that will write to a given stream.

Method Summary
`void` | `close()`
`void` | `flush()`
`int` | `getCharsOnLineSoFar()` Get the number of characters that have been written so far on the current line.
`int` | `getLeftMargin()` Get the position for the left margin for the text stream.
`int` | `getRightMargin()` Get the position for the right margin for the text stream.
`void` | `setLeftMargin(int m)` Set the position for the left margin for the text stream.
`void` | `setRightMargin(int m)` Set the position for the right margin for the text stream.
`void` | `write(char c)` Write a character to the stream.
`void` | `write(char[] cbuf, int off, int len)`

Methods inherited from class java.io.Writer
`append, append, append, write, write, write, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WrapWriter

    public WrapWriter(java.io.OutputStream out)

  Create a WrapWriter object that will write to a given stream.

  Parameters:
    `out` - the stream to which the WrapWriter will write

### WrapWriter

    public WrapWriter(java.io.Writer out)

  Create a WrapWriter object that will write to a given stream.

  Parameters:
    `out` - the stream to which the WrapWriter will write

Method Detail

### setLeftMargin

    public void setLeftMargin(int m)

  Set the position for the left margin for the text stream.

  Parameters:
    `m` - the position for the left margin
  Throws:
    `java.lang.IllegalArgumentException` - if the value is negative or greater than the current value of the right margin
  See Also:
    `getLeftMargin()`

### getLeftMargin

    public int getLeftMargin()

  Get the position for the left margin for the text stream.

  Returns:
    the position for the left margin
  See Also:
    `setLeftMargin(int)`

### setRightMargin

    public void setRightMargin(int m)

  Set the position for the right margin for the text stream.

  Parameters:
    `m` - the position for the right margin
  Throws:
    `java.lang.IllegalArgumentException` - if the value is less than the current value of the left margin
  See Also:
    `getRightMargin()`

### getRightMargin

    public int getRightMargin()

  Get the position for the right margin for the text stream.

  Returns:
    the position for the right margin
  See Also:
    `setRightMargin(int)`

### getCharsOnLineSoFar

    public int getCharsOnLineSoFar()

  Get the number of characters that have been written so far on the current line. This will not include any characters in the last word that have not yet been written. Use flush() or write a white space character to force out the last word written.

  Returns:
    the number of characters that have been written so far on the line

### close

    public void close()
               throws java.io.IOException

  Specified by:
    `close` in interface `java.io.Closeable`
  Specified by:
    `close` in class `java.io.Writer`
  Throws:
    `java.io.IOException`

### flush

    public void flush()
               throws java.io.IOException

  Specified by:
    `flush` in interface `java.io.Flushable`
  Specified by:
    `flush` in class `java.io.Writer`
  Throws:
    `java.io.IOException`

### write

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

  Specified by:
    `write` in class `java.io.Writer`
  Throws:
    `java.io.IOException`

### write

    public void write(char c)
               throws java.io.IOException

  Write a character to the stream. Non-white-space characters will be buffered until a white space character is written. When a white space character is written, the buffered characters will be written on the current line, if they will fit before the right margin, otherwise a newline and spaces will be inserted so that the buffered characters appear on the next line starting at the left margin.

  Parameters:
    `c` - the character to be written
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.