Java Code Examples for com.fasterxml.jackson.core.JsonStreamContext#getCurrentValue()
The following examples show how to use
com.fasterxml.jackson.core.JsonStreamContext#getCurrentValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ESInnerHitDeserializer.java From bboss-elasticsearch with Apache License 2.0 | 5 votes |
@Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonStreamContext jsonStreamContext = p.getParsingContext().getParent(); InnerSearchHit hit = (InnerSearchHit) jsonStreamContext.getCurrentValue(); ESClass refs = null; if(hit != null) { if (hit.getIndex() == null) { refs = getESInnerTypeReferences(hit.getType()); } else { refs = getESInnerTypeReferences(getTypeName(p)); } } if(refs == null){ return ctxt.findRootValueDeserializer(ESSerialThreadLocal.getMapObjectType()).deserialize(p,ctxt); } else { if(refs instanceof ESTypeReferences) return ctxt.findRootValueDeserializer(ESSerialThreadLocal.getJavaType(((ESTypeReferences)refs).getHitType())).deserialize(p,ctxt); else { ESClassType classType = (ESClassType)refs; return ctxt.findRootValueDeserializer(ESSerialThreadLocal.getJavaType(classType.getHitClass())).deserialize(p,ctxt); } } }
Example 2
Source File: JkesJsonSerializer.java From jkes with Apache License 2.0 | 5 votes |
private boolean willRecursive(JsonGenerator gen, JsonStreamContext ctxt, Method method) throws IOException { if (ctxt != null) { JsonStreamContext ptxt = ctxt.getParent(); while(ptxt != null) { // if(ctxt.getCurrentValue() != ptxt.getCurrentValue()) { // ptxt = ptxt.getParent(); // }else { // gen.writeEndObject(); // return; // } // if(ptxt.getCurrentValue() == null || !ctxt.getCurrentValue().getClass().equals(ptxt.getCurrentValue().getClass())) { // ptxt = ptxt.getParent(); // }else { // gen.writeEndObject(); // return; // } // String typeName = method.getGenericReturnType().getTypeName(); if(ptxt.getCurrentValue() == null || !ReflectionUtils.getInnermostType(method).equals(ptxt.getCurrentValue().getClass().getCanonicalName())) { ptxt = ptxt.getParent(); }else { return true; } } } return false; }
Example 3
Source File: MetaableJkesJsonSerializer.java From jkes with Apache License 2.0 | 5 votes |
private boolean willRecursive(JsonStreamContext ctxt, Method method) throws IOException { if (ctxt != null) { JsonStreamContext ptxt; ptxt = ctxt.getParent(); while(ptxt != null) { if(ptxt.getCurrentValue() == null || !ReflectionUtils.getInnermostType(method).equals(ptxt.getCurrentValue().getClass().getCanonicalName())) { ptxt = ptxt.getParent(); }else { return true; } } } return false; }
Example 4
Source File: EntityBeanDeserializer.java From requery with Apache License 2.0 | 5 votes |
@Override protected Object deserializeFromObjectUsingNonDefault(JsonParser p, DeserializationContext ctxt) throws IOException { JsonStreamContext parent = p.getParsingContext().getParent(); // handle embedded types if (parent != null && parent.getCurrentValue() != null) { Object value = parent.getCurrentValue(); Class<?> parentClass = value.getClass(); Method method = embeddedGetters.get(parentClass); if (method == null) { Class<?> target = getValueType().getRawClass(); for (Method m : parentClass.getDeclaredMethods()) { if (target.isAssignableFrom(m.getReturnType()) && m.getParameterTypes().length == 0) { embeddedGetters.put(parentClass, m); method = m; break; } } } if (method != null) { try { return method.invoke(value); } catch (Exception e) { throw new RuntimeException(e); } } } return super.deserializeFromObjectUsingNonDefault(p, ctxt); }
Example 5
Source File: JCalPrettyPrinter.java From biweekly with BSD 2-Clause "Simplified" License | 5 votes |
protected static boolean isInICalProperty(JsonStreamContext context) { if (context == null) { return false; } Object currentValue = context.getCurrentValue(); if (currentValue == PROPERTY_VALUE) { return true; } return isInICalProperty(context.getParent()); }