org.springframework.beans.PropertyEditorRegistrar

Here are the examples of the java api org.springframework.beans.PropertyEditorRegistrar taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

13 Examples 7

19 Source : ConfigurableWebBindingInitializer.java
with MIT License
from Vip-Augus

/**
 * Specify a single PropertyEditorRegistrar to be applied to every DataBinder.
 */
public final void setPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar) {
    this.propertyEditorRegistrars = new PropertyEditorRegistrar[] { propertyEditorRegistrar };
}

19 Source : ConfigurableWebBindingInitializer.java
with MIT License
from Vip-Augus

/**
 * Specify multiple PropertyEditorRegistrars to be applied to every DataBinder.
 */
public final void setPropertyEditorRegistrars(@Nullable PropertyEditorRegistrar[] propertyEditorRegistrars) {
    this.propertyEditorRegistrars = propertyEditorRegistrars;
}

19 Source : CustomEditorConfigurer.java
with MIT License
from Vip-Augus

/**
 * Specify the {@link PropertyEditorRegistrar PropertyEditorRegistrars}
 * to apply to beans defined within the current application context.
 * <p>This allows for sharing {@code PropertyEditorRegistrars} with
 * {@link org.springframework.validation.DataBinder DataBinders}, etc.
 * Furthermore, it avoids the need for synchronization on custom editors:
 * A {@code PropertyEditorRegistrar} will always create fresh editor
 * instances for each bean creation attempt.
 * @see ConfigurableListableBeanFactory#addPropertyEditorRegistrar
 */
public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
    this.propertyEditorRegistrars = propertyEditorRegistrars;
}

19 Source : ConfigurableWebBindingInitializer.java
with Apache License 2.0
from langtianya

/**
 * Specify multiple PropertyEditorRegistrars to be applied to every DataBinder.
 */
public final void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
    this.propertyEditorRegistrars = propertyEditorRegistrars;
}

18 Source : CustomEditorConfigurer.java
with MIT License
from Vip-Augus

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertyEditorRegistrars != null) {
        for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
            beanFactory.addPropertyEditorRegistrar(propertyEditorRegistrar);
        }
    }
    if (this.customEditors != null) {
        this.customEditors.forEach(beanFactory::registerCustomEditor);
    }
}

18 Source : CustomEditorConfigurer.java
with Apache License 2.0
from langtianya

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (this.propertyEditorRegistrars != null) {
        for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
            beanFactory.addPropertyEditorRegistrar(propertyEditorRegistrar);
        }
    }
    if (this.customEditors != null) {
        for (Map.Entry<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
            Clreplaced<?> requiredType = entry.getKey();
            Clreplaced<? extends PropertyEditor> propertyEditorClreplaced = entry.getValue();
            beanFactory.registerCustomEditor(requiredType, propertyEditorClreplaced);
        }
    }
}

17 Source : CustomEditorConfigurer.java
with MIT License
from Vip-Augus

