Package com.blackrook.redis.io
Class RESPWriter
- java.lang.Object
 - 
- com.blackrook.redis.io.RESPWriter
 
 
- 
- All Implemented Interfaces:
 Closeable,AutoCloseable
public class RESPWriter extends Object implements Closeable
Writer class for writing requests to a Redis Socket.- Author:
 - Matthew Tropiano
 
 
- 
- 
Constructor Summary
Constructors Constructor Description RESPWriter(OutputStream out)Opens a RedisWriter attached to an output stream.RESPWriter(Writer out)Opens a RedisWriter attached to a writer. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidwriteArray(Iterable<Object> iterable)Writes a bulk string array.voidwriteArray(Object... objects)Writes a bulk string array.voidwriteArray(String... strings)Writes a bulk string array.voidwriteBulkString(String s)Writes a bulk string to output.protected voidwriteBulkString(String s, boolean flush)Writes a bulk string.voidwriteChar(char c)Writes a character to output.voidwriteCommand(String commandString)Writes a Redis command as though it will be executed from a REPL-like command prompt.voidwriteError(String s)Writes an error to output.voidwriteNull()Writes a null object.protected voidwriteNull(boolean flush)Writes a null object.voidwriteNullArray()Writes a null object.voidwriteNumber(Number n)Writes a number to output.protected voidwriteNumber(Number n, boolean flush)Writes a number to output.voidwriteObject(RedisObject object)Writes a full object that represents a Redis request.voidwriteRaw(String rawcontent)Writes raw content into this writer and flushes it.voidwriteSimpleString(String s)Writes a simple string to output.protected voidwriteSimpleString(String s, boolean flush)Writes a bulk string to output. 
 - 
 
- 
- 
Constructor Detail
- 
RESPWriter
public RESPWriter(OutputStream out)
Opens a RedisWriter attached to an output stream.- Parameters:
 out- theOutputStreamto use.
 
 - 
 
- 
Method Detail
- 
close
public void close() throws IOException- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Throws:
 IOException
 
- 
writeNull
public void writeNull()
Writes a null object. 
- 
writeNullArray
public void writeNullArray()
Writes a null object. 
- 
writeNumber
public void writeNumber(Number n)
Writes a number to output.- Parameters:
 n- the number to write.
 
- 
writeSimpleString
public void writeSimpleString(String s)
Writes a simple string to output.- Parameters:
 s- the string to write.
 
- 
writeBulkString
public void writeBulkString(String s)
Writes a bulk string to output.- Parameters:
 s- the string to write.
 
- 
writeArray
public void writeArray(Iterable<Object> iterable)
Writes a bulk string array.- Parameters:
 iterable- the objects to write.
 
- 
writeArray
public void writeArray(Object... objects)
Writes a bulk string array.- Parameters:
 objects- the objects to write.
 
- 
writeArray
public void writeArray(String... strings)
Writes a bulk string array.- Parameters:
 strings- the series of strings.
 
- 
writeObject
public void writeObject(RedisObject object)
Writes a full object that represents a Redis request.- Parameters:
 object- the Redis object to write.
 
- 
writeChar
public void writeChar(char c)
Writes a character to output.- Parameters:
 c- the character.
 
- 
writeError
public void writeError(String s)
Writes an error to output.- Parameters:
 s- the error string to write.
 
- 
writeCommand
public void writeCommand(String commandString)
Writes a Redis command as though it will be executed from a REPL-like command prompt. The full command is sent to the server as a raw request.- Parameters:
 commandString- the command to send to the server.
 
- 
writeRaw
public void writeRaw(String rawcontent)
Writes raw content into this writer and flushes it.- Parameters:
 rawcontent- the content to send.
 
- 
writeNull
protected void writeNull(boolean flush)
Writes a null object.- Parameters:
 flush- if true, flushes the stream.
 
- 
writeNumber
protected void writeNumber(Number n, boolean flush)
Writes a number to output.- Parameters:
 n- the number to write.flush- if true, flushes the stream.
 
- 
writeSimpleString
protected void writeSimpleString(String s, boolean flush)
Writes a bulk string to output.- Parameters:
 s- the string to write.flush- if true, flushes the stream.
 
- 
writeBulkString
protected void writeBulkString(String s, boolean flush)
Writes a bulk string.- Parameters:
 s- the string to write.flush- if true, flushes the stream.
 
 - 
 
 -