Exemplo n.º 1
0
  private T parseFirstRow(JsonParser jp, ParseState state)
      throws JsonParseException, IOException, JsonProcessingException, JsonMappingException {

    skipToField(jp, VALUE_FIELD_NAME, state);
    firstId = state.lastId;
    firstKey = state.lastKey;
    JsonNode value = null;
    if (atObjectStart(jp)) {
      value = jp.readValueAsTree();
      jp.nextToken();
      if (isEndOfRow(jp)) {
        state.docFieldName = VALUE_FIELD_NAME;
        T doc = mapper.readValue(value, type);
        endRow(jp, state);
        return doc;
      }
    }
    skipToField(jp, INCLUDED_DOC_FIELD_NAME, state);
    if (atObjectStart(jp)) {
      state.docFieldName = INCLUDED_DOC_FIELD_NAME;
      T doc = jp.readValueAs(type);
      endRow(jp, state);
      return doc;
    }
    return null;
  }
 private Object parseFirstRow(JsonParser jp, ParseState state, Class clazz)
     throws JsonParseException, IOException, JsonProcessingException, JsonMappingException {
   skipToField(jp, VALUE_FIELD_NAME, state);
   JsonNode value = null;
   if (atObjectStart(jp)) {
     value = jp.readValueAsTree();
     jp.nextToken();
     if (isEndOfRow(jp)) {
       state.docFieldName = VALUE_FIELD_NAME;
       Object doc = objectMapper.readValue(value, clazz);
       endRow(jp, state);
       return doc;
     }
   }
   skipToField(jp, INCLUDED_DOC_FIELD_NAME, state);
   if (atObjectStart(jp)) {
     state.docFieldName = INCLUDED_DOC_FIELD_NAME;
     Object doc = jp.readValueAs(clazz);
     endRow(jp, state);
     return doc;
   }
   return null;
 }