Groovy Documentation

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
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 addElementToArrayAt(java.lang.Object array, java.lang.Object index, java.lang.Object val)

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, java.util.Map source)

@param obj the object to perform data binding on

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

@param obj the object to perform data binding on

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

@param obj the object to perform data binding on

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

@param obj the object to perform data binding on

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

@param obj the object to perform data binding on

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

@param obj the object to perform data binding on

protected java.lang.Object bindProperty(java.lang.Object obj, java.util.Map source, java.lang.String propName, java.lang.Object propertyValue, DataBindingListener listener)

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 ValueConverter getConverter(java.lang.Class typeToConvertTo, java.lang.Object value)

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 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)

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, java.util.Map source)

protected boolean isBasicType(java.lang.Class c)

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

protected java.lang.Object processProperty(java.lang.Object obj, java.lang.String propName, java.lang.Object val, java.util.Map source, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)

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, java.util.Map source, java.lang.String propName, java.lang.Object propertyValue)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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

addElementToArrayAt

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


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, java.util.Map source)
Parameters:
obj - the object to perform data binding on
source - a Map containg the values to be bound to obj


bind

void bind(java.lang.Object obj, java.util.Map source, DataBindingListener listener)
Parameters:
obj - the object to perform data binding on
source - a Map containg the values to be bound to obj
listener - will be notified of data binding events


bind

void bind(java.lang.Object obj, java.util.Map source, java.util.List whiteList)
Parameters:
obj - the object to perform data binding on
source - a Map containg the values to be bound to obj
whiteList - A list of properties that are eligible for binding, if null all properties are eligible for binding


bind

void bind(java.lang.Object obj, java.util.Map source, java.util.List whiteList, java.util.List blackList)
Parameters:
obj - the object to perform data binding on
source - a Map containg the values to be bound to obj
whiteList - A list of properties that are eligible for binding, if null all properties are eligible for binding
blackList - A list of properties to exclude from binding


bind

void bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath)
Parameters:
obj - the object to perform data binding on
gpath - contains an XML representation of the data to be bound to obj


bind

void bind(java.lang.Object obj, java.util.Map source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)
Parameters:
obj - the object to perform data binding on
source - a Map containg the values to be bound to obj
whiteList - A list of properties that are eligible for binding, if null all properties are eligible for binding
blackList - A list of properties to exclude from binding


bindProperty

protected java.lang.Object bindProperty(java.lang.Object obj, java.util.Map source, java.lang.String propName, java.lang.Object propertyValue, DataBindingListener listener)


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)


getConverter

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


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)


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

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)


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, java.util.Map source)


isBasicType

protected boolean isBasicType(java.lang.Class c)


isOkToBind

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


processProperty

protected java.lang.Object processProperty(java.lang.Object obj, java.lang.String propName, java.lang.Object val, java.util.Map source, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)


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, java.util.Map source, java.lang.String propName, java.lang.Object propertyValue)


 

Groovy Documentation