com.lambdaworks.redis.protocol
Class CommandOutput<K,V,T>

java.lang.Object
  extended by com.lambdaworks.redis.protocol.CommandOutput<K,V,T>
Type Parameters:
T - Output type.
Direct Known Subclasses:
BooleanListOutput, BooleanOutput, ByteArrayOutput, DateOutput, DoubleOutput, IntegerOutput, KeyListOutput, KeyOutput, KeyValueOutput, MapOutput, MultiOutput, NestedMultiOutput, PubSubOutput, ScoredValueListOutput, StatusOutput, StringListOutput, ValueListOutput, ValueOutput, ValueSetOutput

public abstract class CommandOutput<K,V,T>
extends Object

Abstract representation of the output of a redis command.

Author:
Will Glozer

Field Summary
protected  RedisCodec<K,V> codec
           
protected  String error
           
protected  T output
           
 
Constructor Summary
CommandOutput(RedisCodec<K,V> codec, T output)
          Initialize a new instance that encodes and decodes keys and values using the supplied codec.
 
Method Summary
 void complete(int depth)
          Mark the command output complete.
protected  String decodeAscii(ByteBuffer bytes)
           
 T get()
          Get the command output.
 String getError()
          Get the error that occurred.
 boolean hasError()
          Check if the command resulted in an error.
 void set(ByteBuffer bytes)
          Set the command output to a sequence of bytes, or null.
 void set(long integer)
          Set the command output to a 64-bit signed integer.
 void setError(ByteBuffer error)
          Set command output to an error message from the server.
 void setError(String error)
          Set command output to an error message from the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codec

protected RedisCodec<K,V> codec

output

protected T output

error

protected String error
Constructor Detail

CommandOutput

public CommandOutput(RedisCodec<K,V> codec,
                     T output)
Initialize a new instance that encodes and decodes keys and values using the supplied codec.

Parameters:
codec - Codec used to encode/decode keys and values.
output - Initial value of output.
Method Detail

get

public T get()
Get the command output.

Returns:
The command output.

set

public void set(ByteBuffer bytes)
Set the command output to a sequence of bytes, or null. Concrete CommandOutput implementations must override this method unless they only receive an integer value which cannot be null.

Parameters:
bytes - The command output, or null.

set

public void set(long integer)
Set the command output to a 64-bit signed integer. Concrete CommandOutput implementations must override this method unless they only receive a byte array value.

Parameters:
integer - The command output.

setError

public void setError(ByteBuffer error)
Set command output to an error message from the server.

Parameters:
error - Error message.

setError

public void setError(String error)
Set command output to an error message from the client.

Parameters:
error - Error message.

hasError

public boolean hasError()
Check if the command resulted in an error.

Returns:
true if command resulted in an error.

getError

public String getError()
Get the error that occurred.

Returns:
The error.

complete

public void complete(int depth)
Mark the command output complete.

Parameters:
depth - Remaining depth of output queue.

decodeAscii

protected String decodeAscii(ByteBuffer bytes)


Copyright © 2013. All Rights Reserved.