@Override @Nullable public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) { return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath); }
@Override @Nullable public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) { return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath); }
/** * This implementation delegates to the * {@link #getPropertyEditorRegistry() PropertyEditorRegistry}'s * editor lookup facility, if available. */ @Override @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) { PropertyEditorRegistry editorRegistry = getPropertyEditorRegistry(); if (editorRegistry != null) { Class<?> valueTypeToUse = valueType; if (valueTypeToUse == null) { valueTypeToUse = getFieldType(field); } return editorRegistry.findCustomEditor(valueTypeToUse, fixedField(field)); } else { return null; } }
/** * This implementation delegates to the * {@link #getPropertyEditorRegistry() PropertyEditorRegistry}'s * editor lookup facility, if available. */ @Override @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) { PropertyEditorRegistry editorRegistry = getPropertyEditorRegistry(); if (editorRegistry != null) { Class<?> valueTypeToUse = valueType; if (valueTypeToUse == null) { valueTypeToUse = getFieldType(field); } return editorRegistry.findCustomEditor(valueTypeToUse, fixedField(field)); } else { return null; } }
protected final String convertToString(Class<?> type, Object value, TypeConverter converter) { if (value instanceof String) { return (String) value; } else { if (converter instanceof PropertyEditorRegistry && type != null && type.isInstance(value)) { PropertyEditor editor = ((PropertyEditorRegistry) converter).findCustomEditor(type, null); if (editor != null) { editor.setValue(value); return editor.getAsText(); } } return (String) getTypeConverter().convertIfNecessary(value, String.class); } }
protected final String convertToString(Class<?> type, Object value, TypeConverter converter) { if (value instanceof String) { return (String) value; } else { if (converter instanceof PropertyEditorRegistry && type != null && type.isInstance(value)) { PropertyEditor editor = ((PropertyEditorRegistry) converter).findCustomEditor(type, null); if (editor != null) { editor.setValue(value); return editor.getAsText(); } } return (String) getTypeConverter().convertIfNecessary(value, String.class); } }
@Override @Nullable public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) { return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath); }
private Object convertJsonValue(Object pvValue, String path) { if(path != null && propertyEditorRegistry != null && (convertAllMapValues || path.startsWith("("+ objectName + ")."))){ String p = path.replaceAll("^\\("+ objectName + "\\).","").replaceAll("\\).\\[","\\)\\["); PropertyEditor ce = propertyEditorRegistry.findCustomEditor(pvValue.getClass(), p); if(ce == null) return pvValue; else{ ce.setValue(pvValue); return ce.getAsText(); } }else return pvValue; }
public String convert(MultipartFile source) { PropertyEditor editor = accessor.findCustomEditor(MultipartFile.class, null); if (editor == null) { throw new IllegalStateException("Cannot convert source of type " + source.getClass() + " to type: String"); } editor.setValue(source); return editor.getAsText(); }
/** * Returns the actual typed id. Looks up an available customly registered {@link PropertyEditor} from the * {@link PropertyEditorRegistry} before falling back on a {@link SimpleTypeConverter} to translate the {@link String} * id into the type one. * * @param idAsString * @return */ @SuppressWarnings("unchecked") private ID getId(String idAsString) { Class<ID> idClass = information.getIdType(); PropertyEditor idEditor = registry.findCustomEditor(idClass, null); if (idEditor != null) { idEditor.setAsText(idAsString); return (ID) idEditor.getValue(); } return new SimpleTypeConverter().convertIfNecessary(idAsString, idClass); }
/** * This implementation delegates to the * {@link #getPropertyEditorRegistry() PropertyEditorRegistry}'s * editor lookup facility, if available. */ @Override @Nullable public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) { PropertyEditorRegistry editorRegistry = getPropertyEditorRegistry(); if (editorRegistry != null) { Class<?> valueTypeToUse = valueType; if (valueTypeToUse == null) { valueTypeToUse = getFieldType(field); } return editorRegistry.findCustomEditor(valueTypeToUse, fixedField(field)); } else { return null; } }
@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."); } } }
public void convertAnother(Object item, Converter converter) { PropertyEditor pe = null; PropertyEditorRegistryConverterLookup lookup = (PropertyEditorRegistryConverterLookup) converterLookup; if (lookup.existsPropertyEditorRegistry()) { String path = pathTracker.getPath().toString(); String p = path.replaceAll("^map\\(" + lookup.getBindingResult().getObjectName() + "\\).", ""); if (path.equals(p) && convertAllMapValues) { p = path.replaceAll("^map", ""); pe = lookup.getPropertyEditorRegistry().findCustomEditor( item.getClass(), p); } else if (!path.equals(p)) { pe = lookup.getPropertyEditorRegistry().findCustomEditor(item.getClass(), p); } } if (pe != null) { converter = new CustomEditorConverter(pe); } super.convertAnother(item, converter); } }
protected final String convertToString(Class<?> type, Object value, TypeConverter converter) { if (value instanceof String) { return (String) value; } else { if (converter instanceof PropertyEditorRegistry && type != null && type.isInstance(value)) { PropertyEditor editor = ((PropertyEditorRegistry) converter).findCustomEditor(type, null); if (editor != null) { editor.setValue(value); return editor.getAsText(); } } return (String) getTypeConverter().convertIfNecessary(value, String.class); } }
Class<?> propertyType = PropertyUtils.getPropertyType(value, propertyName); Object propertyValue = PropertyUtils.getNestedProperty(value, propertyName); PropertyEditor editor = registry.findCustomEditor(propertyType, registryPropertyNamePrefix + propertyName); if (editor == null) { label.append(propertyValue);
protected final String convertToString(Class<?> type, Object value, TypeConverter converter) { if (value instanceof String) { return (String) value; } else { if (converter instanceof PropertyEditorRegistry && type != null && type.isInstance(value)) { PropertyEditor editor = ((PropertyEditorRegistry) converter).findCustomEditor(type, null); if (editor != null) { editor.setValue(value); return editor.getAsText(); } } return (String) getTypeConverter().convertIfNecessary(value, String.class); } }
protected final String convertToString(Class<?> type, Object value, TypeConverter converter) { if (value instanceof String) { return (String) value; } else { if (converter instanceof PropertyEditorRegistry && type != null && type.isInstance(value)) { PropertyEditor editor = ((PropertyEditorRegistry) converter).findCustomEditor(type, null); if (editor != null) { editor.setValue(value); return editor.getAsText(); } } return (String) getTypeConverter().convertIfNecessary(value, String.class); } }
pe = propertyEditorRegistry.findCustomEditor( value.getClass(), p); } else if (!path.equals(p)) { pe = propertyEditorRegistry.findCustomEditor( value.getClass(), p);
pe = propertyEditorRegistry.findCustomEditor( value.getClass(), p); } else if (!path.equals(p)) { pe = propertyEditorRegistry.findCustomEditor( value.getClass(), p);