/** * Method for constructing a new reader instance with configuration that uses * passed {@link JsonFactory} for constructing underlying Readers. *<p> * NOTE: only factories that <b>DO NOT REQUIRE SPECIAL MAPPERS</b> * (that is, ones that return <code>false</code> for * {@link JsonFactory#requiresCustomCodec()}) can be used: trying * to use one that requires custom codec will throw exception * * @since 2.1 */ public ObjectReader with(JsonFactory f) { if (f == _parserFactory) { return this; } ObjectReader r = _new(this, f); // Also, try re-linking, if possible... if (f.getCodec() == null) { f.setCodec(r); } return r; }
} else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this);
@Override public Object evaluate(Class<?> type) { try { return mapper.readValue(valueNode.traverse(mapper.getFactory().getCodec()), type); } catch (Exception o_O) { throw new PatchException(String.format("Could not read %s into %s!", valueNode, type), o_O); } } }
@Override public Object evaluate(Class<?> type) { try { return mapper.readValue(valueNode.traverse(mapper.getFactory().getCodec()), type); } catch (Exception o_O) { throw new PatchException(String.format("Could not read %s into %s!", valueNode, type), o_O); } } }
@Override public Reference deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = objectMapper.getFactory().setCodec(objectMapper).getCodec().readTree(jp); String spanIdHex = node.get("spanID").asText(); Reference reference = new Reference(); reference.setSpanId(new BigInteger(spanIdHex, 16).longValue()); return reference; } }
@Override public KeyValue deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = objectMapper.getFactory().setCodec(objectMapper).getCodec().readTree(jp); String key = node.get("key").asText(); String type = node.get("type").asText(); KeyValue keyValue = new KeyValue(); keyValue.setKey(key); keyValue.setValueType(type); if ("string".equalsIgnoreCase(type)) { keyValue.setValueString(node.get("value").asText()); } return keyValue; } }
/** * Method for constructing a new reader instance with configuration that uses * passed {@link JsonFactory} for constructing underlying Readers. *<p> * NOTE: only factories that <b>DO NOT REQUIRE SPECIAL MAPPERS</b> * (that is, ones that return <code>false</code> for * {@link JsonFactory#requiresCustomCodec()}) can be used: trying * to use one that requires custom codec will throw exception * * @since 2.1 */ public ObjectReader with(JsonFactory f) { if (f == _parserFactory) { return this; } ObjectReader r = _new(this, f); // Also, try re-linking, if possible... if (f.getCodec() == null) { f.setCodec(r); } return r; }
/** * Method for constructing a new reader instance with configuration that uses * passed {@link JsonFactory} for constructing underlying Readers. *<p> * NOTE: only factories that <b>DO NOT REQUIRE SPECIAL MAPPERS</b> * (that is, ones that return <code>false</code> for * {@link JsonFactory#requiresCustomCodec()}) can be used: trying * to use one that requires custom codec will throw exception * * @since 2.1 */ public ObjectReader with(JsonFactory f) { if (f == _jsonFactory) { return this; } ObjectReader r = new ObjectReader(this, f); // Also, try re-linking, if possible... if (f.getCodec() == null) { f.setCodec(r); } return r; }
/** * Method for constructing a new reader instance with configuration that uses * passed {@link JsonFactory} for constructing underlying Readers. *<p> * NOTE: only factories that <b>DO NOT REQUIRE SPECIAL MAPPERS</b> * (that is, ones that return <code>false</code> for * {@link JsonFactory#requiresCustomCodec()}) can be used: trying * to use one that requires custom codec will throw exception * * @since 2.1 */ public ObjectReader with(JsonFactory f) { if (f == _parserFactory) { return this; } ObjectReader r = _new(this, f); // Also, try re-linking, if possible... if (f.getCodec() == null) { f.setCodec(r); } return r; }
@Override public Span deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = objectMapper.getFactory().setCodec(objectMapper).getCodec().readTree(jp); String spanIdHex = node.get("spanID").asText(); String traceIdHex = node.get("traceID").asText(); String startTimeStr = node.get("startTime").asText(); JsonNode processNode = node.get("process"); Process process = objectMapper.treeToValue(processNode, Process.class); JsonNode tagsNode = node.get("tags"); List<KeyValue> tags = Arrays.asList(objectMapper.treeToValue(tagsNode, KeyValue[].class)); JsonNode tagFieldsNode = node.get("tag"); if (tagFieldsNode != null) { Map<String, Object> tagFields = objectMapper.treeToValue(tagFieldsNode, Map.class); tags = addTagFields(tags, tagFields); } Span span = new Span(); span.setSpanId(new BigInteger(spanIdHex, 16).longValue()); span.setTraceId(traceIdHex); span.setRefs(deserializeReferences(node)); span.setStartTime(startTimeStr != null ? Long.parseLong(startTimeStr) : null); span.setProcess(process); span.setTags(tags); return span; }
/** * Method for constructing a new reader instance with configuration that uses * passed {@link JsonFactory} for constructing underlying Readers. *<p> * NOTE: only factories that <b>DO NOT REQUIRE SPECIAL MAPPERS</b> * (that is, ones that return <code>false</code> for * {@link JsonFactory#requiresCustomCodec()}) can be used: trying * to use one that requires custom codec will throw exception * * @since 2.1 */ public ObjectReader with(JsonFactory f) { if (f == _parserFactory) { return this; } ObjectReader r = _new(this, f); // Also, try re-linking, if possible... if (f.getCodec() == null) { f.setCodec(r); } return r; }
/** * Method for constructing a new reader instance with configuration that uses * passed {@link JsonFactory} for constructing underlying Readers. *<p> * NOTE: only factories that <b>DO NOT REQUIRE SPECIAL MAPPERS</b> * (that is, ones that return <code>false</code> for * {@link JsonFactory#requiresCustomCodec()}) can be used: trying * to use one that requires custom codec will throw exception * * @since 2.1 */ public ObjectReader with(JsonFactory f) { if (f == _parserFactory) { return this; } ObjectReader r = _new(this, f); // Also, try re-linking, if possible... if (f.getCodec() == null) { f.setCodec(r); } return r; }
private JsonNode getResultsNode(long count) { try{ TokenBuffer out = new TokenBuffer(MAPPER.getFactory().getCodec(), false); JsonOutput json = new ExtendedJsonOutput(out); json.writeStartArray(); json.writeStartObject(); json.writeFieldName("count"); json.writeBigInt(count); json.writeEndObject(); json.writeEndArray(); json.flush(); return out.asParser().readValueAsTree(); }catch(IOException ex){ throw Throwables.propagate(ex); } }
private static JsonNode convertToJsonNode(RelDataType rowType, ImmutableList<ImmutableList<RexLiteral>> tuples) throws IOException{ TokenBuffer out = new TokenBuffer(MAPPER.getFactory().getCodec(), false); JsonOutput json = new ExtendedJsonOutput(out); json.writeStartArray(); String[] fields = rowType.getFieldNames().toArray(new String[rowType.getFieldCount()]); for(List<RexLiteral> row : tuples){ json.writeStartObject(); int i =0; for(RexLiteral field : row){ json.writeFieldName(fields[i]); writeLiteral(field, json); i++; } json.writeEndObject(); } json.writeEndArray(); json.flush(); return out.asParser().readValueAsTree(); }
private static JsonNode convertToJsonNode(RelDataType rowType, List<? extends List<RexLiteral>> tuples) throws IOException { TokenBuffer out = new TokenBuffer(MAPPER.getFactory().getCodec(), false); JsonOutput json = new ExtendedJsonOutput(out); json.writeStartArray(); String[] fields = rowType.getFieldNames().toArray(new String[rowType.getFieldCount()]); for (List<RexLiteral> row : tuples) { json.writeStartObject(); int i = 0; for (RexLiteral field : row) { json.writeFieldName(fields[i]); writeLiteral(field, json); i++; } json.writeEndObject(); } json.writeEndArray(); json.flush(); return out.asParser().readValueAsTree(); }
} else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this);
} else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this);
} else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this);
} else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this);
} else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this);