/**
 * {@link BeanFactoryPostProcessor} implementation that allows for convenient
 * registration of custom {@link PropertyEditor property editors}.
 *
 * <p>In case you want to register {@link PropertyEditor} instances,
 * the recommended usage as of Spring 2.0 is to use custom
 * {@link PropertyEditorRegistrar} implementations that in turn register any
 * desired editor instances on a given
 * {@link org.springframework.beans.PropertyEditorRegistry registry}. Each
 * PropertyEditorRegistrar can register any number of custom editors.
 *
 * <pre clreplaced="code">
 * <bean id="customEditorConfigurer" clreplaced="org.springframework.beans.factory.config.CustomEditorConfigurer">
 *   <property name="propertyEditorRegistrars">
 *     <list>
 *       <bean clreplaced="mypackage.MyCustomDateEditorRegistrar"/>
 *       <bean clreplaced="mypackage.MyObjectEditorRegistrar"/>
 *     </list>
 *   </property>
 * </bean>
 * </pre>
 *
 * <p>
 * It's perfectly fine to register {@link PropertyEditor} <em>clreplacedes</em> via
 * the {@code customEditors} property. Spring will create fresh instances of
 * them for each editing attempt then:
 *
 * <pre clreplaced="code">
 * <bean id="customEditorConfigurer" clreplaced="org.springframework.beans.factory.config.CustomEditorConfigurer">
 *   <property name="customEditors">
 *     <map>
 *       <entry key="java.util.Date" value="mypackage.MyCustomDateEditor"/>
 *       <entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/>
 *     </map>
 *   </property>
 * </bean>
 * </pre>
 *
 * <p>
 * Note, that you shouldn't register {@link PropertyEditor} bean instances via
 * the {@code customEditors} property as {@link PropertyEditor PropertyEditors} are stateful
 * and the instances will then have to be synchronized for every editing
 * attempt. In case you need control over the instantiation process of
 * {@link PropertyEditor PropertyEditors}, use a {@link PropertyEditorRegistrar} to register
 * them.
 *
 * <p>
 * Also supports "java.lang.String[]"-style array clreplaced names and primitive
 * clreplaced names (e.g. "boolean"). Delegates to {@link ClreplacedUtils} for actual
 * clreplaced name resolution.
 *
 * <p><b>NOTE:</b> Custom property editors registered with this configurer do
 * <i>not</i> apply to data binding. Custom editors for data binding need to
 * be registered on the {@link org.springframework.validation.DataBinder}:
 * Use a common base clreplaced or delegate to common PropertyEditorRegistrar
 * implementations to reuse editor registration there.
 *
 * @author Juergen Hoeller
 * @since 27.02.2004
 * @see java.beans.PropertyEditor
 * @see org.springframework.beans.PropertyEditorRegistrar
 * @see ConfigurableBeanFactory#addPropertyEditorRegistrar
 * @see ConfigurableBeanFactory#registerCustomEditor
 * @see org.springframework.validation.DataBinder#registerCustomEditor
 */
public clreplaced CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered {

    protected final Log logger = LogFactory.getLog(getClreplaced());

    // default: same as non-Ordered
    private int order = Ordered.LOWEST_PRECEDENCE;

    @Nullable
    private PropertyEditorRegistrar[] propertyEditorRegistrars;

    @Nullable
    private Map<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> customEditors;

    public void setOrder(int order) {
        this.order = order;
    }

    @Override
    public int getOrder() {
        return this.order;
    }

    /**
     * Specify the {@link PropertyEditorRegistrar PropertyEditorRegistrars}
     * to apply to beans defined within the current application context.
     * <p>This allows for sharing {@code PropertyEditorRegistrars} with
     * {@link org.springframework.validation.DataBinder DataBinders}, etc.
     * Furthermore, it avoids the need for synchronization on custom editors:
     * A {@code PropertyEditorRegistrar} will always create fresh editor
     * instances for each bean creation attempt.
     * @see ConfigurableListableBeanFactory#addPropertyEditorRegistrar
     */
    public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
        this.propertyEditorRegistrars = propertyEditorRegistrars;
    }

    /**
     * Specify the custom editors to register via a {@link Map}, using the
     * clreplaced name of the required type as the key and the clreplaced name of the
     * replacedociated {@link PropertyEditor} as value.
     * @see ConfigurableListableBeanFactory#registerCustomEditor
     */
    public void setCustomEditors(Map<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> customEditors) {
        this.customEditors = customEditors;
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        if (this.propertyEditorRegistrars != null) {
            for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
                beanFactory.addPropertyEditorRegistrar(propertyEditorRegistrar);
            }
        }
        if (this.customEditors != null) {
            this.customEditors.forEach(beanFactory::registerCustomEditor);
        }
    }
}

17 Source : CustomEditorConfigurer.java
with Apache License 2.0
from SourceHot

