private static <T> T withCache(DeserializationContext context, Function<DeserializerStringCache, T> consumer) { DeserializerStringCache cache = (DeserializerStringCache) context.getAttribute(ATTR_STRING_CACHE); return consumer.apply(cache); }
@Override public Event deserialize(JsonParser jp, DeserializationContext ctx) throws IOException { Object project = ctx.getAttribute("project"); Object masterKey = ctx.getAttribute("master_key"); return deserializeWithProject( jp, project != null ? project.toString() : null, null, Boolean.TRUE.equals(masterKey)); }
@Override public EventList deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { String project = (String) ctxt.getAttribute("project"); String collection = (String) ctxt.getAttribute("collection"); String apiKey = (String) ctxt.getAttribute("apiKey"); boolean useheader = Boolean.FALSE != ctxt.getAttribute("useHeader");
context = jp.readValueAs(Event.EventContext.class); } else if (fieldName.equals("events")) { InputStream stream = (InputStream) deserializationContext.getAttribute("stream"); eventsBuffer = jp.readValueAs(TokenBuffer.class); } else {
Object apiKey = deserializationContext.getAttribute("apiKey"); String project = null; boolean masterKey = false;
public class SystemIdDeserializer extends StdDeserializer<Long> { public SystemIdDeserializer() { super(Long.class); } @Override public Long deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { SystemIdProvider systemIdProvider = (SystemIdProvider) ctxt.getAttribute("systemIdProvider"); Long oldSystemId = _parseLong(jp, ctxt); return systemIdProvider.getNewSystemId(oldSystemId); } }
private static <T> T withCache(DeserializationContext context, Function<DeserializerStringCache, T> consumer) { DeserializerStringCache cache = (DeserializerStringCache) context.getAttribute(ATTR_STRING_CACHE); return consumer.apply(cache); }
@Override public AbstractPropertyValue getNullValue(DeserializationContext ctxt) throws JsonMappingException { if (ctxt.getAttribute(ConditionalAttributes.REST) != null && RestMapper.PATCH.equals(RestMapper.REQUEST_OPERATION.get())) { try { AbstractPropertyValue instance = (AbstractPropertyValue) RestMapper.NULL_INSTANCES.get(ScalarPropertyValue.class); if (instance == null) { instance = ScalarPropertyValue.class.getConstructor().newInstance(); } RestMapper.NULL_INSTANCES.put(ScalarPropertyValue.class, instance); return instance; } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { } } return super.getNullValue(ctxt); } }
protected ValueNode deserializeValueNode(JsonParser p, DeserializationContext context, JsonLocation startLocation) throws IOException { final Model model = (Model) context.getAttribute(ATTRIBUTE_MODEL); final AbstractNode parent = (AbstractNode) context.getAttribute(ATTRIBUTE_PARENT); final JsonPointer ptr = (JsonPointer) context.getAttribute(ATTRIBUTE_POINTER); Object v = context.readValue(p, Object.class); ValueNode node = model.valueNode(parent, ptr, v); node.setStartLocation(createLocation(startLocation)); node.setEndLocation(createLocation(p.getCurrentLocation())); return node; }
protected ObjectNode deserializeObjectNode(JsonParser p, DeserializationContext context, JsonLocation startLocation) throws IllegalArgumentException, IOException { final Model model = (Model) context.getAttribute(ATTRIBUTE_MODEL); final AbstractNode parent = (AbstractNode) context.getAttribute(ATTRIBUTE_PARENT); final JsonPointer ptr = (JsonPointer) context.getAttribute(ATTRIBUTE_POINTER); final ObjectNode node = model.objectNode(parent, ptr); node.setStartLocation(createLocation(startLocation)); while (p.nextToken() != JsonToken.END_OBJECT) { String name = p.getCurrentName(); JsonPointer pp = JsonPointer.compile(ptr.toString() + "/" + name.replaceAll("/", "~1")); context.setAttribute(ATTRIBUTE_PARENT, node); context.setAttribute(ATTRIBUTE_POINTER, pp); AbstractNode v = deserialize(p, context); v.setProperty(name); node.put(name, v); } node.setEndLocation(createLocation(p.getCurrentLocation())); return node; }
protected ArrayNode deserializeArrayNode(JsonParser p, DeserializationContext context, JsonLocation startLocation) throws IOException { final Model model = (Model) context.getAttribute(ATTRIBUTE_MODEL); final AbstractNode parent = (AbstractNode) context.getAttribute(ATTRIBUTE_PARENT); final JsonPointer ptr = (JsonPointer) context.getAttribute(ATTRIBUTE_POINTER); ArrayNode node = model.arrayNode(parent, ptr); int i = 0; while (p.nextToken() != JsonToken.END_ARRAY) { JsonPointer pp = JsonPointer.compile(ptr.toString() + "/" + i); context.setAttribute(ATTRIBUTE_PARENT, node); context.setAttribute(ATTRIBUTE_POINTER, pp); AbstractNode v = deserialize(p, context); node.add(v); i++; } node.setStartLocation(createLocation(startLocation)); node.setEndLocation(createLocation(p.getCurrentLocation())); return node; }