Class ResponseWriter
- java.lang.Object
-
- java.io.Writer
-
- java.io.FilterWriter
-
- com.tagtraum.beatunes.remotecontrol.ResponseWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class ResponseWriter extends FilterWriter
Writer that defaults to sending a JSON-formatted OK message, unless something else is written beforeflush()
. It is recommended to write a message that contains at least the itemsrequest
andstatus
like this:{"request":"audioplayer.pause.play","status":"ok"}
. The original request is accessible viaConnection.getRequest()
.- Author:
- Hendrik Schreiber
-
-
Field Summary
-
Fields inherited from class java.io.FilterWriter
out
-
-
Constructor Summary
Constructors Constructor Description ResponseWriter(String request, Writer out, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
int
getBufferSize()
Size of the buffer.boolean
isCommitted()
Indicates whether content has already been written to the client (flushed).boolean
isEmpty()
Indicates whether anything has been written with this writer.void
write(char[] cbuf, int off, int len)
void
write(int c)
void
write(String str, int off, int len)
-
Methods inherited from class java.io.FilterWriter
close
-
-
-
-
Method Detail
-
write
public void write(int c) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
isCommitted
public boolean isCommitted()
Indicates whether content has already been written to the client (flushed).- Returns:
- true or false
-
isEmpty
public boolean isEmpty()
Indicates whether anything has been written with this writer. This does not necessarily mean that the content has also been flushed.- Returns:
- true or false
-
getBufferSize
public int getBufferSize()
Size of the buffer.- Returns:
- buffer size
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterWriter
- Throws:
IOException
-
-