/**
 * {@link BeanFactoryPostProcessor} implementation that allows for convenient
 * registration of custom {@link PropertyEditor property editors}.
 *
 * <p>In case you want to register {@link PropertyEditor} instances,
 * the recommended usage as of Spring 2.0 is to use custom
 * {@link PropertyEditorRegistrar} implementations that in turn register any
 * desired editor instances on a given
 * {@link org.springframework.beans.PropertyEditorRegistry registry}. Each
 * PropertyEditorRegistrar can register any number of custom editors.
 *
 * <pre clreplaced="code">
 * <bean id="customEditorConfigurer" clreplaced="org.springframework.beans.factory.config.CustomEditorConfigurer">
 *   <property name="propertyEditorRegistrars">
 *     <list>
 *       <bean clreplaced="mypackage.MyCustomDateEditorRegistrar"/>
 *       <bean clreplaced="mypackage.MyObjectEditorRegistrar"/>
 *     </list>
 *   </property>
 * </bean>
 * </pre>
 *
 * <p>
 * It's perfectly fine to register {@link PropertyEditor} <em>clreplacedes</em> via
 * the {@code customEditors} property. Spring will create fresh instances of
 * them for each editing attempt then:
 *
 * <pre clreplaced="code">
 * <bean id="customEditorConfigurer" clreplaced="org.springframework.beans.factory.config.CustomEditorConfigurer">
 *   <property name="customEditors">
 *     <map>
 *       <entry key="java.util.Date" value="mypackage.MyCustomDateEditor"/>
 *       <entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/>
 *     </map>
 *   </property>
 * </bean>
 * </pre>
 *
 * <p>
 * Note, that you shouldn't register {@link PropertyEditor} bean instances via
 * the {@code customEditors} property as {@link PropertyEditor PropertyEditors} are stateful
 * and the instances will then have to be synchronized for every editing
 * attempt. In case you need control over the instantiation process of
 * {@link PropertyEditor PropertyEditors}, use a {@link PropertyEditorRegistrar} to register
 * them.
 *
 * <p>
 * Also supports "java.lang.String[]"-style array clreplaced names and primitive
 * clreplaced names (e.g. "boolean"). Delegates to {@link ClreplacedUtils} for actual
 * clreplaced name resolution.
 *
 * <p><b>NOTE:</b> Custom property editors registered with this configurer do
 * <i>not</i> apply to data binding. Custom editors for data binding need to
 * be registered on the {@link org.springframework.validation.DataBinder}:
 * Use a common base clreplaced or delegate to common PropertyEditorRegistrar
 * implementations to reuse editor registration there.
 *
 * @author Juergen Hoeller
 * @since 27.02.2004
 * @see java.beans.PropertyEditor
 * @see org.springframework.beans.PropertyEditorRegistrar
 * @see ConfigurableBeanFactory#addPropertyEditorRegistrar
 * @see ConfigurableBeanFactory#registerCustomEditor
 * @see org.springframework.validation.DataBinder#registerCustomEditor
 */
public clreplaced CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered {

    protected final Log logger = LogFactory.getLog(getClreplaced());

    // default: same as non-Ordered
    private int order = Ordered.LOWEST_PRECEDENCE;

    @Nullable
    private PropertyEditorRegistrar[] propertyEditorRegistrars;

    @Nullable
    private Map<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> customEditors;

    @Override
    public int getOrder() {
        return this.order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    /**
     * Specify the {@link PropertyEditorRegistrar PropertyEditorRegistrars}
     * to apply to beans defined within the current application context.
     * <p>This allows for sharing {@code PropertyEditorRegistrars} with
     * {@link org.springframework.validation.DataBinder DataBinders}, etc.
     * Furthermore, it avoids the need for synchronization on custom editors:
     * A {@code PropertyEditorRegistrar} will always create fresh editor
     * instances for each bean creation attempt.
     * @see ConfigurableListableBeanFactory#addPropertyEditorRegistrar
     */
    public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
        this.propertyEditorRegistrars = propertyEditorRegistrars;
    }

    /**
     * Specify the custom editors to register via a {@link Map}, using the
     * clreplaced name of the required type as the key and the clreplaced name of the
     * replacedociated {@link PropertyEditor} as value.
     * @see ConfigurableListableBeanFactory#registerCustomEditor
     */
    public void setCustomEditors(Map<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> customEditors) {
        this.customEditors = customEditors;
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        if (this.propertyEditorRegistrars != null) {
            for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
                beanFactory.addPropertyEditorRegistrar(propertyEditorRegistrar);
            }
        }
        if (this.customEditors != null) {
            this.customEditors.forEach(beanFactory::registerCustomEditor);
        }
    }
}

