org.apache.ignite.internal.processors.rest.protocols.tcp.redis

## Class GridRedisProtocolParser

- java.lang.Object
- - org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisProtocolParser

    public class GridRedisProtocolParser
    extends Object

Parser to decode/encode Redis protocol (RESP) requests.

### Constructor Summary

Constructors
Constructor and Description
`GridRedisProtocolParser()`

### Method Summary

All Methods Static Methods Concrete Methods
`static ByteBuffer` `nil()` Creates Nil response.
`static ByteBuffer` `oKString()`
`static GridRedisMessage` `readArray(ByteBuffer buf)` Reads an array into `GridRedisMessage`.
`static String` `readBulkStr(ByteBuffer buf)` Reads a bulk string.
`static ByteBuffer` `toArray(Collection<Object> vals)` Converts a resultant collection response to an array.
`static ByteBuffer` `toArray(Map<Object,Object> vals)` Converts a resultant map response to an array.
`static ByteBuffer` `toBulkString(Object val)` Converts a resultant object to a bulk string.
`static ByteBuffer` `toGenericError(String errMsg)` Creates a generic error response.
`static ByteBuffer` `toInteger(int integer)` Converts an integer result to a RESP integer.
`static ByteBuffer` `toInteger(String integer)` Converts an integer result to a RESP integer.
`static ByteBuffer` `toSimpleString(byte[] b)` Creates a simple string data as a `ByteBuffer`.
`static ByteBuffer` `toSimpleString(String val)` Converts a simple string data to a `ByteBuffer`.
`static ByteBuffer` `toTypeError(String errMsg)` Creates an error response on operation against the wrong data type.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GridRedisProtocolParser

    public GridRedisProtocolParser()

### Method Detail

#### readArray

    public static GridRedisMessage readArray(ByteBuffer buf)
                                      throws IgniteCheckedException

Reads an array into `GridRedisMessage`.

Parameters:
  `buf` - Buffer.
Returns:
  `GridRedisMessage`.
Throws:
  `IgniteCheckedException`

#### readBulkStr

    public static String readBulkStr(ByteBuffer buf)
                              throws IgniteCheckedException

Reads a bulk string.

Parameters:
  `buf` - Buffer.
Returns:
  Bulk string.
Throws:
  `IgniteCheckedException`

#### toSimpleString

    public static ByteBuffer toSimpleString(String val)

Converts a simple string data to a `ByteBuffer`.

Parameters:
  `val` - String to be converted to a simple string.
Returns:
  Redis simple string.

#### toSimpleString

    public static ByteBuffer toSimpleString(byte[] b)

Creates a simple string data as a `ByteBuffer`.

Parameters:
  `b` - Bytes for a simple string.
Returns:
  Redis simple string.

#### oKString

    public static ByteBuffer oKString()

Returns:
  Standard OK string.

#### toGenericError

    public static ByteBuffer toGenericError(String errMsg)

Creates a generic error response.

Parameters:
  `errMsg` - Error message.
Returns:
  Error response.

#### toTypeError

    public static ByteBuffer toTypeError(String errMsg)

Creates an error response on operation against the wrong data type.

Parameters:
  `errMsg` - Error message.
Returns:
  Error response.

#### toInteger

    public static ByteBuffer toInteger(String integer)

Converts an integer result to a RESP integer.

Parameters:
  `integer` - Integer result.
Returns:
  REDIS integer.

#### toInteger

    public static ByteBuffer toInteger(int integer)

Converts an integer result to a RESP integer.

Parameters:
  `integer` - Integer result.
Returns:
  REDIS integer.

#### nil

    public static ByteBuffer nil()

Creates Nil response.

Returns:
  Nil response.

#### toBulkString

    public static ByteBuffer toBulkString(Object val)

Converts a resultant object to a bulk string.

Parameters:
  `val` - Object.
Returns:
  Bulk string.

#### toArray

    public static ByteBuffer toArray(Map<Object,Object> vals)

Converts a resultant map response to an array.

Parameters:
  `vals` - Map.
Returns:
  Array response.

#### toArray

    public static ByteBuffer toArray(Collection<Object> vals)

Converts a resultant collection response to an array.

Parameters:
  `vals` - Array elements.
Returns:
  Array response.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018