com.fasterxml.jackson.databind.deser
Class SettableBeanProperty

java.lang.Object
  extended by com.fasterxml.jackson.databind.deser.SettableBeanProperty
All Implemented Interfaces:
BeanProperty, Named
Direct Known Subclasses:
CreatorProperty, FieldProperty, InnerClassProperty, ManagedReferenceProperty, MethodProperty, ObjectIdValueProperty, SetterlessProperty

public abstract class SettableBeanProperty
extends Object
implements BeanProperty

Base class for deserilizable properties of a bean: contains both type and name definitions, and reflection-based set functionality. Concrete sub-classes implement details, so that field- and setter-backed properties, as well as a few more esoteric variations, can be handled.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.BeanProperty
BeanProperty.Std
 
Field Summary
protected  Annotations _contextAnnotations
          Class that contains this property (either class that declares the property or one of its subclasses), class that is deserialized using deserializer that contains this property.
protected  String _managedReferenceName
          If property represents a managed (forward) reference (see [JACKSON-235]), we will need name of reference for later linking.
protected  NullProvider _nullProvider
          Object used to figure out value to be used when 'null' literal is encountered in JSON.
protected  int _propertyIndex
          Index of property (within all property of a bean); assigned when all properties have been collected.
protected  String _propName
          Logical name of the property (often but not always derived from the setter method name)
protected  JavaType _type
          Base type for property; may be a supertype of actual value.
protected  JsonDeserializer<Object> _valueDeserializer
          Deserializer used for handling property value.
protected  TypeDeserializer _valueTypeDeserializer
          If value will contain type information (to support polymorphic handling), this is the type deserializer used to handle type resolution.
protected  ViewMatcher _viewMatcher
          Helper object used for checking whether this property is to be included in the active view, if property is view-specific; null otherwise.
 
Constructor Summary
protected SettableBeanProperty(BeanPropertyDefinition propDef, JavaType type, TypeDeserializer typeDeser, Annotations contextAnnotations)
           
protected SettableBeanProperty(SettableBeanProperty src)
          Basic copy-constructor for sub-classes to use.
protected SettableBeanProperty(SettableBeanProperty src, JsonDeserializer<?> deser)
          Copy-with-deserializer-change constructor for sub-classes to use.
protected SettableBeanProperty(SettableBeanProperty src, String newName)
          Copy-with-deserializer-change constructor for sub-classes to use.
protected SettableBeanProperty(String propName, JavaType type, TypeDeserializer typeDeser, Annotations contextAnnotations)
           
 
Method Summary
protected  IOException _throwAsIOE(Exception e)
           
protected  void _throwAsIOE(Exception e, Object value)
          Method that takes in exception of any type, and casts or wraps it to an IOException or its subclass.
 void assignIndex(int index)
          Method used to assign index for property.
 Object deserialize(com.fasterxml.jackson.core.JsonParser jp, DeserializationContext ctxt)
          This method is needed by some specialized bean deserializers, and also called by some deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object) implementations.
abstract  void deserializeAndSet(com.fasterxml.jackson.core.JsonParser jp, DeserializationContext ctxt, Object instance)
          Method called to deserialize appropriate value, given parser (and context), and set it using appropriate mechanism.
abstract  Object deserializeSetAndReturn(com.fasterxml.jackson.core.JsonParser jp, DeserializationContext ctxt, Object instance)
          Alternative to deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object) that returns either return value of setter method called (if one is), or null to indicate that no return value is available.
abstract
<A extends Annotation>
A
getAnnotation(Class<A> acls)
          Method for finding annotation associated with this property; meaning annotation associated with one of entities used to access property.
<A extends Annotation>
A
getContextAnnotation(Class<A> acls)
          Method for finding annotation associated with context of this property; usually class in which member is declared (or its subtype if processing subtype).
protected  Class<?> getDeclaringClass()
           
 Object getInjectableValueId()
          Accessor for id of injectable value, if this bean property supports value injection.
 String getManagedReferenceName()
           