17 Source : CustomEditorConfigurer.java
with Apache License 2.0
from langtianya

/**
 * {@link BeanFactoryPostProcessor} implementation that allows for convenient
 * registration of custom {@link PropertyEditor property editors}.
 *
 * <p>In case you want to register {@link PropertyEditor} instances,
 * the recommended usage as of Spring 2.0 is to use custom
 * {@link PropertyEditorRegistrar} implementations that in turn register any
 * desired editor instances on a given
 * {@link org.springframework.beans.PropertyEditorRegistry registry}. Each
 * PropertyEditorRegistrar can register any number of custom editors.
 *
 * <pre clreplaced="code">
 * <bean id="customEditorConfigurer" clreplaced="org.springframework.beans.factory.config.CustomEditorConfigurer">
 *   <property name="propertyEditorRegistrars">
 *     <list>
 *       <bean clreplaced="mypackage.MyCustomDateEditorRegistrar"/>
 *       <bean clreplaced="mypackage.MyObjectEditorRegistrar"/>
 *     </list>
 *   </property>
 * </bean>
 * </pre>
 *
 * <p>
 * It's perfectly fine to register {@link PropertyEditor} <em>clreplacedes</em> via
 * the {@code customEditors} property. Spring will create fresh instances of
 * them for each editing attempt then:
 *
 * <pre clreplaced="code">
 * <bean id="customEditorConfigurer" clreplaced="org.springframework.beans.factory.config.CustomEditorConfigurer">
 *   <property name="customEditors">
 *     <map>
 *       <entry key="java.util.Date" value="mypackage.MyCustomDateEditor"/>
 *       <entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/>
 *     </map>
 *   </property>
 * </bean>
 * </pre>
 *
 * <p>
 * Note, that you shouldn't register {@link PropertyEditor} bean instances via
 * the {@code customEditors} property as {@link PropertyEditor}s are stateful
 * and the instances will then have to be synchronized for every editing
 * attempt. In case you need control over the instantiation process of
 * {@link PropertyEditor}s, use a {@link PropertyEditorRegistrar} to register
 * them.
 *
 * <p>
 * Also supports "java.lang.String[]"-style array clreplaced names and primitive
 * clreplaced names (e.g. "boolean"). Delegates to {@link ClreplacedUtils} for actual
 * clreplaced name resolution.
 *
 * <p><b>NOTE:</b> Custom property editors registered with this configurer do
 * <i>not</i> apply to data binding. Custom editors for data binding need to
 * be registered on the {@link org.springframework.validation.DataBinder}:
 * Use a common base clreplaced or delegate to common PropertyEditorRegistrar
 * implementations to reuse editor registration there.
 *
 * @author Juergen Hoeller
 * @since 27.02.2004
 * @see java.beans.PropertyEditor
 * @see org.springframework.beans.PropertyEditorRegistrar
 * @see ConfigurableBeanFactory#addPropertyEditorRegistrar
 * @see ConfigurableBeanFactory#registerCustomEditor
 * @see org.springframework.validation.DataBinder#registerCustomEditor
 */
