Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD

## org.grails.databinding
[Groovy] Class SimpleDataBinder

    java.lang.Object
      org.grails.databinding.SimpleDataBinder

All Implemented Interfaces:
  DataBinder

    @groovy.transform.CompileStatic
    class SimpleDataBinder
    extends java.lang.Object

A data binder that will bind nested Maps to an object.

     class Person {
         String firstName
         Address homeAddress
     }

     class Address {
         String city
         String state
     }

     def person = new Person()
     def binder = new SimpleDataBinder()
     binder.bind person, [firstName: 'Steven', homeAddress: [city: 'St. Louis', state: 'Missouri']]
     assert person.firstName == 'Steven'
     assert person.homeAddress.city == 'St. Louis'
     assert person.homeAddress.state == 'Missouri'

Authors:
  Jeff Brown
  Graeme Rocher

Since:
  2.3

Field Summary
`protected static java.util.List` | `BASIC_TYPES`
`protected java.util.Map` | `conversionHelpers`
`protected java.util.Map` | `formattedValueConvertersionHelpers`
`protected java.util.Map` | `structuredEditors`

Property Summary
`static java.lang.Object` | `INDEXED_PROPERTY_REGEX`
`int` | `autoGrowCollectionLimit`
`ConversionService` | `conversionService`

Constructor Summary
`SimpleDataBinder()`

Method Summary
`protected java.lang.Object` | `addBindingError(java.lang.Object obj, java.lang.String propName, java.lang.Object propertyValue, java.lang.Exception e, DataBindingListener listener, java.lang.Object errors)`
`protected java.lang.Object` | `addElementToArrayAt(java.lang.Object array, java.lang.Object index, java.lang.Object val)`
`protected java.lang.Object` | `addElementToCollection(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, java.lang.Object propertyValue, boolean clearCollection)`
`protected java.lang.Object` | `addElementToCollectionAt(java.lang.Object obj, java.lang.String propertyName, java.util.Collection collection, java.lang.Object index, java.lang.Object val)`
`void` | `bind(java.lang.Object obj, DataBindingSource source)` @param obj The object being bound to
`void` | `bind(java.lang.Object obj, DataBindingSource source, DataBindingListener listener)` @param obj The object being bound to
`void` | `bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList)` @param obj The object being bound to
`void` | `bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList, java.util.List blackList)` @param obj The object being bound to
`void` | `bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath)` @param obj The object being bound to
`void` | `bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList)` @param obj The object being bound to
`void` | `bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)` @param obj The object being bound to
`protected java.lang.Object` | `bindProperty(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, java.lang.Object errors)`
`protected java.lang.Object` | `convert(java.lang.Class typeToConvertTo, java.lang.Object value)`
`protected java.lang.Object` | `convertStringToEnum(java.lang.Class enumClass, java.lang.String value)`
`protected void` | `doBind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener, java.lang.Object errors)`
`protected ValueConverter` | `getConverter(java.lang.Class typeToConvertTo, java.lang.Object value)`
`protected java.lang.Object` | `getDefaultCollectionInstanceForType(java.lang.Class type)`
`protected java.lang.reflect.Field` | `getField(java.lang.Class clazz, java.lang.String fieldName)`
`protected java.lang.String` | `getFormatString(BindingFormat annotation)`
`protected ValueConverter` | `getFormattedConverter(java.lang.reflect.Field field, java.lang.String formattingValue)` Get a ValueConverter for field
`protected IndexedPropertyReferenceDescriptor` | `getIndexedPropertyReferenceDescriptor(java.lang.Object propName)`
`protected java.lang.Class` | `getReferencedTypeForCollection(java.lang.String propertyName, java.lang.Object obj)`
`protected java.lang.Class` | `getReferencedTypeForCollectionInClass(java.lang.String propertyName, java.lang.Class clazz)`
`protected ValueConverter` | `getValueConverter(java.lang.Object obj, java.lang.String propName)`
`protected ValueConverter` | `getValueConverterForClass(java.lang.Object obj, java.lang.String propName)`
`protected ValueConverter` | `getValueConverterForField(java.lang.Object obj, java.lang.String propName)`
`protected java.lang.Object` | `initializeArray(java.lang.Object obj, java.lang.String propertyName, java.lang.Class arrayType, int index)`
`protected java.util.Collection` | `initializeCollection(java.lang.Object obj, java.lang.String propertyName, java.lang.Class type, boolean reuseExistingCollectionIfExists = true)`
`protected java.util.Map` | `initializeMap(java.lang.Object obj, java.lang.String propertyName)`
`protected java.lang.Object` | `initializeProperty(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, DataBindingSource source)`
`protected boolean` | `isBasicType(java.lang.Class c)`
`protected boolean` | `isOkToAddElementAt(java.util.Collection collection, int index)`
`protected java.lang.Object` | `isOkToBind(java.lang.String propName, java.util.List whiteList, java.util.List blackList)`
`protected java.lang.Object` | `preprocessValue(java.lang.Object propertyValue)`
`protected java.lang.Object` | `processIndexedProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)`
`protected java.lang.Object` | `processProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)`
`void` | `registerConverter(ValueConverter converter)`
`void` | `registerFormattedValueConverter(FormattedValueConverter converter)`
`void` | `registerStructuredEditor(java.lang.Class clazz, StructuredBindingEditor editor)`
`protected java.lang.Object` | `setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener)`
`protected java.lang.Object` | `setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, boolean convertCollectionElements)`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### BASIC_TYPES

    protected static final java.util.List BASIC_TYPES

