Class ExternalTypeHandler
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler
-
public class ExternalTypeHandler extends java.lang.ObjectHelper class that is used to flatten JSON structure when using "external type id" (seeJsonTypeInfo.As.EXTERNAL_PROPERTY). This is needed to store temporary state and buffer tokens, as the structure is rearranged a bit so that actual type deserializer can resolve type and finalize deserialization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExternalTypeHandler.Builderprivate static classExternalTypeHandler.ExtTypedProperty
-
Field Summary
Fields Modifier and Type Field Description private JavaType_beanTypeprivate java.util.Map<java.lang.String,java.lang.Object>_nameToPropertyIndexMapping from external property ids to one or more indexes; in most cases single index asInteger, but occasionally same name maps to multiple ones: if so,List<Integer>.private ExternalTypeHandler.ExtTypedProperty[]_propertiesprivate TokenBuffer[]_tokensprivate java.lang.String[]_typeIds
-
Constructor Summary
Constructors Modifier Constructor Description protectedExternalTypeHandler(ExternalTypeHandler h)protectedExternalTypeHandler(JavaType beanType, ExternalTypeHandler.ExtTypedProperty[] properties, java.util.Map<java.lang.String,java.lang.Object> nameToPropertyIndex, java.lang.String[] typeIds, TokenBuffer[] tokens)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object_deserialize(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, int index, java.lang.String typeId)protected void_deserializeAndSet(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.Object bean, int index, java.lang.String typeId)private boolean_handleTypePropertyValue(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.String propName, java.lang.Object bean, java.lang.String typeId, int index)static ExternalTypeHandler.Builderbuilder(JavaType beanType)java.lang.Objectcomplete(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, PropertyValueBuffer buffer, PropertyBasedCreator creator)Variant called when creation of the POJO involves buffering of creator properties as well as property-based creator.java.lang.Objectcomplete(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.Object bean)Method called after JSON Object closes, and has to ensure that all external type ids have been handled.booleanhandlePropertyValue(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.String propName, java.lang.Object bean)Method called to ask handler to handle value of given property, at point where parser points to the first token of the value.booleanhandleTypePropertyValue(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.String propName, java.lang.Object bean)Method called to see if given property/value pair is an external type id; and if so handle it.ExternalTypeHandlerstart()Method called to start collection process by creating non-blueprint instances.
-
-
-
Field Detail
-
_beanType
private final JavaType _beanType
-
_properties
private final ExternalTypeHandler.ExtTypedProperty[] _properties
-
_nameToPropertyIndex
private final java.util.Map<java.lang.String,java.lang.Object> _nameToPropertyIndex
Mapping from external property ids to one or more indexes; in most cases single index asInteger, but occasionally same name maps to multiple ones: if so,List<Integer>.
-
_typeIds
private final java.lang.String[] _typeIds
-
_tokens
private final TokenBuffer[] _tokens
-
-
Constructor Detail
-
ExternalTypeHandler
protected ExternalTypeHandler(JavaType beanType, ExternalTypeHandler.ExtTypedProperty[] properties, java.util.Map<java.lang.String,java.lang.Object> nameToPropertyIndex, java.lang.String[] typeIds, TokenBuffer[] tokens)
-
ExternalTypeHandler
protected ExternalTypeHandler(ExternalTypeHandler h)
-
-
Method Detail
-
builder
public static ExternalTypeHandler.Builder builder(JavaType beanType)
- Since:
- 2.9
-
start
public ExternalTypeHandler start()
Method called to start collection process by creating non-blueprint instances.
-
handleTypePropertyValue
public boolean handleTypePropertyValue(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.String propName, java.lang.Object bean) throws java.io.IOExceptionMethod called to see if given property/value pair is an external type id; and if so handle it. This is only to be called in case containing POJO has similarly named property as the external type id AND value is of scalar type: otherwisehandlePropertyValue(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.String, java.lang.Object)should be called instead.- Throws:
java.io.IOException
-
_handleTypePropertyValue
private final boolean _handleTypePropertyValue(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.String propName, java.lang.Object bean, java.lang.String typeId, int index) throws java.io.IOException- Throws:
java.io.IOException
-
handlePropertyValue
public boolean handlePropertyValue(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.String propName, java.lang.Object bean) throws java.io.IOExceptionMethod 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.- Returns:
- True, if the given property was properly handled
- Throws:
java.io.IOException
-
complete
public java.lang.Object complete(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.Object bean) throws java.io.IOExceptionMethod called after JSON Object closes, and has to ensure that all external type ids have been handled.- Throws:
java.io.IOException
-
complete
public java.lang.Object complete(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, PropertyValueBuffer buffer, PropertyBasedCreator creator) throws java.io.IOExceptionVariant called when creation of the POJO involves buffering of creator properties as well as property-based creator.- Throws:
java.io.IOException
-
_deserialize
protected final java.lang.Object _deserialize(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, int index, java.lang.String typeId) throws java.io.IOException- Throws:
java.io.IOException
-
_deserializeAndSet
protected final void _deserializeAndSet(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, java.lang.Object bean, int index, java.lang.String typeId) throws java.io.IOException- Throws:
java.io.IOException
-
-