abstract  AnnotatedMember getMember()
          Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.
 String getName()
          Method to get logical name of the property
 int getPropertyIndex()
          Method for accessing unique index of this property; indexes are assigned once all properties of a BeanDeserializer have been collected.
 JavaType getType()
          Method to get declared type of the property.
 JsonDeserializer<Object> getValueDeserializer()
           
 TypeDeserializer getValueTypeDeserializer()
           
 boolean hasValueDeserializer()
           
 boolean hasValueTypeDeserializer()
           
 boolean hasViews()
           
abstract  void set(Object instance, Object value)
          Method called to assign given value to this property, on specified Object.
abstract  Object setAndReturn(Object instance, Object value)
          Method called to assign given value to this property, on specified Object, and return whatever delegating accessor returned (if anything)
 void setManagedReferenceName(String n)
           
 void setViews(Class<?>[] views)
           
 String toString()
           
 boolean visibleInView(Class<?> activeView)
           
abstract  SettableBeanProperty withName(String newName)
           
abstract  SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_propName

protected final String _propName
Logical name of the property (often but not always derived from the setter method name)


_type

protected final JavaType _type
Base type for property; may be a supertype of actual value.


_contextAnnotations

protected final Annotations _contextAnnotations
Class that contains this property (either class that declares the property or one of its subclasses), class that is deserialized using deserializer that contains this property.


_valueDeserializer

protected JsonDeserializer<Object> _valueDeserializer
Deserializer used for handling property value.


_valueTypeDeserializer

protected TypeDeserializer _valueTypeDeserializer
If value will contain type information (to support polymorphic handling), this is the type deserializer used to handle type resolution.


_nullProvider

protected NullProvider _nullProvider
Object used to figure out value to be used when 'null' literal is encountered in JSON. For most types simply Java null, but for primitive types must be a non-null value (like Integer.valueOf(0) for int).


_managedReferenceName

protected String _managedReferenceName
If property represents a managed (forward) reference (see [JACKSON-235]), we will need name of reference for later linking.


_viewMatcher

protected ViewMatcher _viewMatcher
Helper object used for checking whether this property is to be included in the active view, if property is view-specific; null otherwise.


_propertyIndex

protected int _propertyIndex
Index of property (within all property of a bean); assigned when all properties have been collected. Order of entries is arbitrary, but once indexes are assigned they are not changed.

Constructor Detail

SettableBeanProperty

protected SettableBeanProperty(BeanPropertyDefinition propDef,
                               JavaType type,
                               TypeDeserializer typeDeser,
                               Annotations contextAnnotations)

SettableBeanProperty

protected SettableBeanProperty(String propName,
                               JavaType type,
                               TypeDeserializer typeDeser,
                               Annotations contextAnnotations)

SettableBeanProperty

protected SettableBeanProperty(SettableBeanProperty src)
Basic copy-constructor for sub-classes to use.


SettableBeanProperty

protected SettableBeanProperty(SettableBeanProperty src,
                               JsonDeserializer<?> deser)
Copy-with-deserializer-change constructor for sub-classes to use.


SettableBeanProperty

protected SettableBeanProperty(SettableBeanProperty src,
                               String newName)
Copy-with-deserializer-change constructor for sub-classes to use.

Method Detail

withValueDeserializer

public abstract SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser)

withName

public abstract SettableBeanProperty withName(String newName)

setManagedReferenceName

public void setManagedReferenceName(String n)

setViews

public void setViews(Class<?>[] views)

assignIndex

public void assignIndex(int index)
Method used to assign index for property.


getName

public final String getName()
Description copied from interface: BeanProperty
Method to get logical name of the property

Specified by:
getName in interface BeanProperty
Specified by:
getName in interface Named

getType

public JavaType getType()
Description copied from interface: BeanProperty
Method to get declared type of the property.

Specified by:
getType in interface BeanProperty

getAnnotation

