public final class SerializerPipe extends Object implements Closeable
For character-based serializers, the output object can be any of the following:
Writer
OutputStream
- Output will be written as UTF-8 encoded stream.
File
- Output will be written as system-default encoded stream.
StringBuilder
For stream-based serializers, the output object can be any of the following:
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the output pipe.
|
OutputStream |
getOutputStream()
Wraps the specified output object inside an output stream.
|
Object |
getRawOutput()
Returns the raw output object passed into this session.
|
Writer |
getWriter()
Wraps the specified output object inside a writer.
|
void |
setOutputStream(OutputStream outputStream)
Overwrites the output stream in this pipe.
|
void |
setWriter(Writer writer)
Overwrites the writer in this pipe.
|
public OutputStream getOutputStream() throws IOException
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:
OutputStream.close()
on the returned object simply flushes the response and does not close
the underlying stream.IOException
- If object could not be converted to an output stream.public Writer getWriter() throws IOException
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.
Writer.close()
on the returned object simply flushes the response and does not close
the underlying writer.IOException
- If object could not be converted to a writer.public void setWriter(Writer writer)
Used when wrapping the writer returned by getWriter()
so that the wrapped writer will be flushed
and closed when close()
is called.
writer
- The wrapped writer.public void setOutputStream(OutputStream outputStream)
Used when wrapping the stream returned by getOutputStream()
so that the wrapped stream will be flushed
when close()
is called.
outputStream
- The wrapped stream.public Object getRawOutput()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.