org.codehaus.jackson.map.ser
Class BeanPropertyWriter

java.lang.Object
  extended by org.codehaus.jackson.map.ser.BeanPropertyWriter
Direct Known Subclasses:
BeanPropertyWriter.NonDefaultField, BeanPropertyWriter.NonDefaultMethod, BeanPropertyWriter.NonNullField, BeanPropertyWriter.NonNullMethod, BeanPropertyWriter.StdField, BeanPropertyWriter.StdMethod

public abstract class BeanPropertyWriter
extends Object

Base bean property handler class, which implements common parts of reflection-based functionality for accessing a property value and serializing it.


Nested Class Summary
static class BeanPropertyWriter.NonDefaultField
          Property writer that outputs all property if and only if it has non-null value.
static class BeanPropertyWriter.NonDefaultMethod
          Property writer that outputs all property if and only if it has non-null value.
static class BeanPropertyWriter.NonNullField
          Property writer that outputs all property if and only if it has non-null value.
static class BeanPropertyWriter.NonNullMethod
          Property writer that outputs all property if and only if it has non-null value.
static class BeanPropertyWriter.StdField
          Basic property writer that outputs property entry independent of what value property has.
static class BeanPropertyWriter.StdMethod
          Basic property writer that outputs property entry independent of what value property has.
 
Field Summary
protected  Class<?> _cfgSerializationType
          Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations.
protected  String _name
          Logical name of the property; will be used as the field name under which value for the property is written.
protected  JsonSerializer<Object> _serializer
          Serializer to use for writing out the value: null if it can not be known statically; non-null if it can.
 
Constructor Summary
BeanPropertyWriter(String name, JsonSerializer<Object> ser, Class<?> serType)
           
 
Method Summary
abstract  Object get(Object bean)
          Method that can be used to access value of the property this Object describes, from given bean instance.
abstract  Type getGenericPropertyType()
          Get the generic property type of this property writer.
 String getName()
           
abstract  Class<?> getReturnType()
           
 Class<?> getSerializationType()
           
 boolean hasSerializer()
           
abstract  void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov)
          Method called to access property that this bean stands for, from within given bean, and to serialize it as a Json Object field using appropriate serializer.
abstract  BeanPropertyWriter withSerializer(JsonSerializer<Object> ser)
          Method that will construct and return a new writer that has same properties as this writer, but uses specified serializer instead of currently configured one (if any).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_name

protected final String _name
Logical name of the property; will be used as the field name under which value for the property is written.


_cfgSerializationType

protected final Class<?> _cfgSerializationType
Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations.


_serializer

protected final JsonSerializer<Object> _serializer
Serializer to use for writing out the value: null if it can not be known statically; non-null if it can.

Constructor Detail

BeanPropertyWriter

public BeanPropertyWriter(String name,
                          JsonSerializer<Object> ser,
                          Class<?> serType)
Method Detail

withSerializer

public abstract BeanPropertyWriter withSerializer(JsonSerializer<Object> ser)
Method that will construct and return a new writer that has same properties as this writer, but uses specified serializer instead of currently configured one (if any).


hasSerializer

public final boolean hasSerializer()

getSerializationType

public final Class<?> getSerializationType()

getReturnType

public abstract Class<?> getReturnType()

getName

public final String getName()

serializeAsField

public abstract void serializeAsField(Object bean,
                                      JsonGenerator jgen,
                                      SerializerProvider prov)
                               throws Exception
Method called to access property that this bean stands for, from within given bean, and to serialize it as a Json Object field using appropriate serializer.

Throws:
Exception

get

public abstract Object get(Object bean)
                    throws Exception
Method that can be used to access value of the property this Object describes, from given bean instance.

Note: method is final as it should not need to be overridden -- rather, calling method(s) (serializeAsField(java.lang.Object, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.map.SerializerProvider)) should be overridden to change the behavior

Throws:
Exception

getGenericPropertyType

public abstract Type getGenericPropertyType()
Get the generic property type of this property writer.

Returns:
The property type, or null if not found.