public abstract <A extends Annotation> A getAnnotation(Class<A> acls)
Description copied from interface: BeanProperty
Method for finding annotation associated with this property; meaning annotation associated with one of entities used to access property.

Specified by:
getAnnotation in interface BeanProperty

getMember

public abstract AnnotatedMember getMember()
Description copied from interface: BeanProperty
Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.

Specified by:
getMember in interface BeanProperty

getContextAnnotation

public <A extends Annotation> A getContextAnnotation(Class<A> acls)
Description copied from interface: BeanProperty
Method for finding annotation associated with context of this property; usually class in which member is declared (or its subtype if processing subtype).

Specified by:
getContextAnnotation in interface BeanProperty

getDeclaringClass

protected final Class<?> getDeclaringClass()

getManagedReferenceName

public String getManagedReferenceName()

hasValueDeserializer

public boolean hasValueDeserializer()

hasValueTypeDeserializer

public boolean hasValueTypeDeserializer()

getValueDeserializer

public JsonDeserializer<Object> getValueDeserializer()

getValueTypeDeserializer

public TypeDeserializer getValueTypeDeserializer()

visibleInView

public boolean visibleInView(Class<?> activeView)

hasViews

public boolean hasViews()

getPropertyIndex

public int getPropertyIndex()
Method for accessing unique index of this property; indexes are assigned once all properties of a BeanDeserializer have been collected.

Returns:
Index of this property

getInjectableValueId

public Object getInjectableValueId()
Accessor for id of injectable value, if this bean property supports value injection.


deserializeAndSet

public abstract void deserializeAndSet(com.fasterxml.jackson.core.JsonParser jp,
                                       DeserializationContext ctxt,
                                       Object instance)
                                throws IOException,
                                       com.fasterxml.jackson.core.JsonProcessingException
Method called to deserialize appropriate value, given parser (and context), and set it using appropriate mechanism. Pre-condition is that passed parser must point to the first token that should be consumed to produce the value (the only value for scalars, multiple for Objects and Arrays).

Throws:
IOException
com.fasterxml.jackson.core.JsonProcessingException

deserializeSetAndReturn

public abstract Object deserializeSetAndReturn(com.fasterxml.jackson.core.JsonParser jp,
                                               DeserializationContext ctxt,
                                               Object instance)
                                        throws IOException,
                                               com.fasterxml.jackson.core.JsonProcessingException
Alternative to deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object) that returns either return value of setter method called (if one is), or null to indicate that no return value is available. Mostly used to support Builder style deserialization.

Throws:
IOException
com.fasterxml.jackson.core.JsonProcessingException
Since:
2.0

set

public abstract void set(Object instance,
                         Object value)
                  throws IOException
Method called to assign given value to this property, on specified Object.

Throws:
IOException

setAndReturn

public abstract Object setAndReturn(Object instance,
                                    Object value)
                             throws IOException
Method called to assign given value to this property, on specified Object, and return whatever delegating accessor returned (if anything)

Throws:
IOException
Since:
2.0

deserialize

public final Object deserialize(com.fasterxml.jackson.core.JsonParser jp,
                                DeserializationContext ctxt)
                         throws IOException,
                                com.fasterxml.jackson.core.JsonProcessingException
This method is needed by some specialized bean deserializers, and also called by some deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object) implementations.

Pre-condition is that passed parser must point to the first token that should be consumed to produce the value (the only value for scalars, multiple for Objects and Arrays).

Note that this method is final for performance reasons: to override functionality you must override other methods that call this method; this method should also not be called directly unless you really know what you are doing (and probably not even then).

Throws:
IOException
com.fasterxml.jackson.core.JsonProcessingException

_throwAsIOE

protected void _throwAsIOE(Exception e,
                           Object value)
                    throws IOException
Method that takes in exception of any type, and casts or wraps it to an IOException or its subclass.

Throws:
IOException

_throwAsIOE

protected IOException _throwAsIOE(Exception e)
                           throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 fasterxml.com. All Rights Reserved.