@groovy.transform.CompileStatic class SimpleDataBinder extends java.lang.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 java.util.List<java.lang.Class> |
BASIC_TYPES |
|
protected java.util.Map<java.lang.Class, java.util.List<ValueConverter>> |
conversionHelpers |
|
protected java.util.Map<java.lang.Class, FormattedValueConverter> |
formattedValueConversionHelpers |
|
protected java.util.Map<java.lang.Class, StructuredBindingEditor> |
structuredEditors |
Type | Name and description |
---|---|
static java.lang.Object |
INDEXED_PROPERTY_REGEX |
int |
autoGrowCollectionLimit |
ConversionService |
conversionService |
Constructor and description |
---|
SimpleDataBinder
() |
Type Params | Return Type | Name and description |
---|---|---|
|
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)
|
|
void |
bind(java.lang.Object obj, DataBindingSource source, DataBindingListener listener)
|
|
void |
bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList)
|
|
void |
bind(java.lang.Object obj, DataBindingSource source, java.util.List whiteList, java.util.List blackList)
|
|
void |
bind(java.lang.Object obj, groovy.util.slurpersupport.GPathResult gpath)
|
|
void |
bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList)
|
|
void |
bind(java.lang.Object obj, DataBindingSource source, java.lang.String filter, java.util.List whiteList, java.util.List blackList, DataBindingListener listener)
|
|
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<? extends java.lang.Enum> 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(java.lang.annotation.Annotation 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 ValueInitializer |
getPropertyInitializer(java.lang.Object obj, java.lang.String 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 ValueInitializer |
getValueInitializerForField(java.lang.Object obj, java.lang.String propName) |
|
protected java.lang.Class |
getValueOfBindInitializer(java.lang.annotation.Annotation annotation)
|
|
protected java.lang.Class |
getValueOfBindUsing(java.lang.annotation.Annotation annotation)
|
|
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) |
|
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 boolean |
isOkToBind(java.lang.String propName, java.util.List whiteList, java.util.List blackList) |
|
protected boolean |
isOkToBind(groovy.lang.MetaProperty property, 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) |
|
protected SimpleMapDataBindingSource |
splitIndexedStruct(IndexedPropertyReferenceDescriptor indexedPropertyReferenceDescriptor, DataBindingSource source) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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() |
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.BindingUsingGroovy Documentation