Class SerializerPipe

java.lang.Object
org.apache.juneau.serializer.SerializerPipe
All Implemented Interfaces:
Closeable, AutoCloseable

public final class SerializerPipe extends Object implements Closeable
A wrapper around an object that a serializer sends its output to.

For character-based serializers, the output object can be any of the following:

For stream-based serializers, the output object can be any of the following:

See Also:
  • Method Details

    • getOutputStream

      Wraps the specified output object inside an output stream.

      Subclasses can override this method to implement their own specialized output streams.

      This method can be used if the output object is any of the following class types:

      Returns:
      The output object wrapped in an output stream. Calling OutputStream.close() on the returned object simply flushes the response and does not close the underlying stream.
      Throws:
      IOException - If object could not be converted to an output stream.
    • getWriter

      Wraps the specified output object inside a writer.

      Subclasses can override this method to implement their own specialized writers.

      This method can be used if the output object is any of the following class types:

      • Writer
      • OutputStream - Output will be written as UTF-8 encoded stream.
      • File - Output will be written as system-default encoded stream.
      Returns:
      The output object wrapped in a writer. Calling Writer.close() on the returned object simply flushes the response and does not close the underlying writer.
      Throws:
      SerializeException - If object could not be converted to a writer.
    • setWriter

      public void setWriter(Writer writer)
      Overwrites the writer in this pipe.

      Used when wrapping the writer returned by getWriter() so that the wrapped writer will be flushed and closed when close() is called.

      Parameters:
      writer - The wrapped writer.
    • setOutputStream

      public void setOutputStream(OutputStream outputStream)
      Overwrites the output stream in this pipe.

      Used when wrapping the stream returned by getOutputStream() so that the wrapped stream will be flushed when close() is called.

      Parameters:
      outputStream - The wrapped stream.
    • getRawOutput

      public Object getRawOutput()
      Returns the raw output object passed into this session.
      Returns:
      The raw output object passed into this session.
    • close

      public void close()
      Closes the output pipe.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable