Example usage for java.beans PropertyEditorSupport setValue

List of usage examples for java.beans PropertyEditorSupport setValue

Introduction

In this page you can find the example usage for java.beans PropertyEditorSupport setValue.

Prototype

public void setValue(Object value) 

Source Link

Document

Set (or change) the object that is to be edited.

Usage

From source file:test.automation.operator.AbstractReflectionFormHandler.java

/**
 * Useful for converting a date into a string representation, or serializing an entity, etc..
 * @param field the field in the POJO./* w w w  .j  a  v a2 s .co  m*/
 * @param entity the entity holding the POJO's state.
 * @return
 */
public String getValueAsText(final Field field, final Object value) {
    // convert the Object into a string representation using a property editor.
    if (propertyEditors != null) {
        final PropertyEditorSupport propertyEditor = propertyEditors.get(field.getType());
        if (propertyEditor != null) {
            propertyEditor.setValue(value);
            return (propertyEditor.getAsText());
        }
    }

    return (value.toString());
}