com.fasterxml.jackson.databind.ser.impl
Class SimpleBeanPropertyFilter

java.lang.Object
  extended by com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
All Implemented Interfaces:
BeanPropertyFilter
Direct Known Subclasses:
SimpleBeanPropertyFilter.FilterExceptFilter, SimpleBeanPropertyFilter.SerializeExceptFilter

public abstract class SimpleBeanPropertyFilter
extends Object
implements BeanPropertyFilter

Simple BeanPropertyFilter implementation that only uses property name to determine whether to serialize property as is, or to filter it out.


Nested Class Summary
static class SimpleBeanPropertyFilter.FilterExceptFilter
          Filter implementation which defaults to filtering out unknown properties and only serializes ones explicitly listed.
static class SimpleBeanPropertyFilter.SerializeExceptFilter
          Filter implementation which defaults to serializing all properties, except for ones explicitly listed to be filtered out.
 
Constructor Summary
protected SimpleBeanPropertyFilter()
           
 
Method Summary
 void depositSchemaProperty(BeanPropertyWriter writer, JsonObjectFormatVisitor objectVisitor, SerializerProvider provider)
          Method called by BeanSerializer to let the filter determine whether, and in what form the given property exist within the parent, or root, schema.
 void depositSchemaProperty(BeanPropertyWriter writer, ObjectNode propertiesNode, SerializerProvider provider)
          Method called by BeanSerializer to let the filter determine whether, and in what form the given property exist within the parent, or root, schema.
static SimpleBeanPropertyFilter filterOutAllExcept(Set<String> properties)
          Factory method to construct filter that filters out all properties except ones includes in set
static SimpleBeanPropertyFilter filterOutAllExcept(String... propertyArray)
           
protected abstract  boolean include(BeanPropertyWriter writer)
          Method called to determine whether property will be included (if 'true' returned) or filtered out (if 'false' returned)
static SimpleBeanPropertyFilter serializeAllExcept(Set<String> properties)
           
static SimpleBeanPropertyFilter serializeAllExcept(String... propertyArray)
           
 void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider provider, BeanPropertyWriter writer)
          Method called by BeanSerializer to let filter decide what to do with given bean property value: the usual choices are to either filter out (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleBeanPropertyFilter

protected SimpleBeanPropertyFilter()
Method Detail

filterOutAllExcept

public static SimpleBeanPropertyFilter filterOutAllExcept(Set<String> properties)
Factory method to construct filter that filters out all properties except ones includes in set


filterOutAllExcept

public static SimpleBeanPropertyFilter filterOutAllExcept(String... propertyArray)

serializeAllExcept

public static SimpleBeanPropertyFilter serializeAllExcept(Set<String> properties)

serializeAllExcept

public static SimpleBeanPropertyFilter serializeAllExcept(String... propertyArray)

include

protected abstract boolean include(BeanPropertyWriter writer)
Method called to determine whether property will be included (if 'true' returned) or filtered out (if 'false' returned)


serializeAsField

public void serializeAsField(Object bean,
                             JsonGenerator jgen,
                             SerializerProvider provider,
                             BeanPropertyWriter writer)
                      throws Exception
Description copied from interface: BeanPropertyFilter
Method called by BeanSerializer to let filter decide what to do with given bean property value: the usual choices are to either filter out (i.e. do nothing) or write using given BeanPropertyWriter, although filters can choose other to do something different altogether.

Specified by:
serializeAsField in interface BeanPropertyFilter
Parameters:
bean - Bean of which property value to serialize
jgen - Generator use for serializing value
provider - Provider that can be used for accessing dynamic aspects of serialization processing
writer - Default bean property serializer to use
Throws:
Exception

depositSchemaProperty

public void depositSchemaProperty(BeanPropertyWriter writer,
                                  ObjectNode propertiesNode,
                                  SerializerProvider provider)
                           throws JsonMappingException
Description copied from interface: BeanPropertyFilter
Method called by BeanSerializer to let the filter determine whether, and in what form the given property exist within the parent, or root, schema. Filters can omit adding the property to the node, or choose the form of the schema value for the property.

Typical implementation is something like:

 if (include(writer)) {
      writer.depositSchemaProperty(propertiesNode, provider);
 }

Specified by:
depositSchemaProperty in interface BeanPropertyFilter
Parameters:
writer - Bean property serializer to use to create schema value
propertiesNode - Node which the given property would exist within
provider - Provider that can be used for accessing dynamic aspects of serialization processing
Throws:
JsonMappingException

depositSchemaProperty

public void depositSchemaProperty(BeanPropertyWriter writer,
                                  JsonObjectFormatVisitor objectVisitor,
                                  SerializerProvider provider)
                           throws JsonMappingException
Description copied from interface: BeanPropertyFilter
Method called by BeanSerializer to let the filter determine whether, and in what form the given property exist within the parent, or root, schema. Filters can omit adding the property to the node, or choose the form of the schema value for the property

Typical implementation is something like:

 if (include(writer)) {
      writer.depositSchemaProperty(objectVisitor, provider);
 }

Specified by:
depositSchemaProperty in interface BeanPropertyFilter
Parameters:
writer - Bean property serializer to use to create schema value
objectVisitor - JsonObjectFormatVisitor which should be aware of the property's existence
provider - Provider that can be used for accessing dynamic aspects of serialization processing
Throws:
JsonMappingException


Copyright © 2012 FasterXML. All Rights Reserved.