/** * Find a default editor for the given type. * @param requiredType the type to find an editor for * @return the corresponding editor, or {@code null} if none */ @Nullable private PropertyEditor findDefaultEditor(@Nullable Class<?> requiredType) { PropertyEditor editor = null; if (requiredType != null) { // No custom editor -> check BeanWrapperImpl's default editors. editor = this.propertyEditorRegistry.getDefaultEditor(requiredType); if (editor == null && String.class != requiredType) { // No BeanWrapper default editor -> check standard JavaBean editor. editor = BeanUtils.findEditorByConvention(requiredType); } } return editor; }
/** * Find a default editor for the given type. * @param requiredType the type to find an editor for * @return the corresponding editor, or {@code null} if none */ @Nullable private PropertyEditor findDefaultEditor(@Nullable Class<?> requiredType) { PropertyEditor editor = null; if (requiredType != null) { // No custom editor -> check BeanWrapperImpl's default editors. editor = this.propertyEditorRegistry.getDefaultEditor(requiredType); if (editor == null && String.class != requiredType) { // No BeanWrapper default editor -> check standard JavaBean editor. editor = BeanUtils.findEditorByConvention(requiredType); } } return editor; }
/** * Find a default editor for the given type. * @param requiredType the type to find an editor for * @param descriptor the JavaBeans descriptor for the property * @return the corresponding editor, or <code>null</code> if none */ protected PropertyEditor findDefaultEditor(Class requiredType, TypeDescriptor typeDescriptor) { PropertyEditor editor = null; //if (typeDescriptor instanceof PropertyTypeDescriptor) { //PropertyDescriptor pd = ((PropertyTypeDescriptor) typeDescriptor).getPropertyDescriptor(); //editor = pd.createPropertyEditor(this.targetObject); //} if (editor == null && requiredType != null) { // No custom editor -> check BeanWrapperImpl's default editors. editor = this.propertyEditorRegistry.getDefaultEditor(requiredType); if (editor == null && !String.class.equals(requiredType)) { // No BeanWrapper default editor -> check standard JavaBean editor. editor = BeanUtils.findEditorByConvention(requiredType); } } return editor; }
/** * Gets the default editor. * * @param clazz the clazz * @return the default editor */ private PropertyEditor getDefaultEditor(Class<?> clazz) { return m_editorRegistry.getDefaultEditor(clazz); }
private PropertyEditor getDefaultEditor(Class<?> clazz) { return m_editorRegistry.getDefaultEditor(clazz); } }
private PropertyEditor getDefaultEditor(Class<?> clazz) { return m_editorRegistry.getDefaultEditor(clazz); } }
/** * Find a default editor for the given type. * @param requiredType the type to find an editor for * @return the corresponding editor, or {@code null} if none */ private PropertyEditor findDefaultEditor(Class<?> requiredType) { PropertyEditor editor = null; if (requiredType != null) { // No custom editor -> check BeanWrapperImpl's default editors. editor = this.propertyEditorRegistry.getDefaultEditor(requiredType); if (editor == null && String.class != requiredType) { // No BeanWrapper default editor -> check standard JavaBean editor. editor = BeanUtils.findEditorByConvention(requiredType); } } return editor; }
/** * Find a default editor for the given type. This code is based on <tt>TypeConverterDelegate.findDefaultEditor</tt>. * @param requiredType the type to find an editor for * @param typeDescriptor the type description of the property * @return the corresponding editor, or <code>null</code> if none * * @param propertyEditorRegistry * @param targetObject * * @author Juergen Hoeller * @author Rob Harrop */ protected PropertyEditor findDefaultEditor(PropertyEditorRegistrySupport propertyEditorRegistry, Object targetObject, Class<?> requiredType, TypeDescriptor typeDescriptor) { PropertyEditor editor = null; if (requiredType != null) { // No custom editor -> check BeanWrapperImpl's default editors. editor = propertyEditorRegistry.getDefaultEditor(requiredType); if (editor == null && !String.class.equals(requiredType)) { // No BeanWrapper default editor -> check standard JavaBean editor. editor = BeanUtils.findEditorByConvention(requiredType); } } return editor; }
@Override public void setValue(Object value) { if (value == null || value instanceof String) { super.setValue(value); } else { PropertyEditor editor = editorRegistry.findCustomEditor(value.getClass(), null); if (editor == null) { editor = editorRegistrySupport.getDefaultEditor(value.getClass()); } if (editor != null) { editor.setValue(value); super.setValue(editor.getAsText()); } else if (Enum.class.isAssignableFrom(value.getClass())) { super.setValue(String.valueOf(value)); } else { throw new IllegalArgumentException("Unable to convert " + value.getClass() + " to String. No PropertyEditor found."); } } }
editor = (PropertyEditor) this.propertyEditorRegistry.getDefaultEditor(requiredType); if (editor == null && !String.class.equals(requiredType)) {