public clreplaced CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered {

    protected final Log logger = LogFactory.getLog(getClreplaced());

    // default: same as non-Ordered
    private int order = Ordered.LOWEST_PRECEDENCE;

    private PropertyEditorRegistrar[] propertyEditorRegistrars;

    private Map<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> customEditors;

    public void setOrder(int order) {
        this.order = order;
    }

    @Override
    public int getOrder() {
        return this.order;
    }

    /**
     * Specify the {@link PropertyEditorRegistrar PropertyEditorRegistrars}
     * to apply to beans defined within the current application context.
     * <p>This allows for sharing {@code PropertyEditorRegistrars} with
     * {@link org.springframework.validation.DataBinder DataBinders}, etc.
     * Furthermore, it avoids the need for synchronization on custom editors:
     * A {@code PropertyEditorRegistrar} will always create fresh editor
     * instances for each bean creation attempt.
     * @see ConfigurableListableBeanFactory#addPropertyEditorRegistrar
     */
    public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
        this.propertyEditorRegistrars = propertyEditorRegistrars;
    }

    /**
     * Specify the custom editors to register via a {@link Map}, using the
     * clreplaced name of the required type as the key and the clreplaced name of the
     * replacedociated {@link PropertyEditor} as value.
     * @see ConfigurableListableBeanFactory#registerCustomEditor
     */
    public void setCustomEditors(Map<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> customEditors) {
        this.customEditors = customEditors;
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        if (this.propertyEditorRegistrars != null) {
            for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
                beanFactory.addPropertyEditorRegistrar(propertyEditorRegistrar);
            }
        }
        if (this.customEditors != null) {
            for (Map.Entry<Clreplaced<?>, Clreplaced<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
                Clreplaced<?> requiredType = entry.getKey();
                Clreplaced<? extends PropertyEditor> propertyEditorClreplaced = entry.getValue();
                beanFactory.registerCustomEditor(requiredType, propertyEditorClreplaced);
            }
        }
    }
}

15 Source : ConfigurableWebBindingInitializer.java
with MIT License
from Vip-Augus

/**
 * Convenient {@link WebBindingInitializer} for declarative configuration
 * in a Spring application context. Allows for reusing pre-configured
 * initializers with multiple controller/handlers.
 *
 * @author Juergen Hoeller
 * @since 2.5
 * @see #setDirectFieldAccess
 * @see #setMessageCodesResolver
 * @see #setBindingErrorProcessor
 * @see #setValidator(Validator)
 * @see #setConversionService(ConversionService)
 * @see #setPropertyEditorRegistrar
 */