### conversionHelpers

    protected java.util.Map conversionHelpers

### formattedValueConvertersionHelpers

    protected java.util.Map formattedValueConvertersionHelpers

### structuredEditors

    protected java.util.Map structuredEditors

Property Detail

### INDEXED_PROPERTY_REGEX

    static final java.lang.Object INDEXED_PROPERTY_REGEX

### autoGrowCollectionLimit

    int autoGrowCollectionLimit

### conversionService

    ConversionService conversionService

Constructor Detail

### SimpleDataBinder

    SimpleDataBinder()

Method Detail

### addBindingError

    protected java.lang.Object addBindingError(java.lang.Object obj, java.lang.String propName, java.lang.Object propertyValue, java.lang.Exception e, DataBindingListener listener, java.lang.Object errors)

### addElementToArrayAt

    @groovy.transform.CompileStatic(TypeCheckingMode.SKIP)
    protected java.lang.Object addElementToArrayAt(java.lang.Object array, java.lang.Object index, java.lang.Object val)

### addElementToCollection

    protected java.lang.Object addElementToCollection(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, java.lang.Object propertyValue, boolean clearCollection)

### addElementToCollectionAt

    @groovy.transform.CompileStatic(TypeCheckingMode.SKIP)
    protected java.lang.Object addElementToCollectionAt(java.lang.Object obj, java.lang.String propertyName, java.util.Collection collection, java.lang.Object index, java.lang.Object val)

### bind

    void bind(java.lang.Object obj, DataBindingSource source)

  Parameters:
    `obj` - The object being bound to
    `source` - The data binding source
  See Also:
    DataBindingSource

### bind

    void bind(java.lang.Object obj, DataBindingSource source, DataBindingListener listener)

  Parameters:
    `obj` - The object being bound to
    `source` - The data binding source
    `listener` - A listener which will be notified of data binding events triggered by this binding
  See Also:
    DataBindingSource
    DataBindingListener

### bind

    void bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList)

  Parameters:
    `obj` - The object being bound to
    `source` - The data binding source
    `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
  See Also:
    DataBindingSource

### bind

    void bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList, java.util.List blackList)

  Parameters:
    `obj` - The object being bound to
    `source` - The data binding source
    `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
    `blackList` - A list of properties names to be excluded during this data binding.
  See Also:
    DataBindingSource

### bind

    void bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath)

  Parameters:
    `obj` - The object being bound to
    `gpath` - A GPathResult which represents the data being bound.
  See Also:
    DataBindingSource

