org.codehaus.jackson.map.ser
Class BeanPropertyWriter

java.lang.Object
  extended by org.codehaus.jackson.map.ser.BeanPropertyWriter

public final class BeanPropertyWriter
extends java.lang.Object

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


Field Summary
protected  java.lang.reflect.Method _accessorMethod
          Accessor method used to get property value
protected  boolean _cfgWriteIfNull
          Whether this property will be written out if its value is null or not: if true, property is always written; if false, only if its value is not null.
protected  JsonSerializer<java.lang.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(java.lang.String name, java.lang.reflect.Method acc, JsonSerializer<java.lang.Object> ser, boolean writeIfNull)
           
 
Method Summary
 java.lang.Object get(java.lang.Object bean)
          Method that can be used to access value of the property this Object describes, from given bean instance.
 java.lang.String getName()
           
 java.lang.Class<?> getReturnType()
           
 boolean hasSerializer()
           
 void serializeAsField(java.lang.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.
 java.lang.String toString()
           
 BeanPropertyWriter withSerializer(JsonSerializer<java.lang.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, wait, wait, wait
 

Field Detail

_accessorMethod

protected final java.lang.reflect.Method _accessorMethod
Accessor method used to get property value


_cfgWriteIfNull

protected final boolean _cfgWriteIfNull
Whether this property will be written out if its value is null or not: if true, property is always written; if false, only if its value is not null.


_serializer

protected final JsonSerializer<java.lang.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(java.lang.String name,
                          java.lang.reflect.Method acc,
                          JsonSerializer<java.lang.Object> ser,
                          boolean writeIfNull)
Method Detail

withSerializer

public BeanPropertyWriter withSerializer(JsonSerializer<java.lang.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 boolean hasSerializer()

getReturnType

public final java.lang.Class<?> getReturnType()

getName

public final java.lang.String getName()

serializeAsField

public void serializeAsField(java.lang.Object bean,
                             JsonGenerator jgen,
                             SerializerProvider prov)
                      throws java.lang.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:
java.lang.Exception

get

public final java.lang.Object get(java.lang.Object bean)
                           throws java.lang.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:
java.lang.Exception

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object