/** * Determines the field type from the property type. * @see #getPropertyAccessor() */ @Override @Nullable public Class<?> getFieldType(@Nullable String field) { return (getTarget() != null ? getPropertyAccessor().getPropertyType(fixedField(field)) : super.getFieldType(field)); }
/** * Determines the field type from the property type. * @see #getPropertyAccessor() */ @Override @Nullable public Class<?> getFieldType(@Nullable String field) { return (getTarget() != null ? getPropertyAccessor().getPropertyType(fixedField(field)) : super.getFieldType(field)); }
/** * This implementation exposes a PropertyEditor adapter for a Formatter, * if applicable. */ @Override @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) { Class<?> valueTypeForLookup = valueType; if (valueTypeForLookup == null) { valueTypeForLookup = getFieldType(field); } PropertyEditor editor = super.findEditor(field, valueTypeForLookup); if (editor == null && this.conversionService != null) { TypeDescriptor td = null; if (field != null && getTarget() != null) { TypeDescriptor ptd = getPropertyAccessor().getPropertyTypeDescriptor(fixedField(field)); if (ptd != null && (valueType == null || valueType.isAssignableFrom(ptd.getType()))) { td = ptd; } } if (td == null) { td = TypeDescriptor.valueOf(valueTypeForLookup); } if (this.conversionService.canConvert(TypeDescriptor.valueOf(String.class), td)) { editor = new ConvertingPropertyEditorAdapter(this.conversionService, td); } } return editor; }
/** * Formats the field value based on registered PropertyEditors. * @see #getCustomEditor */ @Override protected Object formatFieldValue(String field, @Nullable Object value) { String fixedField = fixedField(field); // Try custom editor... PropertyEditor customEditor = getCustomEditor(fixedField); if (customEditor != null) { customEditor.setValue(value); String textValue = customEditor.getAsText(); // If the PropertyEditor returned null, there is no appropriate // text representation for this value: only use it if non-null. if (textValue != null) { return textValue; } } if (this.conversionService != null) { // Try custom converter... TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField); TypeDescriptor strDesc = TypeDescriptor.valueOf(String.class); if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, strDesc)) { return this.conversionService.convert(value, fieldDesc, strDesc); } } return value; }
/** * This implementation exposes a PropertyEditor adapter for a Formatter, * if applicable. */ @Override @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) { Class<?> valueTypeForLookup = valueType; if (valueTypeForLookup == null) { valueTypeForLookup = getFieldType(field); } PropertyEditor editor = super.findEditor(field, valueTypeForLookup); if (editor == null && this.conversionService != null) { TypeDescriptor td = null; if (field != null && getTarget() != null) { TypeDescriptor ptd = getPropertyAccessor().getPropertyTypeDescriptor(fixedField(field)); if (ptd != null && (valueType == null || valueType.isAssignableFrom(ptd.getType()))) { td = ptd; } } if (td == null) { td = TypeDescriptor.valueOf(valueTypeForLookup); } if (this.conversionService.canConvert(TypeDescriptor.valueOf(String.class), td)) { editor = new ConvertingPropertyEditorAdapter(this.conversionService, td); } } return editor; }
/** * Formats the field value based on registered PropertyEditors. * @see #getCustomEditor */ @Override protected Object formatFieldValue(String field, @Nullable Object value) { String fixedField = fixedField(field); // Try custom editor... PropertyEditor customEditor = getCustomEditor(fixedField); if (customEditor != null) { customEditor.setValue(value); String textValue = customEditor.getAsText(); // If the PropertyEditor returned null, there is no appropriate // text representation for this value: only use it if non-null. if (textValue != null) { return textValue; } } if (this.conversionService != null) { // Try custom converter... TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField); TypeDescriptor strDesc = TypeDescriptor.valueOf(String.class); if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, strDesc)) { return this.conversionService.convert(value, fieldDesc, strDesc); } } return value; }
/** * Determines the field type from the property type. * @see #getPropertyAccessor() */ @Override @Nullable public Class<?> getFieldType(@Nullable String field) { return (getTarget() != null ? getPropertyAccessor().getPropertyType(fixedField(field)) : super.getFieldType(field)); }
/** * This implementation exposes a PropertyEditor adapter for a Formatter, * if applicable. */ @Override @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) { Class<?> valueTypeForLookup = valueType; if (valueTypeForLookup == null) { valueTypeForLookup = getFieldType(field); } PropertyEditor editor = super.findEditor(field, valueTypeForLookup); if (editor == null && this.conversionService != null) { TypeDescriptor td = null; if (field != null && getTarget() != null) { TypeDescriptor ptd = getPropertyAccessor().getPropertyTypeDescriptor(fixedField(field)); if (ptd != null && (valueType == null || valueType.isAssignableFrom(ptd.getType()))) { td = ptd; } } if (td == null) { td = TypeDescriptor.valueOf(valueTypeForLookup); } if (this.conversionService.canConvert(TypeDescriptor.valueOf(String.class), td)) { editor = new ConvertingPropertyEditorAdapter(this.conversionService, td); } } return editor; }
/** * Formats the field value based on registered PropertyEditors. * @see #getCustomEditor */ @Override protected Object formatFieldValue(String field, @Nullable Object value) { String fixedField = fixedField(field); // Try custom editor... PropertyEditor customEditor = getCustomEditor(fixedField); if (customEditor != null) { customEditor.setValue(value); String textValue = customEditor.getAsText(); // If the PropertyEditor returned null, there is no appropriate // text representation for this value: only use it if non-null. if (textValue != null) { return textValue; } } if (this.conversionService != null) { // Try custom converter... TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField); TypeDescriptor strDesc = TypeDescriptor.valueOf(String.class); if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, strDesc)) { return this.conversionService.convert(value, fieldDesc, strDesc); } } return value; }