com.jgoodies.binding.value
Interface BindingConverter

All Known Implementing Classes:
ConverterFactory.BooleanNegator, ConverterFactory.BooleanToStringConverter, ConverterFactory.DoubleConverter, ConverterFactory.DoubleToIntegerConverter, ConverterFactory.FloatConverter, ConverterFactory.FloatToIntegerConverter, ConverterFactory.IntegerConverter, ConverterFactory.LongConverter, ConverterFactory.LongToIntegerConverter, ConverterFactory.StringConverter

public interface BindingConverter

Describes an object that converts values from a binding target to a binding source and vice versa.

Used by the binder mechanism to introduce a conversion in the binding chain from source to target. Often the binding source is a bean property that has been turned into a ValueModel. The binding target is typically a user interface component, e.g. combo box or text field.

Example:
binder.bindBeanProperty("price").converted(currencyConverter).to(priceField);

This conversion is similar to the String conversion of the Format class, where Format.format(Object) equates to targetValue(Object), and Format.parseObject(String) to sourceValue(Object).

Binding converters should be used judiciously; they can be limited w.r.t. to localized formatting conventions. When binding non-String values to a text UI component, consider using a JFormattedTextField. Formatted text fields provide a powerful means to convert strings to objects and handle many cases that arise around invalid input.

Since:
2.7
Version:
$Revision: 1.4 $
Author:
Karsten Lentzsch

Method Summary
 Object sourceValue(Object targetValue)
          Returns the converted target value for use by the binding source.
 Object targetValue(Object sourceValue)
          Returns the converted source value for use by the binding target.
 

Method Detail

targetValue

Object targetValue(Object sourceValue)
Returns the converted source value for use by the binding target. Equates to Format.format(Object) if the target accepts and provides Strings.

Parameters:
sourceValue - the value to convert
Returns:
the converted value

sourceValue

Object sourceValue(Object targetValue)
Returns the converted target value for use by the binding source. Equates to Format.parseObject(String) if the target accepts and provides Strings.

Parameters:
targetValue - the value to convert
Returns:
the converted value


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.