コード例 #1
0
  public WriteRequest unmarshall(JsonUnmarshallerContext context) throws Exception {
    WriteRequest writeRequest = new WriteRequest();

    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    JsonToken token = context.currentToken;
    if (token == null) token = context.nextToken();

    while (true) {
      if (token == null) break;

      if (token == FIELD_NAME || token == START_OBJECT) {
        if (context.testExpression("PutRequest", targetDepth)) {
          context.nextToken();
          writeRequest.setPutRequest(PutRequestJsonUnmarshaller.getInstance().unmarshall(context));
        }
        if (context.testExpression("DeleteRequest", targetDepth)) {
          context.nextToken();
          writeRequest.setDeleteRequest(
              DeleteRequestJsonUnmarshaller.getInstance().unmarshall(context));
        }
      } else if (token == END_ARRAY || token == END_OBJECT) {
        if (context.getCurrentDepth() <= originalDepth) break;
      }

      token = context.nextToken();
    }

    return writeRequest;
  }