### bind

    void bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList)

  Parameters:
    `obj` - The object being bound to
    `source` - The data binding source
    `filter` - Only properties beginning with filter will be included in the data binding. For example, if filter is "person" and the binding source contains data for properties "person.name" and "author.name" the value of "person.name" will be bound to obj.name. The value of "author.name" will be ignored.
    `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
    `blackList` - A list of properties names to be excluded during this data binding.
  See Also:
    DataBindingSource

### bind

    void bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)

  Parameters:
    `obj` - The object being bound to
    `source` - The data binding source
    `filter` - Only properties beginning with filter will be included in the data binding. For example, if filter is "person" and the binding source contains data for properties "person.name" and "author.name" the value of "person.name" will be bound to obj.name. The value of "author.name" will be ignored.
    `whiteList` - A list of property names to be included during this data binding. All other properties represented in the binding source will be ignored
    `blackList` - A list of properties names to be excluded during this data binding.
    `listener` - A listener which will be notified of data binding events triggered by this binding
  See Also:
    DataBindingSource
    DataBindingListener

### bindProperty

    protected java.lang.Object bindProperty(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, java.lang.Object errors)

### convert

    protected java.lang.Object convert(java.lang.Class typeToConvertTo, java.lang.Object value)

### convertStringToEnum

    @groovy.transform.CompileStatic(TypeCheckingMode.SKIP)
    protected java.lang.Object convertStringToEnum(java.lang.Class enumClass, java.lang.String value)

### doBind

    protected void doBind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener, java.lang.Object errors)

### getConverter

    protected ValueConverter getConverter(java.lang.Class typeToConvertTo, java.lang.Object value)

### getDefaultCollectionInstanceForType

    protected java.lang.Object getDefaultCollectionInstanceForType(java.lang.Class type)

### getField

    protected java.lang.reflect.Field getField(java.lang.Class clazz, java.lang.String fieldName)

### getFormatString

    protected java.lang.String getFormatString(BindingFormat annotation)

### getFormattedConverter

    protected ValueConverter getFormattedConverter(java.lang.reflect.Field field, java.lang.String formattingValue)

  Get a ValueConverter for field
  Parameters:
    `field` - The field to retrieve a converter for
    `formattingValue` - The format that the converter will use
  Returns:
    a ValueConverter for field which uses formattingValue for its format
  See Also:
    BindingFormat

### getIndexedPropertyReferenceDescriptor

    protected IndexedPropertyReferenceDescriptor getIndexedPropertyReferenceDescriptor(java.lang.Object propName)

### getReferencedTypeForCollection

    protected java.lang.Class getReferencedTypeForCollection(java.lang.String propertyName, java.lang.Object obj)

### getReferencedTypeForCollectionInClass

    protected java.lang.Class getReferencedTypeForCollectionInClass(java.lang.String propertyName, java.lang.Class clazz)

### getValueConverter

    protected ValueConverter getValueConverter(java.lang.Object obj, java.lang.String propName)

### getValueConverterForClass

    protected ValueConverter getValueConverterForClass(java.lang.Object obj, java.lang.String propName)

### getValueConverterForField

    protected ValueConverter getValueConverterForField(java.lang.Object obj, java.lang.String propName)

### initializeArray

    @groovy.transform.CompileStatic(TypeCheckingMode.SKIP)
    protected java.lang.Object initializeArray(java.lang.Object obj, java.lang.String propertyName, java.lang.Class arrayType, int index)

### initializeCollection

    protected java.util.Collection initializeCollection(java.lang.Object obj, java.lang.String propertyName, java.lang.Class type, boolean reuseExistingCollectionIfExists = true)

### initializeMap

    protected java.util.Map initializeMap(java.lang.Object obj, java.lang.String propertyName)

### initializeProperty

    protected java.lang.Object initializeProperty(java.lang.Object obj, java.lang.String propName, java.lang.Class propertyType, DataBindingSource source)

### isBasicType

    protected boolean isBasicType(java.lang.Class c)

### isOkToAddElementAt

    protected boolean isOkToAddElementAt(java.util.Collection collection, int index)

### isOkToBind

    protected java.lang.Object isOkToBind(java.lang.String propName, java.util.List whiteList, java.util.List blackList)

### preprocessValue

    protected java.lang.Object preprocessValue(java.lang.Object propertyValue)

### processIndexedProperty

    protected java.lang.Object processIndexedProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)

### processProperty

    protected java.lang.Object processProperty(java.lang.Object obj, groovy.lang.MetaProperty metaProperty, java.lang.Object val, DataBindingSource source, DataBindingListener listener, java.lang.Object errors)

### registerConverter

    void registerConverter(ValueConverter converter)

### registerFormattedValueConverter

    void registerFormattedValueConverter(FormattedValueConverter converter)

### registerStructuredEditor

    void registerStructuredEditor(java.lang.Class clazz, StructuredBindingEditor editor)

### setPropertyValue

    protected java.lang.Object setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener)

### setPropertyValue

    protected java.lang.Object setPropertyValue(java.lang.Object obj, DataBindingSource source, groovy.lang.MetaProperty metaProperty, java.lang.Object propertyValue, DataBindingListener listener, boolean convertCollectionElements)

Groovy Documentation