本文整理汇总了Java中com.fasterxml.jackson.databind.util.TokenBuffer.copyCurrentStructure方法的典型用法代码示例。如果您正苦于以下问题:Java TokenBuffer.copyCurrentStructure方法的具体用法?Java TokenBuffer.copyCurrentStructure怎么用?Java TokenBuffer.copyCurrentStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.util.TokenBuffer
的用法示例。
在下文中一共展示了TokenBuffer.copyCurrentStructure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializeMetadata
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
FieldMetadata deserializeMetadata(ObjectMapper mapper, String fieldName, JsonNode fieldJson) throws JsonParseException, IOException {
TokenBuffer tb = new TokenBuffer(null, false);
JsonParser jp = fieldJson.traverse(mapper);
jp.nextToken(); // Get to Start TOKEN
JsonToken token = jp.getCurrentToken();
tb.writeStringField(NAME_PROP, fieldName);
do {
jp.nextToken();
token = jp.getCurrentToken();
tb.copyCurrentStructure(jp);
} while(token != JsonToken.END_OBJECT);
jp = tb.asParser(jp);
jp.nextToken();
tb.close();
FieldMetadata diff = mapper.readValue(jp, FieldMetadata.class);
return defaultMetaProvider.mergeWithDefault(diff);
}
示例2: enrichJsonObject
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
private JsonParser enrichJsonObject(ObjectMapper mapper, String fieldName, JsonNode fieldJson) throws IOException {
TokenBuffer tb = new TokenBuffer(null, false);
JsonParser jp = fieldJson.traverse(mapper);
JsonToken token = jp.nextToken(); // Get to Start TOKEN
tb.writeStringField(NAME_PROP, fieldName);
do {
jp.nextToken();
token = jp.getCurrentToken();
tb.copyCurrentStructure(jp);
} while(token != JsonToken.END_OBJECT);
jp = tb.asParser(jp);
jp.nextToken();
tb.close();
return jp;
}
示例3: _deserialize
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected final Object _deserialize(JsonParser jp, DeserializationContext ctxt,
int index)
throws IOException, JsonProcessingException
{
TokenBuffer merged = new TokenBuffer(jp.getCodec());
merged.writeStartArray();
merged.writeString(_typeIds[index]);
JsonParser p2 = _tokens[index].asParser(jp);
p2.nextToken();
merged.copyCurrentStructure(p2);
merged.writeEndArray();
// needs to point to START_OBJECT (or whatever first token is)
p2 = merged.asParser(jp);
p2.nextToken();
return _properties[index].getProperty().deserialize(p2, ctxt);
}
示例4: _deserializeAndSet
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected final void _deserializeAndSet(JsonParser jp, DeserializationContext ctxt, Object bean, int index)
throws IOException, JsonProcessingException
{
/* Ok: time to mix type id, value; and we will actually use "wrapper-array"
* style to ensure we can handle all kinds of JSON constructs.
*/
TokenBuffer merged = new TokenBuffer(jp.getCodec());
merged.writeStartArray();
merged.writeString(_typeIds[index]);
JsonParser p2 = _tokens[index].asParser(jp);
p2.nextToken();
merged.copyCurrentStructure(p2);
merged.writeEndArray();
// needs to point to START_OBJECT (or whatever first token is)
p2 = merged.asParser(jp);
p2.nextToken();
_properties[index].getProperty().deserializeAndSet(p2, ctxt, bean);
}
示例5: nextTokenBuffer
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
/**
* Reads current value including objects and array as effiecient token buffer.
* Use of Jackson's own mechanisms is important to preserve custom elements
* such as special embedded objects in BSON or other data formats.
* @return {@link TokenBuffer}
* @throws IOException if error occured
*/
public final TokenBuffer nextTokenBuffer() throws IOException {
TokenBuffer buffer = new TokenBuffer(parser);
// if token is consumed, but undelying parser is still sitting on this token, we move forward
requirePeek();
buffer.copyCurrentStructure(parser);
// when we will return to reading from reader, state will be cleared and nextToken after
clearPeek();
return buffer;
}
示例6: _deserialize
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, int paramInt, String paramString)
{
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.writeStartArray();
localTokenBuffer.writeString(paramString);
JsonParser localJsonParser1 = this._tokens[paramInt].asParser(paramJsonParser);
localJsonParser1.nextToken();
localTokenBuffer.copyCurrentStructure(localJsonParser1);
localTokenBuffer.writeEndArray();
JsonParser localJsonParser2 = localTokenBuffer.asParser(paramJsonParser);
localJsonParser2.nextToken();
return this._properties[paramInt].getProperty().deserialize(localJsonParser2, paramDeserializationContext);
}
示例7: _deserializeAndSet
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected final void _deserializeAndSet(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Object paramObject, int paramInt, String paramString)
{
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.writeStartArray();
localTokenBuffer.writeString(paramString);
JsonParser localJsonParser1 = this._tokens[paramInt].asParser(paramJsonParser);
localJsonParser1.nextToken();
localTokenBuffer.copyCurrentStructure(localJsonParser1);
localTokenBuffer.writeEndArray();
JsonParser localJsonParser2 = localTokenBuffer.asParser(paramJsonParser);
localJsonParser2.nextToken();
this._properties[paramInt].getProperty().deserializeAndSet(localJsonParser2, paramDeserializationContext, paramObject);
}
示例8: handlePropertyValue
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
public boolean handlePropertyValue(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, String paramString, Object paramObject)
{
Integer localInteger = (Integer)this._nameToPropertyIndex.get(paramString);
if (localInteger == null)
return false;
int i = localInteger.intValue();
int j;
if (this._properties[i].hasTypePropertyName(paramString))
{
this._typeIds[i] = paramJsonParser.getText();
paramJsonParser.skipChildren();
if ((paramObject != null) && (this._tokens[i] != null))
j = 1;
else
j = 0;
}
else
{
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.copyCurrentStructure(paramJsonParser);
this._tokens[i] = localTokenBuffer;
if ((paramObject != null) && (this._typeIds[i] != null))
j = 1;
else
j = 0;
}
if (j != 0)
{
String str = this._typeIds[i];
this._typeIds[i] = null;
_deserializeAndSet(paramJsonParser, paramDeserializationContext, paramObject, i, str);
this._tokens[i] = null;
}
return true;
}
示例9: deserialize
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
@Override
public TokenBuffer deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException
{
TokenBuffer tb = new TokenBuffer(jp.getCodec());
// quite simple, given that TokenBuffer is a JsonGenerator:
tb.copyCurrentStructure(jp);
return tb;
}
示例10: handlePropertyValue
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
/**
* Method called to ask handler to handle value of given property,
* at point where parser points to the first token of the value.
* Handling can mean either resolving type id it contains (if it matches type
* property name), or by buffering the value for further use.
*
* @return True, if the given property was properly handled
*/
public boolean handlePropertyValue(JsonParser jp, DeserializationContext ctxt,
String propName, Object bean)
throws IOException, JsonProcessingException
{
Integer I = _nameToPropertyIndex.get(propName);
if (I == null) {
return false;
}
int index = I.intValue();
ExtTypedProperty prop = _properties[index];
boolean canDeserialize;
if (prop.hasTypePropertyName(propName)) {
_typeIds[index] = jp.getText();
jp.skipChildren();
canDeserialize = (bean != null) && (_tokens[index] != null);
} else {
TokenBuffer tokens = new TokenBuffer(jp.getCodec());
tokens.copyCurrentStructure(jp);
_tokens[index] = tokens;
canDeserialize = (bean != null) && (_typeIds[index] != null);
}
/* Minor optimization: let's deserialize properties as soon as
* we have all pertinent information:
*/
if (canDeserialize) {
_deserializeAndSet(jp, ctxt, bean, index);
// clear stored data, to avoid deserializing+setting twice:
_typeIds[index] = null;
_tokens[index] = null;
}
return true;
}
示例11: deserializeTypedFromObject
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
@Override
public Object deserializeTypedFromObject(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonToken t;
t = p.getCurrentToken();
if (t == JsonToken.START_OBJECT) {
t = p.nextToken();
} else if (t != JsonToken.FIELD_NAME) {
throw new JsonMappingException(p, "Could not extract event type from non-object");
}
final TokenBuffer tb = new TokenBuffer(p, ctxt);
for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
final String topLevelProperty = p.getCurrentName();
tb.writeFieldName(topLevelProperty);
t = p.nextToken();
if (topLevelProperty.equals("metadata")) {
if (t != JsonToken.START_OBJECT) {
throw new JsonMappingException(p, "Could not extract event type from invalid metadata");
}
tb.writeStartObject();
t = p.nextToken();
for (; t == JsonToken.FIELD_NAME; t = p.nextToken()) {
final String metadataProperty = p.getCurrentName();
tb.writeFieldName(metadataProperty);
t = p.nextToken();
if (metadataProperty.equals("event_type")) {
if (t != JsonToken.VALUE_STRING) {
throw new JsonMappingException(p, "Could not extract event type from non-string property");
}
final String typeId = p.getText();
tb.writeString(typeId);
final JsonParser pb = JsonParserSequence.createFlattened(false, tb.asParser(p), p);
return deserialize(pb, ctxt, typeId);
} else {
tb.copyCurrentStructure(p);
}
}
} else {
tb.copyCurrentStructure(p);
}
}
throw new JsonMappingException(p, "Could not find metadata property to extract event type");
}
示例12: deserializeUsingPropertyBasedWithExternalTypeId
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
ExternalTypeHandler localExternalTypeHandler = this._externalTypeIdHandler.start();
PropertyBasedCreator localPropertyBasedCreator = this._propertyBasedCreator;
PropertyValueBuffer localPropertyValueBuffer = localPropertyBasedCreator.startBuilding(paramJsonParser, paramDeserializationContext, this._objectIdReader);
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.writeStartObject();
for (JsonToken localJsonToken1 = paramJsonParser.getCurrentToken(); localJsonToken1 == JsonToken.FIELD_NAME; localJsonToken1 = paramJsonParser.nextToken())
{
String str = paramJsonParser.getCurrentName();
paramJsonParser.nextToken();
SettableBeanProperty localSettableBeanProperty1 = localPropertyBasedCreator.findCreatorProperty(str);
if (localSettableBeanProperty1 != null)
{
if (!localExternalTypeHandler.handlePropertyValue(paramJsonParser, paramDeserializationContext, str, localPropertyValueBuffer))
{
Object localObject2 = localSettableBeanProperty1.deserialize(paramJsonParser, paramDeserializationContext);
if (localPropertyValueBuffer.assignParameter(localSettableBeanProperty1.getCreatorIndex(), localObject2))
{
JsonToken localJsonToken2 = paramJsonParser.nextToken();
Object localObject3;
try
{
localObject3 = localPropertyBasedCreator.build(paramDeserializationContext, localPropertyValueBuffer);
}
catch (Exception localException2)
{
wrapAndThrow(localException2, this._beanType.getRawClass(), str, paramDeserializationContext);
continue;
}
while (localJsonToken2 == JsonToken.FIELD_NAME)
{
paramJsonParser.nextToken();
localTokenBuffer.copyCurrentStructure(paramJsonParser);
localJsonToken2 = paramJsonParser.nextToken();
}
if (localObject3.getClass() != this._beanType.getRawClass())
throw paramDeserializationContext.mappingException("Can not create polymorphic instances with unwrapped values");
return localExternalTypeHandler.complete(paramJsonParser, paramDeserializationContext, localObject3);
}
}
}
else if (!localPropertyValueBuffer.readIdProperty(str))
{
SettableBeanProperty localSettableBeanProperty2 = this._beanProperties.find(str);
if (localSettableBeanProperty2 != null)
localPropertyValueBuffer.bufferProperty(localSettableBeanProperty2, localSettableBeanProperty2.deserialize(paramJsonParser, paramDeserializationContext));
else if (!localExternalTypeHandler.handlePropertyValue(paramJsonParser, paramDeserializationContext, str, null))
if ((this._ignorableProps != null) && (this._ignorableProps.contains(str)))
paramJsonParser.skipChildren();
else if (this._anySetter != null)
localPropertyValueBuffer.bufferAnyProperty(this._anySetter, str, this._anySetter.deserialize(paramJsonParser, paramDeserializationContext));
}
}
try
{
Object localObject1 = localExternalTypeHandler.complete(paramJsonParser, paramDeserializationContext, localPropertyValueBuffer, localPropertyBasedCreator);
return localObject1;
}
catch (Exception localException1)
{
wrapInstantiationProblem(localException1, paramDeserializationContext);
}
return null;
}
示例13: deserializeUsingPropertyBasedWithUnwrapped
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
PropertyBasedCreator localPropertyBasedCreator = this._propertyBasedCreator;
PropertyValueBuffer localPropertyValueBuffer = localPropertyBasedCreator.startBuilding(paramJsonParser, paramDeserializationContext, this._objectIdReader);
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.writeStartObject();
for (JsonToken localJsonToken1 = paramJsonParser.getCurrentToken(); localJsonToken1 == JsonToken.FIELD_NAME; localJsonToken1 = paramJsonParser.nextToken())
{
String str = paramJsonParser.getCurrentName();
paramJsonParser.nextToken();
SettableBeanProperty localSettableBeanProperty1 = localPropertyBasedCreator.findCreatorProperty(str);
if (localSettableBeanProperty1 != null)
{
Object localObject2 = localSettableBeanProperty1.deserialize(paramJsonParser, paramDeserializationContext);
if (localPropertyValueBuffer.assignParameter(localSettableBeanProperty1.getCreatorIndex(), localObject2))
{
JsonToken localJsonToken2 = paramJsonParser.nextToken();
Object localObject3;
try
{
localObject3 = localPropertyBasedCreator.build(paramDeserializationContext, localPropertyValueBuffer);
}
catch (Exception localException2)
{
wrapAndThrow(localException2, this._beanType.getRawClass(), str, paramDeserializationContext);
continue;
}
while (localJsonToken2 == JsonToken.FIELD_NAME)
{
paramJsonParser.nextToken();
localTokenBuffer.copyCurrentStructure(paramJsonParser);
localJsonToken2 = paramJsonParser.nextToken();
}
localTokenBuffer.writeEndObject();
if (localObject3.getClass() != this._beanType.getRawClass())
{
localTokenBuffer.close();
throw paramDeserializationContext.mappingException("Can not create polymorphic instances with unwrapped values");
}
return this._unwrappedPropertyHandler.processUnwrapped(paramJsonParser, paramDeserializationContext, localObject3, localTokenBuffer);
}
}
else if (!localPropertyValueBuffer.readIdProperty(str))
{
SettableBeanProperty localSettableBeanProperty2 = this._beanProperties.find(str);
if (localSettableBeanProperty2 != null)
{
localPropertyValueBuffer.bufferProperty(localSettableBeanProperty2, localSettableBeanProperty2.deserialize(paramJsonParser, paramDeserializationContext));
}
else if ((this._ignorableProps != null) && (this._ignorableProps.contains(str)))
{
paramJsonParser.skipChildren();
}
else
{
localTokenBuffer.writeFieldName(str);
localTokenBuffer.copyCurrentStructure(paramJsonParser);
if (this._anySetter != null)
localPropertyValueBuffer.bufferAnyProperty(this._anySetter, str, this._anySetter.deserialize(paramJsonParser, paramDeserializationContext));
}
}
}
Object localObject1;
try
{
localObject1 = localPropertyBasedCreator.build(paramDeserializationContext, localPropertyValueBuffer);
}
catch (Exception localException1)
{
wrapInstantiationProblem(localException1, paramDeserializationContext);
return null;
}
return this._unwrappedPropertyHandler.processUnwrapped(paramJsonParser, paramDeserializationContext, localObject1, localTokenBuffer);
}
示例14: deserializeWithUnwrapped
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
protected Object deserializeWithUnwrapped(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
if (this._delegateDeserializer != null)
return this._valueInstantiator.createUsingDelegate(paramDeserializationContext, this._delegateDeserializer.deserialize(paramJsonParser, paramDeserializationContext));
if (this._propertyBasedCreator != null)
return deserializeUsingPropertyBasedWithUnwrapped(paramJsonParser, paramDeserializationContext);
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.writeStartObject();
Object localObject = this._valueInstantiator.createUsingDefault(paramDeserializationContext);
if (this._injectables != null)
injectValues(paramDeserializationContext, localObject);
Class localClass;
if (this._needViewProcesing)
localClass = paramDeserializationContext.getActiveView();
else
localClass = null;
while (paramJsonParser.getCurrentToken() != JsonToken.END_OBJECT)
{
String str = paramJsonParser.getCurrentName();
paramJsonParser.nextToken();
SettableBeanProperty localSettableBeanProperty = this._beanProperties.find(str);
if (localSettableBeanProperty != null)
{
if ((localClass != null) && (!localSettableBeanProperty.visibleInView(localClass)))
paramJsonParser.skipChildren();
else
try
{
localSettableBeanProperty.deserializeAndSet(paramJsonParser, paramDeserializationContext, localObject);
}
catch (Exception localException2)
{
wrapAndThrow(localException2, localObject, str, paramDeserializationContext);
}
}
else if ((this._ignorableProps != null) && (this._ignorableProps.contains(str)))
{
paramJsonParser.skipChildren();
}
else
{
localTokenBuffer.writeFieldName(str);
localTokenBuffer.copyCurrentStructure(paramJsonParser);
if (this._anySetter != null)
try
{
this._anySetter.deserializeAndSet(paramJsonParser, paramDeserializationContext, localObject, str);
}
catch (Exception localException1)
{
wrapAndThrow(localException1, localObject, str, paramDeserializationContext);
}
}
paramJsonParser.nextToken();
}
localTokenBuffer.writeEndObject();
this._unwrappedPropertyHandler.processUnwrapped(paramJsonParser, paramDeserializationContext, localObject, localTokenBuffer);
return localObject;
}
示例15: deserialize
import com.fasterxml.jackson.databind.util.TokenBuffer; //导入方法依赖的package包/类
public TokenBuffer deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
TokenBuffer localTokenBuffer = new TokenBuffer(paramJsonParser.getCodec());
localTokenBuffer.copyCurrentStructure(paramJsonParser);
return localTokenBuffer;
}