public clreplaced ConfigurableWebBindingInitializer implements WebBindingInitializer {

    private boolean autoGrowNestedPaths = true;

    private boolean directFieldAccess = false;

    @Nullable
    private MessageCodesResolver messageCodesResolver;

    @Nullable
    private BindingErrorProcessor bindingErrorProcessor;

    @Nullable
    private Validator validator;

    @Nullable
    private ConversionService conversionService;

    @Nullable
    private PropertyEditorRegistrar[] propertyEditorRegistrars;

    /**
     * Set whether a binder should attempt to "auto-grow" a nested path that contains a null value.
     * <p>If "true", a null path location will be populated with a default object value and traversed
     * instead of resulting in an exception. This flag also enables auto-growth of collection elements
     * when accessing an out-of-bounds index.
     * <p>Default is "true" on a standard DataBinder. Note that this feature is only supported
     * for bean property access (DataBinder's default mode), not for field access.
     * @see org.springframework.validation.DataBinder#initBeanPropertyAccess()
     * @see org.springframework.validation.DataBinder#setAutoGrowNestedPaths
     */
    public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) {
        this.autoGrowNestedPaths = autoGrowNestedPaths;
    }

    /**
     * Return whether a binder should attempt to "auto-grow" a nested path that contains a null value.
     */
    public boolean isAutoGrowNestedPaths() {
        return this.autoGrowNestedPaths;
    }

    /**
     * Set whether to use direct field access instead of bean property access.
     * <p>Default is {@code false}, using bean property access.
     * Switch this to {@code true} in order to enforce direct field access.
     * @see org.springframework.validation.DataBinder#initDirectFieldAccess()
     * @see org.springframework.validation.DataBinder#initBeanPropertyAccess()
     */
    public final void setDirectFieldAccess(boolean directFieldAccess) {
        this.directFieldAccess = directFieldAccess;
    }

    /**
     * Return whether to use direct field access instead of bean property access.
     */
    public boolean isDirectFieldAccess() {
        return this.directFieldAccess;
    }

    /**
     * Set the strategy to use for resolving errors into message codes.
     * Applies the given strategy to all data binders used by this controller.
     * <p>Default is {@code null}, i.e. using the default strategy of
     * the data binder.
     * @see org.springframework.validation.DataBinder#setMessageCodesResolver
     */
    public final void setMessageCodesResolver(@Nullable MessageCodesResolver messageCodesResolver) {
        this.messageCodesResolver = messageCodesResolver;
    }

    /**
     * Return the strategy to use for resolving errors into message codes.
     */
    @Nullable
    public final MessageCodesResolver getMessageCodesResolver() {
        return this.messageCodesResolver;
    }

    /**
     * Set the strategy to use for processing binding errors, that is,
     * required field errors and {@code PropertyAccessException}s.
     * <p>Default is {@code null}, that is, using the default strategy
     * of the data binder.
     * @see org.springframework.validation.DataBinder#setBindingErrorProcessor
     */
    public final void setBindingErrorProcessor(@Nullable BindingErrorProcessor bindingErrorProcessor) {
        this.bindingErrorProcessor = bindingErrorProcessor;
    }

    /**
     * Return the strategy to use for processing binding errors.
     */
    @Nullable
    public final BindingErrorProcessor getBindingErrorProcessor() {
        return this.bindingErrorProcessor;
    }

    /**
     * Set the Validator to apply after each binding step.
     */
    public final void setValidator(@Nullable Validator validator) {
        this.validator = validator;
    }

    /**
     * Return the Validator to apply after each binding step, if any.
     */
    @Nullable
    public final Validator getValidator() {
        return this.validator;
    }

    /**
     * Specify a ConversionService which will apply to every DataBinder.
     * @since 3.0
     */
    public final void setConversionService(@Nullable ConversionService conversionService) {
        this.conversionService = conversionService;
    }

    /**
     * Return the ConversionService which will apply to every DataBinder.
     */
    @Nullable
    public final ConversionService getConversionService() {
        return this.conversionService;
    }

    /**
     * Specify a single PropertyEditorRegistrar to be applied to every DataBinder.
     */
    public final void setPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar) {
        this.propertyEditorRegistrars = new PropertyEditorRegistrar[] { propertyEditorRegistrar };
    }

    /**
     * Specify multiple PropertyEditorRegistrars to be applied to every DataBinder.
     */
    public final void setPropertyEditorRegistrars(@Nullable PropertyEditorRegistrar[] propertyEditorRegistrars) {
        this.propertyEditorRegistrars = propertyEditorRegistrars;
    }

    /**
     * Return the PropertyEditorRegistrars to be applied to every DataBinder.
     */
    @Nullable
    public final PropertyEditorRegistrar[] getPropertyEditorRegistrars() {
        return this.propertyEditorRegistrars;
    }

    @Override
    public void initBinder(WebDataBinder binder) {
        binder.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
        if (this.directFieldAccess) {
            binder.initDirectFieldAccess();
        }
        if (this.messageCodesResolver != null) {
            binder.setMessageCodesResolver(this.messageCodesResolver);
        }
        if (this.bindingErrorProcessor != null) {
            binder.setBindingErrorProcessor(this.bindingErrorProcessor);
        }
        if (this.validator != null && binder.getTarget() != null && this.validator.supports(binder.getTarget().getClreplaced())) {
            binder.setValidator(this.validator);
        }
        if (this.conversionService != null) {
            binder.setConversionService(this.conversionService);
        }
        if (this.propertyEditorRegistrars != null) {
            for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
                propertyEditorRegistrar.registerCustomEditors(binder);
            }
        }
    }
}

