@CompileStatic class SimpleDataBinder extends Object implements DataBinder
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'
Modifiers | Name | Description |
---|---|---|
protected static List<Class> |
BASIC_TYPES |
|
protected Map<Class, List<ValueConverter>> |
conversionHelpers |
|
protected Map<Class, FormattedValueConverter> |
formattedValueConversionHelpers |
|
protected Map<Class, StructuredBindingEditor> |
structuredEditors |
Type | Name and description |
---|---|
static Object |
INDEXED_PROPERTY_REGEX |
int |
autoGrowCollectionLimit |
ConversionService |
conversionService |
Constructor and description |
---|
SimpleDataBinder() |
Type Params | Return Type | Name and description |
---|---|---|
|
protected void |
addBindingError(Object obj, String propName, Object propertyValue, Exception e, DataBindingListener listener, Object errors) |
|
protected Object |
addElementToArrayAt(Object[] array, int index, Object val) |
|
protected boolean |
addElementToCollection(Object obj, String propName, Class propertyType, Object propertyValue, boolean clearCollection) |
|
protected void |
addElementToCollectionAt(Object obj, String propertyName, Collection collection, int index, Object val) |
|
void |
bind(Object obj, DataBindingSource source)
|
|
void |
bind(Object obj, DataBindingSource source, DataBindingListener listener)
|
|
void |
bind(Object obj, DataBindingSource source, List whiteList)
|
|
void |
bind(Object obj, DataBindingSource source, List whiteList, List blackList)
|
|
void |
bind(Object obj, GPathResult gpath)
|
|
void |
bind(Object obj, DataBindingSource source, String filter, List whiteList, List blackList)
|
|
void |
bind(Object obj, DataBindingSource source, String filter, List whiteList, List blackList, DataBindingListener listener)
|
|
protected Object |
bindProperty(Object obj, DataBindingSource source, MetaProperty metaProperty, Object propertyValue, DataBindingListener listener, Object errors) |
|
protected Object |
convert(Class typeToConvertTo, Object value) |
|
protected Object |
convertStringToEnum(Class<? extends Enum> enumClass, String value) |
|
protected void |
doBind(Object obj, DataBindingSource source, String filter, List whiteList, List blackList, DataBindingListener listener, Object errors) |
|
protected ValueConverter |
getConverter(Class typeToConvertTo, Object value) |
|
protected Object |
getDefaultCollectionInstanceForType(Class type) |
|
protected Field |
getField(Class clazz, String fieldName) |
|
protected String |
getFormatString(Annotation annotation)
|
|
protected ValueConverter |
getFormattedConverter(Field field, String formattingValue) Get a ValueConverter for field |
|
protected IndexedPropertyReferenceDescriptor |
getIndexedPropertyReferenceDescriptor(String propName) |
|
protected ValueInitializer |
getPropertyInitializer(Object obj, String propName) |
|
protected Class<?> |
getReferencedTypeForCollection(String propertyName, Object obj) |
|
protected Class<?> |
getReferencedTypeForCollectionInClass(String propertyName, Class clazz) |
|
protected ValueConverter |
getValueConverter(Object obj, String propName) |
|
protected ValueConverter |
getValueConverterForClass(Object obj, String propName) |
|
protected ValueConverter |
getValueConverterForField(Object obj, String propName) |
|
protected ValueInitializer |
getValueInitializerForField(Object obj, String propName) |
|
protected Class |
getValueOfBindInitializer(Annotation annotation)
|
|
protected Class |
getValueOfBindUsing(Annotation annotation)
|
|
protected Object[] |
initializeArray(Object obj, String propertyName, Class arrayType, int index) |
|
protected Collection |
initializeCollection(Object obj, String propertyName, Class type, boolean reuseExistingCollectionIfExists) |
|
protected Map |
initializeMap(Object obj, String propertyName) |
|
protected void |
initializeProperty(Object obj, String propName, Class propertyType, DataBindingSource source) |
|
protected boolean |
isBasicType(Class c) |
|
protected boolean |
isOkToAddElementAt(Collection collection, int index) |
|
protected boolean |
isOkToBind(String propName, List whiteList, List blackList) |
|
protected boolean |
isOkToBind(MetaProperty property, List whitelist, List blacklist) |
|
protected Object |
preprocessValue(Object propertyValue) |
|
protected void |
processIndexedProperty(Object obj, MetaProperty metaProperty, IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, Object val, DataBindingSource source, DataBindingListener listener, Object errors) |
|
protected void |
processProperty(Object obj, MetaProperty metaProperty, Object val, DataBindingSource source, DataBindingListener listener, Object errors) |
|
void |
registerConverter(ValueConverter converter) |
|
void |
registerFormattedValueConverter(FormattedValueConverter converter) |
|
void |
registerStructuredEditor(Class clazz, StructuredBindingEditor editor) |
|
protected void |
setPropertyValue(Object obj, DataBindingSource source, MetaProperty metaProperty, Object propertyValue, DataBindingListener listener) |
|
protected void |
setPropertyValue(Object obj, DataBindingSource source, MetaProperty metaProperty, Object propertyValue, DataBindingListener listener, boolean convertCollectionElements) |
|
protected SimpleMapDataBindingSource |
splitIndexedStruct(IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, DataBindingSource source) |
obj
- The object being bound tosource
- The data binding source
obj
- The object being bound tosource
- The data binding sourcelistener
- A listener which will be notified of data binding events triggered
by this binding
obj
- The object being bound tosource
- The data binding sourcewhiteList
- A list of property names to be included during this data binding.
All other properties represented in the binding source will be ignored.
obj
- The object being bound tosource
- The data binding sourcewhiteList
- A list of property names to be included during this data binding.
All other properties represented in the binding source will be ignoredblackList
- A list of properties names to be excluded during this data binding.
obj
- The object being bound togpath
- A GPathResult which represents the data being bound.
obj
- The object being bound tosource
- The data binding sourcefilter
- 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 ignoredblackList
- A list of properties names to be excluded during this data binding.
obj
- The object being bound tosource
- The data binding sourcefilter
- 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 ignoredblackList
- 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
annotation
- An instance of grails.databinding.BindingFormat or org.grails.databinding.BindingFormatGet a ValueConverter for field
field
- The field to retrieve a converter forformattingValue
- The format that the converter will use
annotation
- An instance of grails.databinding.BindInitializer
annotation
- An instance of grails.databinding.BindingUsing or org.grails.databinding.BindingUsing