## org.codehaus.groovy.grails.web.pages
Class GSPResponseWriter

    java.lang.Object
      java.io.Writer
          java.io.PrintWriter
              org.codehaus.groovy.grails.web.pages.GSPResponseWriter

All Implemented Interfaces:
  Closeable, Flushable, Appendable

    public class GSPResponseWriter

extends PrintWriter

NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/) A buffered writer that won't commit the response until the buffer has reached the high water mark, or until flush() or close() is called.

Author:
  Troy Heninger, Graeme Rocher Date: Jan 10, 2004

Field Summary

Fields inherited from class java.io.PrintWriter
`out`

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

Method Summary
`boolean` `checkError()` Flush the stream if it's not closed and check its error state.
`void` `close()` Close the stream.
`void` `flush()` Flush the stream.
`static GSPResponseWriter` `getInstance(ServletResponse response, int max)` Static factory method to create the writer.
`static GSPResponseWriter` `getInstance(Writer target, int max)` Static factory method to create the writer.
`GSPResponseWriter` `leftShift(Object value)` Provides Groovy << left shift operator, but intercepts call to make sure nulls are converted to "" strings
`void` `print(Object obj)` Print an object.
`void` `print(String s)` Print a string.
`void` `write(char[] buf, int off, int len)` Write a portion of an array of characters.
`void` `write(int c)` Write a single character.
`void` `write(String s)` Writes a string.
`void` `write(String s, int off, int len)` Write a portion of a string.

Methods inherited from class java.io.PrintWriter
`append, append, append, append, append, append, append, append, append, format, format, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write`

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

Method Detail

### checkError

    public boolean checkError()

  Flush the stream if it's not closed and check its error state. Errors are cumulative; once the stream encounters an error, this routine will return true on all successive calls.

  Overrides:
    `checkError` in class `PrintWriter`
  Returns:
    True if the print stream has encountered an error, either on the underlying output stream or during a format conversion.

### close

    public void close()

  Close the stream.

  Specified by:
    `close` in interface `Closeable`
  Overrides:
    `close` in class `PrintWriter`
  See Also:
    `checkError()`

### flush

    public void flush()

  Flush the stream.

  Specified by:
    `flush` in interface `Flushable`
  Overrides:
    `flush` in class `PrintWriter`
  See Also:
    `checkError()`

### getInstance

    public static GSPResponseWriter getInstance(ServletResponse response,
                                                int max)

  Static factory method to create the writer.

  Parameters:
    `response` -
    `max` -
  Returns:
    A GSPResponseWriter instance

### getInstance

    public static GSPResponseWriter getInstance(Writer target,
                                                int max)

  Static factory method to create the writer.

  Parameters:
    `target` - The target writer to write too
    `max` -
  Returns:
    A GSPResponseWriter instance

### print

    public void print(Object obj)

  Print an object. The string produced by the ``String.valueOf(Object)`` method is translated into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the ``write(int)`` method.

  Overrides:
    `print` in class `PrintWriter`
  Parameters:
    `obj` - The `Object` to be printed
  See Also:
    `Object.toString()`

### print

    public void print(String s)

  Print a string. If the argument is `null` then the string `""` is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the ``write(int)`` method.

  Overrides:
    `print` in class `PrintWriter`
  Parameters:
    `s` - The `String` to be printed

### write

    public void write(String s)

  Writes a string. If the argument is `null` then the string `""` is printed.

  Overrides:
    `write` in class `PrintWriter`
  Parameters:
    `s` - The `String` to be printed

### write

    public void write(int c)

  Write a single character.

  Overrides:
    `write` in class `PrintWriter`
  Parameters:
    `c` - int specifying a character to be written.

### write

    public void write(char[] buf,
                      int off,
                      int len)

  Write a portion of an array of characters.

  Overrides:
    `write` in class `PrintWriter`
  Parameters:
    `buf` - Array of characters
    `off` - Offset from which to start writing characters
    `len` - Number of characters to write

### write

    public void write(String s,
                      int off,
                      int len)

  Write a portion of a string.

  Overrides:
    `write` in class `PrintWriter`
  Parameters:
    `s` - A String
    `off` - Offset from which to start writing characters
    `len` - Number of characters to write

### leftShift

    public GSPResponseWriter leftShift(Object value)
                                throws IOException

  Provides Groovy << left shift operator, but intercepts call to make sure nulls are converted to "" strings

  Parameters:
    `value` - The value
  Returns:
    Returns this object
  Throws:
    `IOException`

Copyright (c) 2005-2006 The Grails project