15 Source : ConfigurableWebBindingInitializer.java
with Apache License 2.0
from langtianya

/**
 * Convenient {@link WebBindingInitializer} for declarative configuration
 * in a Spring application context. Allows for reusing pre-configured
 * initializers with multiple controller/handlers.
 *
 * @author Juergen Hoeller
 * @since 2.5
 * @see #setDirectFieldAccess
 * @see #setMessageCodesResolver
 * @see #setBindingErrorProcessor
 * @see #setValidator(Validator)
 * @see #setConversionService(ConversionService)
 * @see #setPropertyEditorRegistrar
 */
public clreplaced ConfigurableWebBindingInitializer implements WebBindingInitializer {

    private boolean autoGrowNestedPaths = true;

    private boolean directFieldAccess = false;

    private MessageCodesResolver messageCodesResolver;

    private BindingErrorProcessor bindingErrorProcessor;

    private Validator validator;

    private ConversionService conversionService;

    private PropertyEditorRegistrar[] propertyEditorRegistrars;

    /**
     * Set whether a binder should attempt to "auto-grow" a nested path that contains a null value.
     * <p>If "true", a null path location will be populated with a default object value and traversed
     * instead of resulting in an exception. This flag also enables auto-growth of collection elements
     * when accessing an out-of-bounds index.
     * <p>Default is "true" on a standard DataBinder. Note that this feature is only supported
     * for bean property access (DataBinder's default mode), not for field access.
     * @see org.springframework.validation.DataBinder#initBeanPropertyAccess()
     * @see org.springframework.validation.DataBinder#setAutoGrowNestedPaths
     */
    public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) {
        this.autoGrowNestedPaths = autoGrowNestedPaths;
    }

    /**
     * Return whether a binder should attempt to "auto-grow" a nested path that contains a null value.
     */
    public boolean isAutoGrowNestedPaths() {
        return this.autoGrowNestedPaths;
    }

    /**
     * Set whether to use direct field access instead of bean property access.
     * <p>Default is {@code false}, using bean property access.
     * Switch this to {@code true} in order to enforce direct field access.
     * @see org.springframework.validation.DataBinder#initDirectFieldAccess()
     * @see org.springframework.validation.DataBinder#initBeanPropertyAccess()
     */
    public final void setDirectFieldAccess(boolean directFieldAccess) {
        this.directFieldAccess = directFieldAccess;
    }

    /**
     * Return whether to use direct field access instead of bean property access.
     */
    public boolean isDirectFieldAccess() {
        return directFieldAccess;
    }

    /**
     * Set the strategy to use for resolving errors into message codes.
     * Applies the given strategy to all data binders used by this controller.
     * <p>Default is {@code null}, i.e. using the default strategy of
     * the data binder.
     * @see org.springframework.validation.DataBinder#setMessageCodesResolver
     */
    public final void setMessageCodesResolver(MessageCodesResolver messageCodesResolver) {
        this.messageCodesResolver = messageCodesResolver;
    }

    /**
     * Return the strategy to use for resolving errors into message codes.
     */
    public final MessageCodesResolver getMessageCodesResolver() {
        return this.messageCodesResolver;
    }

    /**
     * Set the strategy to use for processing binding errors, that is,
     * required field errors and {@code PropertyAccessException}s.
     * <p>Default is {@code null}, that is, using the default strategy
     * of the data binder.
     * @see org.springframework.validation.DataBinder#setBindingErrorProcessor
     */
    public final void setBindingErrorProcessor(BindingErrorProcessor bindingErrorProcessor) {
        this.bindingErrorProcessor = bindingErrorProcessor;
    }

    /**
     * Return the strategy to use for processing binding errors.
     */
    public final BindingErrorProcessor getBindingErrorProcessor() {
        return this.bindingErrorProcessor;
    }

    /**
     * Set the Validator to apply after each binding step.
     */
    public final void setValidator(Validator validator) {
        this.validator = validator;
    }

    /**
     * Return the Validator to apply after each binding step, if any.
     */
    public final Validator getValidator() {
        return this.validator;
    }

    /**
     * Specify a ConversionService which will apply to every DataBinder.
     * @since 3.0
     */
    public final void setConversionService(ConversionService conversionService) {
        this.conversionService = conversionService;
    }

    /**
     * Return the ConversionService which will apply to every DataBinder.
     */
    public final ConversionService getConversionService() {
        return this.conversionService;
    }

    /**
     * Specify a single PropertyEditorRegistrar to be applied to every DataBinder.
     */
    public final void setPropertyEditorRegistrar(PropertyEditorRegistrar propertyEditorRegistrar) {
        this.propertyEditorRegistrars = new PropertyEditorRegistrar[] { propertyEditorRegistrar };
    }

    /**
     * Specify multiple PropertyEditorRegistrars to be applied to every DataBinder.
     */
    public final void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) {
        this.propertyEditorRegistrars = propertyEditorRegistrars;
    }

    /**
     * Return the PropertyEditorRegistrars to be applied to every DataBinder.
     */
    public final PropertyEditorRegistrar[] getPropertyEditorRegistrars() {
        return this.propertyEditorRegistrars;
    }

    @Override
    public void initBinder(WebDataBinder binder, WebRequest request) {
        binder.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
        if (this.directFieldAccess) {
            binder.initDirectFieldAccess();
        }
        if (this.messageCodesResolver != null) {
            binder.setMessageCodesResolver(this.messageCodesResolver);
        }
        if (this.bindingErrorProcessor != null) {
            binder.setBindingErrorProcessor(this.bindingErrorProcessor);
        }
        if (this.validator != null && binder.getTarget() != null && this.validator.supports(binder.getTarget().getClreplaced())) {
            binder.setValidator(this.validator);
        }
        if (this.conversionService != null) {
            binder.setConversionService(this.conversionService);
        }
        if (this.propertyEditorRegistrars != null) {
            for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
                propertyEditorRegistrar.registerCustomEditors(binder);
            }
        }
    }
}

