Package com.isomorphic.datasource

# Class DataSourceBeanFilter

java.lang.Object
com.isomorphic.datasource.DataSourceBeanFilter

All Implemented Interfaces:
  `IBeanFilter`, `com.isomorphic.js.IContextBeanFilter`, `com.isomorphic.js.IContextBeanFilterWithNullControl`

public class DataSourceBeanFilter extends Object implements com.isomorphic.js.IContextBeanFilterWithNullControl
An IBeanFilter that applies DataSource.getProperties() to all bean values (e.g. applying valueXPath) and optionally strips any bean properties that do not have a corresponding DataSource field definition.

Note: this filter is automatically applied by the RPCManager to all DSResponse objects sent to the client in order to perform valueXPath resolution.

See Also:
  - `IBeanFilter`
  - `DataSource.getProperties(java.lang.Object)`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DataSourceBeanFilter(DataSource dataSource, boolean dropExtraFields)`
  Creates a new DataSourceBeanFilter
  `DataSourceBeanFilter(DataSource dataSource, boolean dropExtraFields, boolean dropIgnoredFields)`
  Creates a new DataSourceBeanFilter
  `DataSourceBeanFilter(DataSource dataSource, Collection propsToKeep)`
  Creates a new DataSourceBeanFilter
  `DataSourceBeanFilter(String dataSource, boolean dropExtraFields)`
  Creates a new DataSourceBeanFilter
  `DataSourceBeanFilter(String dataSource, boolean dropExtraFields, boolean dropIgnoredFields)`
  Creates a new DataSourceBeanFilter
  `DataSourceBeanFilter(String dataSource, Collection propsToKeep)`
  Creates a new DataSourceBeanFilter

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map`
  `filter(Object obj)`
  This method is called to filter a bean (IBeanFilter Interface).

- ## Constructor Details

  - ### DataSourceBeanFilter

    public DataSourceBeanFilter(String dataSource, boolean dropExtraFields)
    Creates a new DataSourceBeanFilter
    Parameters:
      `dataSource` - DataSource to use, as a String.
      `dropExtraFields` - If true, this filter will drop all bean properties that do not have a corresponding DataSource field definition. If false, those extra fields will not be removed by the filter.

  - ### DataSourceBeanFilter

    public DataSourceBeanFilter(DataSource dataSource, boolean dropExtraFields)
    Creates a new DataSourceBeanFilter
    Parameters:
      `dataSource` - DataSource to use, as a DataSource instance.
      `dropExtraFields` - If true, this filter will drop all bean properties that do not have a corresponding DataSource field definition. If false, those extra fields will not be removed by the filter.

  - ### DataSourceBeanFilter

    public DataSourceBeanFilter(String dataSource, boolean dropExtraFields, boolean dropIgnoredFields)
    Creates a new DataSourceBeanFilter
    Parameters:
      `dataSource` - DataSource to use, as a String.
      `dropExtraFields` - If true, this filter will drop all bean properties that do not have a corresponding DataSource field definition. If false, those extra fields will not be removed by the filter.
      `dropIgnoredFields` - If true, this filter will drop all bean properties where the corresponding DataSource field definition is marked with the property ignore: true. If false, the ignored fields will not be removed by the filter.

  - ### DataSourceBeanFilter

    public DataSourceBeanFilter(DataSource dataSource, boolean dropExtraFields, boolean dropIgnoredFields)
    Creates a new DataSourceBeanFilter
    Parameters:
      `dataSource` - DataSource to use, as a DataSource instance.
      `dropExtraFields` - If true, this filter will drop all bean properties that do not have a corresponding DataSource field definition. If false, those extra fields will not be removed by the filter.
      `dropIgnoredFields` - If true, this filter will drop all bean properties where the corresponding DataSource field definition is marked with the property ignore: true. If false, the ignored fields will not be removed by the filter.

  - ### DataSourceBeanFilter

    public DataSourceBeanFilter(String dataSource, Collection propsToKeep)
    Creates a new DataSourceBeanFilter
    Parameters:
      `dataSource` - DataSource to use, as a String.
      `propsToKeep` - Explicit list of properties to keep.

  - ### DataSourceBeanFilter

    public DataSourceBeanFilter(DataSource dataSource, Collection propsToKeep)
    Creates a new DataSourceBeanFilter
    Parameters:
      `dataSource` - DataSource to use, as a DataSource instance.
      `propsToKeep` - Explicit list of properties to keep.

- ## Method Details

  - ### filter

    public Map filter(Object obj) throws Exception
    This method is called to filter a bean (IBeanFilter Interface). Returns the bean as filtered by this filter.
    Specified by:
      `filter` in interface `IBeanFilter`
    Parameters:
      `obj` - the bean to convert
    Returns:
      the converted bean as a Map
    Throws:
      `Exception`