Example usage for java.beans PropertyEditorSupport getAsText

List of usage examples for java.beans PropertyEditorSupport getAsText

Introduction

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

Prototype

public String getAsText() 

Source Link

Document

Gets the property value as a string suitable for presentation to a human to edit.

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  a  2 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());
}