Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "JFace Data Binding/Converter"
m (Converters moved to Converter) |
m (Added JFace Data Binding side bar) |
||
Line 2: | Line 2: | ||
Converters, implementations of <code>org.eclipse.core.databinding.conversion.IConverter</code>, are a basic yet core part of the binding pipeline. They allow for the conversion between data types. This conversion can be as basic as converting from a primitive (e.g. boolean.class) to a boxed type (e.g. Boolean.class) or as complex as converting a String to an int. | Converters, implementations of <code>org.eclipse.core.databinding.conversion.IConverter</code>, are a basic yet core part of the binding pipeline. They allow for the conversion between data types. This conversion can be as basic as converting from a primitive (e.g. boolean.class) to a boxed type (e.g. Boolean.class) or as complex as converting a String to an int. | ||
− | + | {{JFace Data Binding}} | |
== Implementation Design Principles == | == Implementation Design Principles == | ||
# It's best for the converter to be immutable. This will allow for greater reuse of the instance especially across threads. | # It's best for the converter to be immutable. This will allow for greater reuse of the instance especially across threads. | ||
# Synchronize during convert(...) if necessary. A good example of this is using <code>com.ibm.icu.text.NumberFormat</code> in a converter. NumberFormat expects to be externally synchronized as the state of NumberFormat changes during formatting and parsing. In order to be used across threads access to the internal NumberFormat must be synchronized. | # Synchronize during convert(...) if necessary. A good example of this is using <code>com.ibm.icu.text.NumberFormat</code> in a converter. NumberFormat expects to be externally synchronized as the state of NumberFormat changes during formatting and parsing. In order to be used across threads access to the internal NumberFormat must be synchronized. | ||
# If the converter is converting to a primitive from an object ensure null is handled. | # If the converter is converting to a primitive from an object ensure null is handled. |
Revision as of 22:48, 20 March 2007
In JFace Data Binding converters are used to convert from one value type to another.
Converters, implementations of org.eclipse.core.databinding.conversion.IConverter
, are a basic yet core part of the binding pipeline. They allow for the conversion between data types. This conversion can be as basic as converting from a primitive (e.g. boolean.class) to a boxed type (e.g. Boolean.class) or as complex as converting a String to an int.
JFace Data Binding |
Home |
How to Contribute |
FAQ |
Snippets |
Concepts |
Binding |
Converter |
Observable |
Realm |
Implementation Design Principles
- It's best for the converter to be immutable. This will allow for greater reuse of the instance especially across threads.
- Synchronize during convert(...) if necessary. A good example of this is using
com.ibm.icu.text.NumberFormat
in a converter. NumberFormat expects to be externally synchronized as the state of NumberFormat changes during formatting and parsing. In order to be used across threads access to the internal NumberFormat must be synchronized. - If the converter is converting to a primitive from an object ensure null is handled.