Class GrailsPrintWriter

java.lang.Object
java.io.Writer
org.grails.buffer.GrailsPrintWriter
All Implemented Interfaces:
groovy.lang.GroovyObject, Closeable, Flushable, Appendable, AutoCloseable, GrailsWrappedWriter, EncodedAppenderWriterFactory
Direct Known Subclasses:
CodecPrintWriter, FastStringWriter, GrailsLazyProxyPrintWriter

public class GrailsPrintWriter extends Writer implements GrailsWrappedWriter, EncodedAppenderWriterFactory, groovy.lang.GroovyObject
PrintWriter implementation that doesn't have synchronization. null object references are ignored in print methods (nothing gets printed)
  • Field Details

    • logger

      protected static final org.apache.commons.logging.Log logger
    • CRLF

      protected static final char[] CRLF
    • trouble

      protected boolean trouble
    • out

      protected Writer out
    • allowUnwrappingOut

      protected boolean allowUnwrappingOut
    • usageFlag

      protected boolean usageFlag
    • streamCharBufferTarget

      protected Writer streamCharBufferTarget
    • previousOut

      protected Writer previousOut
  • Constructor Details

    • GrailsPrintWriter

      public GrailsPrintWriter(Writer out)
  • Method Details

    • isAllowUnwrappingOut

      public boolean isAllowUnwrappingOut()
      Specified by:
      isAllowUnwrappingOut in interface GrailsWrappedWriter
    • unwrap

      public Writer unwrap()
      Specified by:
      unwrap in interface GrailsWrappedWriter
    • isDestinationActivated

      public boolean isDestinationActivated()
    • getOut

      public Writer getOut()
    • setOut

      public void setOut(Writer newOut)
    • unwrapWriter

      protected Writer unwrapWriter(Writer writer)
    • leftShift

      public GrailsPrintWriter leftShift(Object obj) throws IOException
      Provides Groovy << left shift operator, but intercepts call to make sure nulls are converted to "" strings
      Parameters:
      obj - The value
      Returns:
      Returns this object
      Throws:
      IOException
    • plus

      public GrailsPrintWriter plus(Object value) throws IOException
      Throws:
      IOException
    • 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.
      Returns:
      true if the print stream has encountered an error, either on the underlying output stream or during a format conversion.
    • setError

      public void setError()
    • flush

      public void flush()
      Flush the stream.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class Writer
      See Also:
    • 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.
      Parameters:
      obj - The Object to be printed
      See Also:
    • 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.
      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 Writer
      Parameters:
      s - The String to be printed
    • write

      public void write(int c)
      Write a single character.
      Overrides:
      write in class Writer
      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.
      Specified by:
      write in class Writer
      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 Writer
      Parameters:
      s - A String
      off - Offset from which to start writing characters
      len - Number of characters to write
    • write

      public void write(char[] buf)
      Overrides:
      write in class Writer
    • print

      public void print(boolean b)
      delegate methods, not synchronized
    • print

      public void print(char c)
    • print

      public void print(int i)
    • print

      public void print(long l)
    • print

      public void print(float f)
    • print

      public void print(double d)
    • print

      public void print(char[] s)
    • println

      public void println()
    • println

      public void println(boolean b)
    • println

      public void println(char c)
    • println

      public void println(int i)
    • println

      public void println(long l)
    • println

      public void println(float f)
    • println

      public void println(double d)
    • println

      public void println(char[] c)
    • println

      public void println(String s)
    • println

      public void println(Object o)
    • append

      public GrailsPrintWriter append(char c)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
    • append

      public GrailsPrintWriter append(CharSequence csq, int start, int end)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
    • appendNullCharSequence

      protected void appendNullCharSequence() throws IOException
      Throws:
      IOException
    • append

      public GrailsPrintWriter append(CharSequence csq)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
    • append

      public GrailsPrintWriter append(Object obj)
    • clone

      protected Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • write

      public void write(StreamCharBuffer otherBuffer)
    • findStreamCharBufferTarget

      protected Writer findStreamCharBufferTarget(boolean markUsed)
    • print

      public void print(StreamCharBuffer otherBuffer)
    • append

      public void append(StreamCharBuffer otherBuffer)
    • println

      public void println(StreamCharBuffer otherBuffer)
    • leftShift

      public GrailsPrintWriter leftShift(StreamCharBuffer otherBuffer)
    • write

      public void write(groovy.lang.Writable writable)
    • writeWritable

      protected void writeWritable(groovy.lang.Writable writable)
    • print

      public void print(groovy.lang.Writable writable)
    • leftShift

      public GrailsPrintWriter leftShift(groovy.lang.Writable writable)
    • print

      public void print(org.codehaus.groovy.runtime.GStringImpl gstring)
    • leftShift

      public GrailsPrintWriter leftShift(org.codehaus.groovy.runtime.GStringImpl gstring)
    • leftShift

      public GrailsPrintWriter leftShift(String string)
    • isUsed

      public boolean isUsed()
    • setUsed

      public void setUsed(boolean newUsed)
    • resetUsed

      public boolean resetUsed()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
    • markUsed

      public void markUsed()
      Specified by:
      markUsed in interface GrailsWrappedWriter
    • asType

      public Object asType(Class<?> clazz)
    • asPrintWriter

      public PrintWriter asPrintWriter()
    • getWriterForEncoder

      public Writer getWriterForEncoder(Encoder encoder, EncodingStateRegistry encodingStateRegistry)
      Description copied from interface: EncodedAppenderWriterFactory
      Gets the EncodedAppenderWriter instance that is connected to this instance implementation with a certain encoder fixed.
      Specified by:
      getWriterForEncoder in interface EncodedAppenderWriterFactory
      Parameters:
      encoder - the encoder to use
      encodingStateRegistry - the current EncodingStateRegistry to use
      Returns:
      the java.io.Writer instance
    • getProperty

      public Object getProperty(String property)
      Specified by:
      getProperty in interface groovy.lang.GroovyObject
    • setProperty

      public void setProperty(String property, Object newValue)
      Specified by:
      setProperty in interface groovy.lang.GroovyObject
    • invokeMethod

      public Object invokeMethod(String name, Object args)
      Specified by:
      invokeMethod in interface groovy.lang.GroovyObject
    • getMetaClass

      public groovy.lang.MetaClass getMetaClass()
      Specified by:
      getMetaClass in interface groovy.lang.GroovyObject
    • setMetaClass

      public void setMetaClass(groovy.lang.MetaClass metaClass)
      Specified by:
      setMetaClass in interface groovy.lang.GroovyObject