10 Source : ConfigurableWebBindingInitializer.java
with MIT License
from Vip-Augus

@Override
public void initBinder(WebDataBinder binder) {
    binder.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
    if (this.directFieldAccess) {
        binder.initDirectFieldAccess();
    }
    if (this.messageCodesResolver != null) {
        binder.setMessageCodesResolver(this.messageCodesResolver);
    }
    if (this.bindingErrorProcessor != null) {
        binder.setBindingErrorProcessor(this.bindingErrorProcessor);
    }
    if (this.validator != null && binder.getTarget() != null && this.validator.supports(binder.getTarget().getClreplaced())) {
        binder.setValidator(this.validator);
    }
    if (this.conversionService != null) {
        binder.setConversionService(this.conversionService);
    }
    if (this.propertyEditorRegistrars != null) {
        for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
            propertyEditorRegistrar.registerCustomEditors(binder);
        }
    }
}

9 Source : ConfigurableWebBindingInitializer.java
with Apache License 2.0
from langtianya

@Override
public void initBinder(WebDataBinder binder, WebRequest request) {
    binder.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
    if (this.directFieldAccess) {
        binder.initDirectFieldAccess();
    }
    if (this.messageCodesResolver != null) {
        binder.setMessageCodesResolver(this.messageCodesResolver);
    }
    if (this.bindingErrorProcessor != null) {
        binder.setBindingErrorProcessor(this.bindingErrorProcessor);
    }
    if (this.validator != null && binder.getTarget() != null && this.validator.supports(binder.getTarget().getClreplaced())) {
        binder.setValidator(this.validator);
    }
    if (this.conversionService != null) {
        binder.setConversionService(this.conversionService);
    }
    if (this.propertyEditorRegistrars != null) {
        for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
            propertyEditorRegistrar.registerCustomEditors(binder);
        }
    }
}