org.codehaus.jackson.map.ser.std

## Class BeanSerializerBase

- java.lang.Object
- - org.codehaus.jackson.map.JsonSerializer<T>
  - - org.codehaus.jackson.map.ser.std.SerializerBase<Object>
    - - org.codehaus.jackson.map.ser.std.BeanSerializerBase

- All Implemented Interfaces:
    ResolvableSerializer, SchemaAware
  Direct Known Subclasses:
    BeanSerializer, UnwrappingBeanSerializer

      public abstract class BeanSerializerBase
      extends SerializerBase<Object>
      implements ResolvableSerializer, SchemaAware

  Base class both for the standard bean serializer, and couple of variants that only differ in small details. Can be used for custom bean serializers as well, although that is not the primary design goal.
  Since:
    1.9

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.codehaus.jackson.map.JsonSerializer

      `JsonSerializer.None`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AnyGetterWriter` | `_anyGetterWriter` Handler for `JsonAnyGetter` annotated properties
    `protected BeanPropertyWriter[]` | `_filteredProps` Optional filters used to suppress output of properties that are only to be included in certain views
    `protected Object` | `_propertyFilterId` Id of the bean property filter to use, if any; null if none.
    `protected BeanPropertyWriter[]` | `_props` Writers used for outputting actual property values
    `protected static BeanPropertyWriter[]` | `NO_PROPS`

    - ### Fields inherited from class org.codehaus.jackson.map.ser.std.SerializerBase

      `_handledType`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BeanSerializerBase(BeanSerializerBase src)` Copy-constructor that is useful for sub-classes that just want to copy all super-class properties without modifications.
    `` | `BeanSerializerBase(Class<?> rawType, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId)`
    `protected` | `BeanSerializerBase(JavaType type, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected BeanPropertyFilter` | `findFilter(SerializerProvider provider)` Helper method used to locate filter that is needed, based on filter id this serializer was constructed with.
    `JsonNode` | `getSchema(SerializerProvider provider, Type typeHint)` Note: since Jackson 1.9, default implementation claims type is "string"
    `void` | `resolve(SerializerProvider provider)` Method called after `SerializerProvider` has registered the serializer, but before it has returned it to the caller.
    `abstract void` | `serialize(Object bean, JsonGenerator jgen, SerializerProvider provider)` Method that can be called to ask implementation to serialize values of type this serializer handles.
    `protected void` | `serializeFields(Object bean, JsonGenerator jgen, SerializerProvider provider)`
    `protected void` | `serializeFieldsFiltered(Object bean, JsonGenerator jgen, SerializerProvider provider)` Alternative serialization method that gets called when there is a `BeanPropertyFilter` that needs to be called to determine which properties are to be serialized (and possibly how)
    `void` | `serializeWithType(Object bean, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer)` Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.

    - ### Methods inherited from class org.codehaus.jackson.map.ser.std.SerializerBase

      `createObjectNode, createSchemaNode, createSchemaNode, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow, wrapAndThrow, wrapAndThrow`

    - ### Methods inherited from class org.codehaus.jackson.map.JsonSerializer

      `isUnwrappingSerializer, unwrappingSerializer`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NO_PROPS

          protected static final BeanPropertyWriter[] NO_PROPS

    - #### _props

          protected final BeanPropertyWriter[] _props

      Writers used for outputting actual property values

    - #### _filteredProps

          protected final BeanPropertyWriter[] _filteredProps

      Optional filters used to suppress output of properties that are only to be included in certain views

    - #### _anyGetterWriter

          protected final AnyGetterWriter _anyGetterWriter

      Handler for `JsonAnyGetter` annotated properties
      Since:
        1.6

    - #### _propertyFilterId

          protected final Object _propertyFilterId

      Id of the bean property filter to use, if any; null if none.

  - ### Constructor Detail

    - #### BeanSerializerBase

          protected BeanSerializerBase(JavaType type,
                            BeanPropertyWriter[] properties,
                            BeanPropertyWriter[] filteredProperties,
                            AnyGetterWriter anyGetterWriter,
                            Object filterId)

      Parameters:
        `type` - Nominal type of values handled by this serializer
        `properties` - Property writers used for actual serialization

    - #### BeanSerializerBase

          public BeanSerializerBase(Class<?> rawType,
                            BeanPropertyWriter[] properties,
                            BeanPropertyWriter[] filteredProperties,
                            AnyGetterWriter anyGetterWriter,
                            Object filterId)

    - #### BeanSerializerBase

          protected BeanSerializerBase(BeanSerializerBase src)

      Copy-constructor that is useful for sub-classes that just want to copy all super-class properties without modifications.

  - ### Method Detail

    - #### serialize

          public abstract void serialize(Object bean,
                       JsonGenerator jgen,
                       SerializerProvider provider)
                                  throws IOException,
                                         JsonGenerationException

      Description copied from class: `JsonSerializer`
      Method that can be called to ask implementation to serialize values of type this serializer handles.
      Specified by:
        `serialize` in class `SerializerBase<Object>`
      Parameters:
        `bean` - Value to serialize; can not be null.
        `jgen` - Generator used to output resulting Json content
        `provider` - Provider that can be used to get serializers for serializing Objects value contains, if any.
      Throws:
        `IOException`
        `JsonGenerationException`

    - #### serializeWithType

          public void serializeWithType(Object bean,
                               JsonGenerator jgen,
                               SerializerProvider provider,
                               TypeSerializer typeSer)
                                 throws IOException,
                                        JsonGenerationException

      Description copied from class: `JsonSerializer`
      Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.

      Default implementation will ignore serialization of type information, and just calls `JsonSerializer.serialize(T, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.map.SerializerProvider)`: serializers that can embed type information should override this to implement actual handling. Most common such handling is done by something like:

            // note: method to call depends on whether this type is serialized as JSON scalar, object or Array!
            typeSer.writeTypePrefixForScalar(value, jgen);
            serialize(value, jgen, provider);
            typeSer.writeTypeSuffixForScalar(value, jgen);

      Overrides:
        `serializeWithType` in class `JsonSerializer<Object>`
      Parameters:
        `bean` - Value to serialize; can not be null.
        `jgen` - Generator used to output resulting Json content
        `provider` - Provider that can be used to get serializers for serializing Objects value contains, if any.
        `typeSer` - Type serializer to use for including type information
      Throws:
        `IOException`
        `JsonGenerationException`

    - #### serializeFields

          protected void serializeFields(Object bean,
                             JsonGenerator jgen,
                             SerializerProvider provider)
                                  throws IOException,
                                         JsonGenerationException

      Throws:
        `IOException`
        `JsonGenerationException`

    - #### serializeFieldsFiltered

          protected void serializeFieldsFiltered(Object bean,
                                     JsonGenerator jgen,
                                     SerializerProvider provider)
                                          throws IOException,
                                                 JsonGenerationException

      Alternative serialization method that gets called when there is a `BeanPropertyFilter` that needs to be called to determine which properties are to be serialized (and possibly how)
      Throws:
        `IOException`
        `JsonGenerationException`
      Since:
        1.7

    - #### findFilter

          protected BeanPropertyFilter findFilter(SerializerProvider provider)
                                           throws JsonMappingException

      Helper method used to locate filter that is needed, based on filter id this serializer was constructed with.
      Throws:
        `JsonMappingException`
      Since:
        1.7

    - #### getSchema

          public JsonNode getSchema(SerializerProvider provider,
                           Type typeHint)
                             throws JsonMappingException

      Description copied from class: `SerializerBase`
      Note: since Jackson 1.9, default implementation claims type is "string"
      Specified by:
        `getSchema` in interface `SchemaAware`
      Overrides:
        `getSchema` in class `SerializerBase<Object>`
      Parameters:
        `provider` - The serializer provider.
        `typeHint` - A hint about the type.
      Returns:
        Json-schema for this serializer.
      Throws:
        `JsonMappingException`

    - #### resolve

          public void resolve(SerializerProvider provider)
                       throws JsonMappingException

      Description copied from interface: `ResolvableSerializer`
      Method called after `SerializerProvider` has registered the serializer, but before it has returned it to the caller. Called object can then resolve its dependencies to other types, including self-references (direct or indirect).
      Specified by:
        `resolve` in interface `ResolvableSerializer`
      Parameters:
        `provider` - Provider that has constructed serializer this method is called on.
      Throws:
        `JsonMappingException`