本文整理汇总了Java中com.fasterxml.jackson.core.JsonStreamContext.getCurrentValue方法的典型用法代码示例。如果您正苦于以下问题:Java JsonStreamContext.getCurrentValue方法的具体用法?Java JsonStreamContext.getCurrentValue怎么用?Java JsonStreamContext.getCurrentValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonStreamContext
的用法示例。
在下文中一共展示了JsonStreamContext.getCurrentValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOnType
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
/** Get type for "on" values that are plain URIs by deducing the type from their parent. */
private String getOnType(DeserializationContext ctxt) {
// Easiest way: The parser has already constructed an annotation object with a motivation.
// This is highly dependendant on the order of keys in the JSON, i.e. if "on" is the first key in the annotation
// object, this won't work.
Object curVal = ctxt.getParser().getCurrentValue();
boolean isPaintingAnno = (curVal != null && curVal instanceof Annotation &&
((Annotation) curVal).getMotivation() != null &&
((Annotation) curVal).getMotivation().equals(Motivation.PAINTING));
if (isPaintingAnno) {
return "sc:Canvas";
}
// More reliable way: Walk up the parsing context until we hit a IIIF resource that we can deduce the type from
// Usually this shouldn't be more than two levels up
JsonStreamContext parent = ctxt.getParser().getParsingContext().getParent();
while (parent != null && (parent.getCurrentValue() == null || !(parent.getCurrentValue() instanceof Resource))) {
parent = parent.getParent();
}
if (parent != null) {
Resource parentObj = (Resource) parent.getCurrentValue();
return parentObj.getType();
}
return null;
}
示例2: getPath
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
private Path getPath(PropertyWriter writer, JsonStreamContext sc) {
LinkedList<PathElement> elements = new LinkedList<>();
if (sc != null) {
elements.add(new PathElement(writer.getName(), sc.getCurrentValue()));
sc = sc.getParent();
}
while (sc != null) {
if (sc.getCurrentName() != null && sc.getCurrentValue() != null) {
elements.addFirst(new PathElement(sc.getCurrentName(), sc.getCurrentValue()));
}
sc = sc.getParent();
}
return new Path(elements);
}
示例3: willRecursive
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
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;
}
示例4: willRecursive
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
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;
}
示例5: mapNearestDruidQuery
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
/**
* JSON tree walk to find the druid query context of the current context and apply handler to the DruidQuery,
* finds the current context if current context is a druid query.
*
* @param gen the Json Generator to retrieve the tree to walk on.
* @param mapper a function that takes an DruidQuery as an argument and return the final desired returned result.
* @param <T> Type of result from the mapper
*
* @return an Optional of the desired result T if DruidQuery is found, Optional.empty otherwise
*/
public static <T> Optional<T> mapNearestDruidQuery(JsonGenerator gen, Function<DruidQuery, T> mapper) {
JsonStreamContext context = gen.getOutputContext();
while (context != null) {
Object parent = context.getCurrentValue();
if (parent instanceof DruidQuery) {
return Optional.of(mapper.apply((DruidQuery) parent));
}
context = context.getParent();
}
return Optional.empty();
}
示例6: deserializeFromObjectUsingNonDefault
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
@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);
}
示例7: isInICalProperty
import com.fasterxml.jackson.core.JsonStreamContext; //导入方法依赖的package包/类
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());
}