Example usage for io.vertx.core.json JsonArray addNull

List of usage examples for io.vertx.core.json JsonArray addNull

Introduction

In this page you can find the example usage for io.vertx.core.json JsonArray addNull.

Prototype

public JsonArray addNull() 

Source Link

Document

Add a null value to the JSON array.

Usage

From source file:com.groupon.vertx.redis.RedisInputStream.java

License:Apache License

/**
 * The multi-line responses will be an array containing all of the subsequent responses for the
 * multi-line response./*from  w  w  w  . jav a 2 s.co  m*/
 *
 * @param multiLine
 * @return JsonArray
 */
private JsonArray processMultiLine(byte[] multiLine) {
    if (multiLine[1] == '-') {
        return null;
    }

    JsonArray result = new JsonArray();

    int lines = processIntegerLine(multiLine);
    while (lines > 0) {
        byte[] line = completedLines.poll();
        if (line == null) {
            // Unable to find completed line for multi command
            result.addNull();
        } else if (line[0] == RedisResponseType.MULTI_BULK_REPLY.marker) {
            result.add(processMultiLine(line));
        } else if (line[0] == RedisResponseType.BULK_REPLY.marker) {
            result.add(processBulkLine(line));
        } else if (line[0] == RedisResponseType.INTEGER_REPLY.marker) {
            result.add(processIntegerLine(line));
        } else {
            result.add(processLine(line));
        }

        lines--;
    }

    return result;
}