Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 80312 Details for
Bug 203492
[DataBinding] Binding builder API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
A first draft implementation
patch.txt (text/plain), 66.51 KB, created by
Thomas Schindl
on 2007-10-13 21:17:25 EDT
(
hide
)
Description:
A first draft implementation
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2007-10-13 21:17:25 EDT
Size:
66.51 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.databinding >Index: src/org/eclipse/core/databinding/UpdateListStrategy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateListStrategy.java,v >retrieving revision 1.3 >diff -u -r1.3 UpdateListStrategy.java >--- src/org/eclipse/core/databinding/UpdateListStrategy.java 26 Apr 2007 03:00:44 -0000 1.3 >+++ src/org/eclipse/core/databinding/UpdateListStrategy.java 14 Oct 2007 01:15:27 -0000 >@@ -12,9 +12,11 @@ > package org.eclipse.core.databinding; > > import org.eclipse.core.databinding.conversion.IConverter; >+import org.eclipse.core.databinding.conversion.IConverterProvider; > import org.eclipse.core.databinding.observable.list.IObservableList; > import org.eclipse.core.databinding.validation.ValidationStatus; > import org.eclipse.core.internal.databinding.BindingMessages; >+import org.eclipse.core.internal.databinding.DefaultConverterProvider; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > >@@ -36,8 +38,8 @@ > * construction of the strategy (e.g. {@link #POLICY_NEVER}, > * {@link #POLICY_ON_REQUEST}, {@link #POLICY_UPDATE}). > * </p> >- * >- * >+ * >+ * > * @see DataBindingContext#bindList(IObservableList, IObservableList, > * UpdateListStrategy, UpdateListStrategy) > * @see IConverter >@@ -71,7 +73,7 @@ > * Helper method allowing API evolution of the above constant values. The > * compiler will not inline constant values into client code if values are > * "computed" using this helper. >- * >+ * > * @param i > * an integer > * @return the same integer >@@ -93,14 +95,21 @@ > * calling one of the setter methods. > */ > public UpdateListStrategy() { >- this(true, POLICY_UPDATE); >+ this(true, POLICY_UPDATE,new DefaultConverterProvider()); >+ } >+ >+ /** >+ * @param provider >+ */ >+ public UpdateListStrategy(IConverterProvider provider) { >+ this(true,POLICY_UPDATE,provider); > } > > /** > * Creates a new update list strategy with a configurable update policy. A > * default converter will be provided. The defaults can be changed by > * calling one of the setter methods. >- * >+ * > * @param updatePolicy > * one of {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, or > * {@link #POLICY_UPDATE} >@@ -110,11 +119,19 @@ > } > > /** >+ * @param updatePolicy >+ * @param provider >+ */ >+ public UpdateListStrategy(int updatePolicy,IConverterProvider provider) { >+ this(true,updatePolicy,provider); >+ } >+ >+ /** > * Creates a new update list strategy with a configurable update policy. A > * default converter will be provided if <code>provideDefaults</code> is > * <code>true</code>. The defaults can be changed by calling one of the > * setter methods. >- * >+ * > * @param provideDefaults > * if <code>true</code>, default validators and a default > * converter will be provided based on the observable list's >@@ -124,6 +141,16 @@ > * {@link #POLICY_UPDATE} > */ > public UpdateListStrategy(boolean provideDefaults, int updatePolicy) { >+ this(true,updatePolicy,new DefaultConverterProvider()); >+ } >+ >+ /** >+ * @param provideDefaults >+ * @param updatePolicy >+ * @param provider >+ */ >+ public UpdateListStrategy(boolean provideDefaults, int updatePolicy, IConverterProvider provider) { >+ super(provider==null?new DefaultConverterProvider():provider); > this.provideDefaults = provideDefaults; > this.updatePolicy = updatePolicy; > } >@@ -136,7 +163,7 @@ > * {@link #setConverter(IConverter) converter} if one exists. If no > * converter exists no conversion occurs. > * </p> >- * >+ * > * @param element > * @return the converted element > */ >@@ -145,7 +172,7 @@ > } > > /** >- * >+ * > * @param source > * @param destination > */ >@@ -180,7 +207,7 @@ > /** > * Sets the converter to be invoked when converting added elements from the > * source element type to the destination element type. >- * >+ * > * @param converter > * @return the receiver, to enable method call chaining > */ >@@ -192,7 +219,7 @@ > /** > * Adds the given element at the given index to the given observable list. > * Clients may extend but must call the super implementation. >- * >+ * > * @param observableList > * @param element > * @param index >@@ -213,7 +240,7 @@ > /** > * Removes the element at the given index from the given observable list. > * Clients may extend but must call the super implementation. >- * >+ * > * @param observableList > * @param index > * @return a status >Index: src/org/eclipse/core/databinding/UpdateStrategy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateStrategy.java,v >retrieving revision 1.7 >diff -u -r1.7 UpdateStrategy.java >--- src/org/eclipse/core/databinding/UpdateStrategy.java 29 Apr 2007 04:12:55 -0000 1.7 >+++ src/org/eclipse/core/databinding/UpdateStrategy.java 14 Oct 2007 01:15:27 -0000 >@@ -11,77 +11,29 @@ > > package org.eclipse.core.databinding; > >-import java.math.BigDecimal; >-import java.math.BigInteger; >-import java.util.HashMap; >-import java.util.Map; > > import org.eclipse.core.databinding.conversion.IConverter; >-import org.eclipse.core.databinding.conversion.NumberToStringConverter; >-import org.eclipse.core.databinding.conversion.StringToNumberConverter; >-import org.eclipse.core.databinding.util.Policy; >-import org.eclipse.core.internal.databinding.ClassLookupSupport; >-import org.eclipse.core.internal.databinding.Pair; >-import org.eclipse.core.internal.databinding.conversion.IdentityConverter; >-import org.eclipse.core.internal.databinding.conversion.IntegerToStringConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToBigDecimalConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToBigIntegerConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToByteConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToDoubleConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToFloatConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToIntegerConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToLongConverter; >-import org.eclipse.core.internal.databinding.conversion.NumberToShortConverter; >-import org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter; >-import org.eclipse.core.internal.databinding.conversion.StringToByteConverter; >-import org.eclipse.core.internal.databinding.conversion.StringToShortConverter; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >- >-import com.ibm.icu.text.NumberFormat; >+import org.eclipse.core.databinding.conversion.IConverterProvider; > > /** > * @since 1.0 >- * >+ * > */ > /* package */class UpdateStrategy { >+ private IConverterProvider converterProvider; > >- private static final String BOOLEAN_TYPE = "java.lang.Boolean.TYPE"; //$NON-NLS-1$ >- private static final String SHORT_TYPE = "java.lang.Short.TYPE"; //$NON-NLS-1$ >- private static final String BYTE_TYPE = "java.lang.Byte.TYPE"; //$NON-NLS-1$ >- private static final String DOUBLE_TYPE = "java.lang.Double.TYPE"; //$NON-NLS-1$ >- private static final String FLOAT_TYPE = "java.lang.Float.TYPE"; //$NON-NLS-1$ >- private static final String INTEGER_TYPE = "java.lang.Integer.TYPE"; //$NON-NLS-1$ >- private static final String LONG_TYPE = "java.lang.Long.TYPE"; //$NON-NLS-1$ >- private static Map converterMap; >- >- private static Class autoboxed(Class clazz) { >- if (clazz == Float.TYPE) >- return Float.class; >- else if (clazz == Double.TYPE) >- return Double.class; >- else if (clazz == Short.TYPE) >- return Short.class; >- else if (clazz == Integer.TYPE) >- return Integer.class; >- else if (clazz == Long.TYPE) >- return Long.class; >- else if (clazz == Byte.TYPE) >- return Byte.class; >- else if (clazz == Boolean.TYPE) >- return Boolean.class; >- return clazz; >- } >+// /** >+// * >+// */ >+// public UpdateStrategy() { >+// this(new DefaultConverterProvider()); >+// } > >- final protected void checkAssignable(Object toType, Object fromType, >- String errorString) { >- Boolean assignableFromModelToModelConverter = isAssignableFromTo( >- fromType, toType); >- if (assignableFromModelToModelConverter != null >- && !assignableFromModelToModelConverter.booleanValue()) { >- throw new BindingException(errorString >- + " Expected: " + fromType + ", actual: " + toType); //$NON-NLS-1$//$NON-NLS-2$ >- } >+ /** >+ * @param converterProvider the provider implementation used >+ */ >+ public UpdateStrategy(IConverterProvider converterProvider) { >+ this.converterProvider = converterProvider; > } > > /** >@@ -89,421 +41,29 @@ > * fromType. Returns <code>null</code> if no converter could be created. > * Either toType or modelDescription can be <code>null</code>, but not > * both. >- * >+ * > * @param fromType > * @param toType > * @return an IConverter, or <code>null</code> if unsuccessful > */ > protected IConverter createConverter(Object fromType, Object toType) { >- if (!(fromType instanceof Class) || !(toType instanceof Class)) { >- return new DefaultConverter(fromType, toType); >- } >- Class toClass = (Class) toType; >- Class originalToClass = toClass; >- if (toClass.isPrimitive()) { >- toClass = autoboxed(toClass); >- } >- Class fromClass = (Class) fromType; >- Class originalFromClass = fromClass; >- if (fromClass.isPrimitive()) { >- fromClass = autoboxed(fromClass); >- } >- if (!((Class) toType).isPrimitive() >- && toClass.isAssignableFrom(fromClass)) { >- return new IdentityConverter(originalFromClass, originalToClass); >- } >- if (((Class) fromType).isPrimitive() && ((Class) toType).isPrimitive() >- && fromType.equals(toType)) { >- return new IdentityConverter(originalFromClass, originalToClass); >- } >- Map converterMap = getConverterMap(); >- Class[] supertypeHierarchyFlattened = ClassLookupSupport >- .getTypeHierarchyFlattened(fromClass); >- for (int i = 0; i < supertypeHierarchyFlattened.length; i++) { >- Class currentFromClass = supertypeHierarchyFlattened[i]; >- if (currentFromClass == toType) { >- // converting to toType is just a widening >- return new IdentityConverter(fromClass, toClass); >- } >- Pair key = new Pair(getKeyForClass(fromType, currentFromClass), >- getKeyForClass(toType, toClass)); >- Object converterOrClassname = converterMap.get(key); >- if (converterOrClassname instanceof IConverter) { >- return (IConverter) converterOrClassname; >- } else if (converterOrClassname instanceof String) { >- String classname = (String) converterOrClassname; >- Class converterClass; >- try { >- converterClass = Class.forName(classname); >- IConverter result = (IConverter) converterClass >- .newInstance(); >- converterMap.put(key, result); >- return result; >- } catch (Exception e) { >- Policy >- .getLog() >- .log( >- new Status( >- IStatus.ERROR, >- Policy.JFACE_DATABINDING, >- 0, >- "Error while instantiating default converter", e)); //$NON-NLS-1$ >- } >- } >- } >- // Since we found no converter yet, try a "downcast" converter; >- // the IdentityConverter will automatically check the actual types at >- // runtime. >- if (fromClass.isAssignableFrom(toClass)) { >- return new IdentityConverter(originalFromClass, originalToClass); >- } >- return new DefaultConverter(fromType, toType); >- } >- >- private static Map getConverterMap() { >- // using string-based lookup avoids loading of too many classes >- if (converterMap == null) { >- //NumberFormat to be shared across converters for the formatting of integer values >- NumberFormat integerFormat = NumberFormat.getIntegerInstance(); >- //NumberFormat to be shared across converters for formatting non integer values >- NumberFormat numberFormat = NumberFormat.getNumberInstance(); >- >- converterMap = new HashMap(); >- converterMap >- .put( >- new Pair("java.util.Date", "java.lang.String"), "org.eclipse.core.internal.databinding.conversion.DateToStringConverter"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- converterMap >- .put( >- new Pair("java.lang.String", "java.lang.Boolean"), "org.eclipse.core.internal.databinding.conversion.StringToBooleanConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >- converterMap >- .put( >- new Pair("java.lang.String", "java.lang.Byte"), StringToByteConverter.toByte(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap >- .put( >- new Pair("java.lang.String", "java.lang.Character"), "org.eclipse.core.internal.databinding.conversion.StringToCharacterConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >- converterMap >- .put( >- new Pair("java.lang.String", "java.util.Date"), "org.eclipse.core.internal.databinding.conversion.StringToDateConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >- converterMap >- .put( >- new Pair("java.lang.String", "java.lang.Short"), StringToShortConverter.toShort(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- >- converterMap.put(new Pair("java.lang.String", "java.lang.Integer"), StringToNumberConverter.toInteger(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.String", "java.lang.Double"), StringToNumberConverter.toDouble(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.String", "java.lang.Long"), StringToNumberConverter.toLong(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.String", "java.lang.Float"), StringToNumberConverter.toFloat(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.String", "java.math.BigInteger"), StringToNumberConverter.toBigInteger(integerFormat)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.Integer", "java.lang.String"), NumberToStringConverter.fromInteger(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.Long", "java.lang.String"), NumberToStringConverter.fromLong(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.Double", "java.lang.String"), NumberToStringConverter.fromDouble(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.Float", "java.lang.String"), NumberToStringConverter.fromFloat(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.math.BigInteger", "java.lang.String"), NumberToStringConverter.fromBigInteger(integerFormat)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.Byte", "java.lang.String"), IntegerToStringConverter.fromByte(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- converterMap.put(new Pair("java.lang.Short", "java.lang.String"), IntegerToStringConverter.fromShort(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >- >- converterMap >- .put( >- new Pair("java.lang.Object", "java.lang.String"), "org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >- >- // Integer.TYPE >- converterMap.put(new Pair("java.lang.String", INTEGER_TYPE), StringToNumberConverter.toInteger(integerFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(INTEGER_TYPE, "java.lang.Integer"), new IdentityConverter(Integer.TYPE, Integer.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(INTEGER_TYPE, "java.lang.Object"), new IdentityConverter(Integer.TYPE, Object.class)); //$NON-NLS-1$ >- converterMap.put(new Pair(INTEGER_TYPE, "java.lang.String"), NumberToStringConverter.fromInteger(integerFormat, true)); //$NON-NLS-1$ >- >- // Byte.TYPE >- converterMap >- .put( >- new Pair("java.lang.String", BYTE_TYPE), StringToByteConverter.toByte(integerFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(BYTE_TYPE, "java.lang.Byte"), new IdentityConverter(Byte.TYPE, Byte.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(BYTE_TYPE, "java.lang.String"), IntegerToStringConverter.fromByte(integerFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(BYTE_TYPE, "java.lang.Object"), new IdentityConverter(Byte.TYPE, Object.class)); //$NON-NLS-1$ >- >- // Double.TYPE >- converterMap.put(new Pair("java.lang.String", DOUBLE_TYPE), StringToNumberConverter.toDouble(numberFormat, true)); //$NON-NLS-1$ >- converterMap.put(new Pair(DOUBLE_TYPE, "java.lang.String"), NumberToStringConverter.fromDouble(numberFormat, true)); //$NON-NLS-1$ >- >- converterMap >- .put( >- new Pair(DOUBLE_TYPE, "java.lang.Double"), new IdentityConverter(Double.TYPE, Double.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(DOUBLE_TYPE, "java.lang.Object"), new IdentityConverter(Double.TYPE, Object.class)); //$NON-NLS-1$ >- >- // Boolean.TYPE >- converterMap >- .put( >- new Pair("java.lang.String", BOOLEAN_TYPE), "org.eclipse.core.internal.databinding.conversion.StringToBooleanPrimitiveConverter"); //$NON-NLS-1$ //$NON-NLS-2$ >- converterMap >- .put( >- new Pair(BOOLEAN_TYPE, "java.lang.Boolean"), new IdentityConverter(Boolean.TYPE, Boolean.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(BOOLEAN_TYPE, "java.lang.String"), new ObjectToStringConverter(Boolean.TYPE)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(BOOLEAN_TYPE, "java.lang.Object"), new IdentityConverter(Boolean.TYPE, Object.class)); //$NON-NLS-1$ >- >- // Float.TYPE >- converterMap.put(new Pair("java.lang.String", FLOAT_TYPE), StringToNumberConverter.toFloat(numberFormat, true)); //$NON-NLS-1$ >- converterMap.put(new Pair(FLOAT_TYPE, "java.lang.String"), NumberToStringConverter.fromFloat(numberFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(FLOAT_TYPE, "java.lang.Float"), new IdentityConverter(Float.TYPE, Float.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(FLOAT_TYPE, "java.lang.Object"), new IdentityConverter(Float.TYPE, Object.class)); //$NON-NLS-1$ >- >- // Short.TYPE >- converterMap >- .put( >- new Pair("java.lang.String", SHORT_TYPE), StringToShortConverter.toShort(integerFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(SHORT_TYPE, "java.lang.Short"), new IdentityConverter(Short.TYPE, Short.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(SHORT_TYPE, "java.lang.String"), IntegerToStringConverter.fromShort(integerFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(SHORT_TYPE, "java.lang.Object"), new IdentityConverter(Short.TYPE, Object.class)); //$NON-NLS-1$ >- >- // Long.TYPE >- converterMap.put(new Pair("java.lang.String", LONG_TYPE), StringToNumberConverter.toLong(integerFormat, true)); //$NON-NLS-1$ >- converterMap.put(new Pair(LONG_TYPE, "java.lang.String"), NumberToStringConverter.fromLong(integerFormat, true)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(LONG_TYPE, "java.lang.Long"), new IdentityConverter(Long.TYPE, Long.class)); //$NON-NLS-1$ >- converterMap >- .put( >- new Pair(LONG_TYPE, "java.lang.Object"), new IdentityConverter(Long.TYPE, Object.class)); //$NON-NLS-1$ >- >- converterMap >- .put( >- new Pair("org.eclipse.core.runtime.IStatus", "java.lang.String"), "org.eclipse.core.internal.databinding.conversion.StatusToStringConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >- >- addNumberToByteConverters(converterMap, integerFormat, integerClasses); >- addNumberToByteConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToShortConverters(converterMap, integerFormat, integerClasses); >- addNumberToShortConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToIntegerConverters(converterMap, integerFormat, integerClasses); >- addNumberToIntegerConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToLongConverters(converterMap, integerFormat, integerClasses); >- addNumberToLongConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToFloatConverters(converterMap, integerFormat, integerClasses); >- addNumberToFloatConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToDoubleConverters(converterMap, integerFormat, integerClasses); >- addNumberToDoubleConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToBigIntegerConverters(converterMap, integerFormat, integerClasses); >- addNumberToBigIntegerConverters(converterMap, numberFormat, floatClasses); >- >- addNumberToBigDecimalConverters(converterMap, integerFormat, integerClasses); >- addNumberToBigDecimalConverters(converterMap, numberFormat, floatClasses); >- } >- >- return converterMap; >- } >- >- private static final Class[] integerClasses = new Class[]{ >- Byte.TYPE, Byte.class, >- Short.TYPE, Short.class, >- Integer.TYPE, Integer.class, >- Long.TYPE, Long.class, >- BigInteger.class}; >- >- private static final Class[] floatClasses = new Class[] { >- Float.TYPE, Float.class, >- Double.TYPE, Double.class, >- BigDecimal.class}; >- >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToByteConverters(Map map, >- NumberFormat numberFormat, Class[] fromTypes) { >- >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(Byte.class) && !fromType.equals(Byte.TYPE)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, BYTE_TYPE), new NumberToByteConverter(numberFormat, fromType, true)); >- map.put(new Pair(fromName, Byte.class.getName()), new NumberToByteConverter(numberFormat, fromType, false)); >- } >- } >- } >- >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToShortConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(Short.class) && !fromType.equals(Short.TYPE)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, SHORT_TYPE), new NumberToShortConverter(numberFormat, fromType, true)); >- map.put(new Pair(fromName, Short.class.getName()), new NumberToShortConverter(numberFormat, fromType, false)); >- } >- } >- } >- >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToIntegerConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(Integer.class) && !fromType.equals(Integer.TYPE)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, INTEGER_TYPE), new NumberToIntegerConverter(numberFormat, fromType, true)); >- map.put(new Pair(fromName, Integer.class.getName()), new NumberToIntegerConverter(numberFormat, fromType, false)); >- } >- } >- } >- >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToLongConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(Long.class) && !fromType.equals(Long.TYPE)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, LONG_TYPE), new NumberToLongConverter(numberFormat, fromType, true)); >- map.put(new Pair(fromName, Long.class.getName()), new NumberToLongConverter(numberFormat, fromType, false)); >- } >+ IConverter convert = converterProvider.createConverter(fromType, toType); >+ if( convert == null ) { >+ convert = new DefaultConverter(fromType,toType); > } >- } > >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToFloatConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(Float.class) && !fromType.equals(Float.TYPE)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, FLOAT_TYPE), new NumberToFloatConverter(numberFormat, fromType, true)); >- map.put(new Pair(fromName, Float.class.getName()), new NumberToFloatConverter(numberFormat, fromType, false)); >- } >- } >- } >- >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToDoubleConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(Double.class) && !fromType.equals(Double.TYPE)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, DOUBLE_TYPE), new NumberToDoubleConverter(numberFormat, fromType, true)); >- map.put(new Pair(fromName, Double.class.getName()), new NumberToDoubleConverter(numberFormat, fromType, false)); >- } >- } >+ return convert; > } > >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToBigIntegerConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(BigInteger.class)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, BigInteger.class.getName()), new NumberToBigIntegerConverter(numberFormat, fromType)); >- } >- } >- } >- >- /** >- * Registers converters to boxed and unboxed types from a list of from classes. >- * >- * @param map >- * @param numberFormat >- * @param fromTypes >- */ >- private static void addNumberToBigDecimalConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >- for (int i = 0; i < fromTypes.length; i++) { >- Class fromType = fromTypes[i]; >- if (!fromType.equals(BigDecimal.class)) { >- String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >- >- map.put(new Pair(fromName, BigDecimal.class.getName()), new NumberToBigDecimalConverter(numberFormat, fromType)); >- } >- } >- } >- >- private static String getKeyForClass(Object originalValue, Class filteredValue) { >- if (originalValue instanceof Class) { >- Class originalClass = (Class) originalValue; >- if (originalClass.equals(Integer.TYPE)) { >- return INTEGER_TYPE; >- } else if (originalClass.equals(Byte.TYPE)) { >- return BYTE_TYPE; >- } else if (originalClass.equals(Boolean.TYPE)) { >- return BOOLEAN_TYPE; >- } else if (originalClass.equals(Double.TYPE)) { >- return DOUBLE_TYPE; >- } else if (originalClass.equals(Float.TYPE)) { >- return FLOAT_TYPE; >- } else if (originalClass.equals(Long.TYPE)) { >- return LONG_TYPE; >- } else if (originalClass.equals(Short.TYPE)) { >- return SHORT_TYPE; >- } >+ final protected void checkAssignable(Object toType, Object fromType, >+ String errorString) { >+ Boolean assignableFromModelToModelConverter = isAssignableFromTo( >+ fromType, toType); >+ if (assignableFromModelToModelConverter != null >+ && !assignableFromModelToModelConverter.booleanValue()) { >+ throw new BindingException(errorString >+ + " Expected: " + fromType + ", actual: " + toType); //$NON-NLS-1$//$NON-NLS-2$ > } >- return filteredValue.getName(); > } > > /** >@@ -512,19 +72,7 @@ > * @return whether fromType is assignable to toType > */ > protected Boolean isAssignableFromTo(Object fromType, Object toType) { >- if (fromType instanceof Class && toType instanceof Class) { >- Class toClass = (Class) toType; >- if (toClass.isPrimitive()) { >- toClass = autoboxed(toClass); >- } >- Class fromClass = (Class) fromType; >- if (fromClass.isPrimitive()) { >- fromClass = autoboxed(fromClass); >- } >- return toClass.isAssignableFrom(fromClass) ? Boolean.TRUE >- : Boolean.FALSE; >- } >- return null; >+ return converterProvider.isAssignableFromTo(fromType, toType); > } > > /* >Index: src/org/eclipse/core/databinding/DataBindingContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/DataBindingContext.java,v >retrieving revision 1.14 >diff -u -r1.14 DataBindingContext.java >--- src/org/eclipse/core/databinding/DataBindingContext.java 26 Apr 2007 02:11:16 -0000 1.14 >+++ src/org/eclipse/core/databinding/DataBindingContext.java 14 Oct 2007 01:15:27 -0000 >@@ -16,6 +16,7 @@ > > import java.util.Iterator; > >+import org.eclipse.core.databinding.conversion.IConverterProvider; > import org.eclipse.core.databinding.observable.Observables; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.list.IObservableList; >@@ -47,7 +48,7 @@ > * could be aggregated to set the page status and fulfillment. Each page in the > * <code>IWizard</code> would have its own context instance. > * </p> >- * >+ * > * @since 1.0 > */ > public class DataBindingContext { >@@ -62,10 +63,12 @@ > > private Realm validationRealm; > >+ private IConverterProvider converterProvider; >+ > /** > * Creates a data binding context, using the current default realm for the > * validation observables. >- * >+ * > * @see Realm > */ > public DataBindingContext() { >@@ -73,16 +76,32 @@ > } > > /** >+ * @param converterProvider >+ */ >+ public DataBindingContext(IConverterProvider converterProvider) { >+ this(Realm.getDefault(),null); >+ } >+ >+ /** > * Creates a data binding context using the given realm for the validation > * observables. >- * >+ * > * @param validationRealm > * the realm to be used for the validation observables >- * >+ * > * @see Realm > */ > public DataBindingContext(Realm validationRealm) { >+ this(validationRealm,null); >+ } >+ >+ /** >+ * @param validationRealm >+ * @param converterProvider >+ */ >+ public DataBindingContext(Realm validationRealm,IConverterProvider converterProvider) { > Assert.isNotNull(validationRealm); >+ this.converterProvider = converterProvider; > this.validationRealm = validationRealm; > bindings = new WritableList(validationRealm); > >@@ -97,7 +116,7 @@ > * validation and conversion can be employed to customize the process. For > * specifics on the customization of the process see > * {@link UpdateValueStrategy}. >- * >+ * > * @param targetObservableValue > * target value, commonly a UI widget > * @param modelObservableValue >@@ -109,7 +128,7 @@ > * strategy to employ when the model is the source of the change > * and the target is the destination > * @return created binding >- * >+ * > * @see UpdateValueStrategy > */ > public final Binding bindValue(IObservableValue targetObservableValue, >@@ -131,36 +150,36 @@ > /** > * Returns an update value strategy to be used for copying values from the > * from value to the to value. Clients may override. >- * >+ * > * @param fromValue > * @param toValue > * @return a update value strategy > */ > protected UpdateValueStrategy createModelToTargetUpdateValueStrategy( > IObservableValue fromValue, IObservableValue toValue) { >- return new UpdateValueStrategy(); >+ return new UpdateValueStrategy(converterProvider); > } > > /** > * Returns an update value strategy to be used for copying values from the > * from value to the to value. Clients may override. >- * >+ * > * @param fromValue > * @param toValue > * @return a update value strategy > */ > protected UpdateValueStrategy createTargetToModelUpdateValueStrategy( > IObservableValue fromValue, IObservableValue toValue) { >- return new UpdateValueStrategy(); >+ return new UpdateValueStrategy(converterProvider); > } >- >+ > /** > * Creates a {@link Binding} to synchronize the values of two > * {@link IObservableList observable lists}. During synchronization > * validation and conversion can be employed to customize the process. For > * specifics on the customization of the process see > * {@link UpdateListStrategy}. >- * >+ * > * @param targetObservableList > * target list, commonly a list representing a list in the UI > * @param modelObservableList >@@ -172,7 +191,7 @@ > * strategy to employ when the model is the source of the change > * and the target is the destination > * @return created binding >- * >+ * > * @see UpdateListStrategy > */ > public final Binding bindList(IObservableList targetObservableList, >@@ -203,18 +222,18 @@ > protected UpdateListStrategy createModelToTargetUpdateListStrategy( > IObservableList modelObservableList, > IObservableList targetObservableList) { >- return new UpdateListStrategy(); >+ return new UpdateListStrategy(converterProvider); > } > > /** > * @param targetObservableList > * @param modelObservableList >- * @return an update list strategy >+ * @return an update list strategy > */ > protected UpdateListStrategy createTargetToModelUpdateListStrategy( > IObservableList targetObservableList, > IObservableList modelObservableList) { >- return new UpdateListStrategy(); >+ return new UpdateListStrategy(converterProvider); > } > > /** >@@ -231,7 +250,7 @@ > /** > * Returns an unmodifiable observable list with elements of type > * {@link Binding}, ordered by time of addition. >- * >+ * > * @return the observable list containing all bindings > */ > public final IObservableList getBindings() { >@@ -243,7 +262,7 @@ > * statuses (type: {@link IStatus}). The keys of the map are the bindings > * returned by {@link #getBindings()}, and the values are the current > * validaion status objects for each binding. >- * >+ * > * @return the observable map from bindings to status objects. > */ > public final IObservableMap getValidationStatusMap() { >@@ -252,7 +271,7 @@ > > /** > * Adds the given binding to this data binding context. >- * >+ * > * @param binding > * The binding to add. > */ >@@ -263,7 +282,7 @@ > /** > * Updates all model observable objects to reflect the current state of the > * target observable objects. >- * >+ * > */ > public final void updateModels() { > for (Iterator it = bindings.iterator(); it.hasNext();) { >@@ -275,7 +294,7 @@ > /** > * Updates all target observable objects to reflect the current state of the > * model observable objects. >- * >+ * > */ > public final void updateTargets() { > for (Iterator it = bindings.iterator(); it.hasNext();) { >@@ -286,7 +305,7 @@ > > /** > * Removes the given binding. >- * >+ * > * @param binding > * @return <code>true</code> if was associated with the context, > * <code>false</code> if not >@@ -297,7 +316,7 @@ > > /** > * Returns the validation realm. >- * >+ * > * @return the realm for the validation observables > * @see Realm > */ >Index: src/org/eclipse/core/databinding/UpdateValueStrategy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/UpdateValueStrategy.java,v >retrieving revision 1.8 >diff -u -r1.8 UpdateValueStrategy.java >--- src/org/eclipse/core/databinding/UpdateValueStrategy.java 29 Apr 2007 04:12:55 -0000 1.8 >+++ src/org/eclipse/core/databinding/UpdateValueStrategy.java 14 Oct 2007 01:15:27 -0000 >@@ -15,10 +15,12 @@ > import java.util.HashMap; > > import org.eclipse.core.databinding.conversion.IConverter; >+import org.eclipse.core.databinding.conversion.IConverterProvider; > import org.eclipse.core.databinding.observable.value.IObservableValue; > import org.eclipse.core.databinding.validation.IValidator; > import org.eclipse.core.databinding.validation.ValidationStatus; > import org.eclipse.core.internal.databinding.BindingMessages; >+import org.eclipse.core.internal.databinding.DefaultConverterProvider; > import org.eclipse.core.internal.databinding.Pair; > import org.eclipse.core.internal.databinding.conversion.NumberToBigDecimalConverter; > import org.eclipse.core.internal.databinding.conversion.NumberToBigIntegerConverter; >@@ -87,7 +89,7 @@ > * construction of the strategy (e.g. {@link #POLICY_NEVER}, > * {@link #POLICY_CONVERT}, {@link #POLICY_ON_REQUEST}, {@link #POLICY_UPDATE}). > * </p> >- * >+ * > * @see DataBindingContext#bindValue(IObservableValue, IObservableValue, > * UpdateValueStrategy, UpdateValueStrategy) > * @see Binding#getValidationStatus() >@@ -131,7 +133,7 @@ > * Helper method allowing API evolution of the above constant values. The > * compiler will not inline constant values into client code if values are > * "computed" using this helper. >- * >+ * > * @param i > * an integer > * @return the same integer >@@ -168,16 +170,31 @@ > } > > /** >+ * @param provider >+ */ >+ public UpdateValueStrategy(IConverterProvider provider) { >+ this(true,POLICY_UPDATE,provider); >+ } >+ >+ /** > * Creates a new update value strategy with a configurable update policy. > * Default validators and a default converter will be provided. The defaults > * can be changed by calling one of the setter methods. >- * >+ * > * @param updatePolicy > * one of {@link #POLICY_NEVER}, {@link #POLICY_ON_REQUEST}, > * {@link #POLICY_CONVERT}, or {@link #POLICY_UPDATE} > */ > public UpdateValueStrategy(int updatePolicy) { >- this(true, updatePolicy); >+ this(true, updatePolicy, new DefaultConverterProvider()); >+ } >+ >+ /** >+ * @param updatePolicy >+ * @param provider >+ */ >+ public UpdateValueStrategy(int updatePolicy,IConverterProvider provider) { >+ this(true,updatePolicy,provider); > } > > /** >@@ -185,7 +202,7 @@ > * Default validators and a default converter will be provided if > * <code>provideDefaults</code> is <code>true</code>. The defaults can > * be changed by calling one of the setter methods. >- * >+ * > * @param provideDefaults > * if <code>true</code>, default validators and a default > * converter will be provided based on the observable value's >@@ -195,6 +212,16 @@ > * {@link #POLICY_CONVERT}, or {@link #POLICY_UPDATE} > */ > public UpdateValueStrategy(boolean provideDefaults, int updatePolicy) { >+ this(provideDefaults,updatePolicy,new DefaultConverterProvider()); >+ } >+ >+ /** >+ * @param provideDefaults >+ * @param updatePolicy >+ * @param provider >+ */ >+ public UpdateValueStrategy(boolean provideDefaults, int updatePolicy,IConverterProvider provider) { >+ super(provider==null?new DefaultConverterProvider():provider); > this.provideDefaults = provideDefaults; > this.updatePolicy = updatePolicy; > } >@@ -206,7 +233,7 @@ > * {@link #setConverter(IConverter) converter} if one exists. If no > * converter exists no conversion occurs. > * </p> >- * >+ * > * @param value > * @return the converted value > */ >@@ -218,7 +245,7 @@ > * Tries to create a validator that can validate values of type fromType. > * Returns <code>null</code> if no validator could be created. Either > * toType or modelDescription can be <code>null</code>, but not both. >- * >+ * > * @param fromType > * @param toType > * @return an IValidator, or <code>null</code> if unsuccessful >@@ -243,7 +270,7 @@ > * attempt is made to default the > * {@link #validateAfterGet(Object) after get validator}. If a validator > * cannot be defaulted it will be <code>null</code>. >- * >+ * > * @param source > * @param destination > */ >@@ -316,7 +343,7 @@ > } > } else if (converter instanceof NumberToNumberConverter) { > result = (IValidator) validatorsByConverter.get(converter); >- >+ > if (result == null) { > if (converter instanceof NumberToByteConverter) { > result = new NumberToByteValidator((NumberToByteConverter) converter); >@@ -355,7 +382,7 @@ > /** > * Sets the validator to be invoked after the source value is converted to > * the type of the destination observable. >- * >+ * > * @param validator > * @return the receiver, to enable method call chaining > */ >@@ -367,7 +394,7 @@ > /** > * Sets the validator to be invoked after the source value is retrieved at > * the beginning of the synchronization process. >- * >+ * > * @param validator > * @return the receiver, to enable method call chaining > */ >@@ -379,7 +406,7 @@ > /** > * Sets the validator to be invoked before the value is to be set on the > * destination at the end of the synchronization process. >- * >+ * > * @param validator > * @return the receiver, to enable method call chaining > */ >@@ -391,7 +418,7 @@ > /** > * Sets the converter to be invoked when converting from the source type to > * the destination type. >- * >+ * > * @param converter > * @return the receiver, to enable method call chaining > */ >@@ -407,7 +434,7 @@ > * {@link #setAfterConvertValidator(IValidator) validator} if one exists. If > * one does not exist no validation will occur. > * </p> >- * >+ * > * @param value > * @return an ok status > */ >@@ -423,7 +450,7 @@ > * {@link #setAfterGetValidator(IValidator) validator} if one exists. If one > * does not exist no validation will occur. > * </p> >- * >+ * > * @param value > * @return an ok status > */ >@@ -439,7 +466,7 @@ > * {@link #setBeforeSetValidator(IValidator) validator} if one exists. If > * one does not exist no validation will occur. > * </p> >- * >+ * > * @param value > * @return an ok status > */ >@@ -447,11 +474,11 @@ > return beforeSetValidator == null ? Status.OK_STATUS > : beforeSetValidator.validate(value); > } >- >+ > /** > * Sets the current value of the given observable to the given value. > * Clients may extend but must call the super implementation. >- * >+ * > * @param observableValue > * @param value > * @return status >@@ -512,7 +539,7 @@ > /** > * Associate a particular validator that can validate the conversion > * (fromClass, toClass) >- * >+ * > * @param fromClass > * The Class to convert from > * @param toClass >@@ -527,7 +554,7 @@ > > /** > * Return an IValidator for a specific fromClass and toClass. >- * >+ * > * @param fromClass > * The Class to convert from > * @param toClass >Index: src/org/eclipse/core/internal/databinding/DefaultConverterProvider.java >=================================================================== >RCS file: src/org/eclipse/core/internal/databinding/DefaultConverterProvider.java >diff -N src/org/eclipse/core/internal/databinding/DefaultConverterProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/databinding/DefaultConverterProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,518 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.core.internal.databinding; >+ >+import java.math.BigDecimal; >+import java.math.BigInteger; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.databinding.conversion.IConverter; >+import org.eclipse.core.databinding.conversion.IConverterProvider; >+import org.eclipse.core.databinding.conversion.NumberToStringConverter; >+import org.eclipse.core.databinding.conversion.StringToNumberConverter; >+import org.eclipse.core.databinding.util.Policy; >+import org.eclipse.core.internal.databinding.conversion.IdentityConverter; >+import org.eclipse.core.internal.databinding.conversion.IntegerToStringConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToBigDecimalConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToBigIntegerConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToByteConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToDoubleConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToFloatConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToIntegerConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToLongConverter; >+import org.eclipse.core.internal.databinding.conversion.NumberToShortConverter; >+import org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter; >+import org.eclipse.core.internal.databinding.conversion.StringToByteConverter; >+import org.eclipse.core.internal.databinding.conversion.StringToShortConverter; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+ >+import com.ibm.icu.text.NumberFormat; >+ >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public class DefaultConverterProvider implements IConverterProvider { >+ private static Map converterMap; >+ >+ private static final Class[] integerClasses = new Class[]{ >+ Byte.TYPE, Byte.class, >+ Short.TYPE, Short.class, >+ Integer.TYPE, Integer.class, >+ Long.TYPE, Long.class, >+ BigInteger.class}; >+ >+ private static final Class[] floatClasses = new Class[] { >+ Float.TYPE, Float.class, >+ Double.TYPE, Double.class, >+ BigDecimal.class}; >+ >+ private static final String BOOLEAN_TYPE = "java.lang.Boolean.TYPE"; //$NON-NLS-1$ >+ private static final String SHORT_TYPE = "java.lang.Short.TYPE"; //$NON-NLS-1$ >+ private static final String BYTE_TYPE = "java.lang.Byte.TYPE"; //$NON-NLS-1$ >+ private static final String DOUBLE_TYPE = "java.lang.Double.TYPE"; //$NON-NLS-1$ >+ private static final String FLOAT_TYPE = "java.lang.Float.TYPE"; //$NON-NLS-1$ >+ private static final String INTEGER_TYPE = "java.lang.Integer.TYPE"; //$NON-NLS-1$ >+ private static final String LONG_TYPE = "java.lang.Long.TYPE"; //$NON-NLS-1$ >+ >+ >+ private static Class autoboxed(Class clazz) { >+ if (clazz == Float.TYPE) >+ return Float.class; >+ else if (clazz == Double.TYPE) >+ return Double.class; >+ else if (clazz == Short.TYPE) >+ return Short.class; >+ else if (clazz == Integer.TYPE) >+ return Integer.class; >+ else if (clazz == Long.TYPE) >+ return Long.class; >+ else if (clazz == Byte.TYPE) >+ return Byte.class; >+ else if (clazz == Boolean.TYPE) >+ return Boolean.class; >+ return clazz; >+ } >+ >+ >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.databinding.conversion.IConverterProvider#createConverter(java.lang.Object, java.lang.Object) >+ */ >+ public IConverter createConverter(Object fromType, Object toType) { >+ if (!(fromType instanceof Class) || !(toType instanceof Class)) { >+ return null; >+ } >+ Class toClass = (Class) toType; >+ Class originalToClass = toClass; >+ if (toClass.isPrimitive()) { >+ toClass = autoboxed(toClass); >+ } >+ Class fromClass = (Class) fromType; >+ Class originalFromClass = fromClass; >+ if (fromClass.isPrimitive()) { >+ fromClass = autoboxed(fromClass); >+ } >+ if (!((Class) toType).isPrimitive() >+ && toClass.isAssignableFrom(fromClass)) { >+ return new IdentityConverter(originalFromClass, originalToClass); >+ } >+ if (((Class) fromType).isPrimitive() && ((Class) toType).isPrimitive() >+ && fromType.equals(toType)) { >+ return new IdentityConverter(originalFromClass, originalToClass); >+ } >+ Map converterMap = getConverterMap(); >+ Class[] supertypeHierarchyFlattened = ClassLookupSupport >+ .getTypeHierarchyFlattened(fromClass); >+ for (int i = 0; i < supertypeHierarchyFlattened.length; i++) { >+ Class currentFromClass = supertypeHierarchyFlattened[i]; >+ if (currentFromClass == toType) { >+ // converting to toType is just a widening >+ return new IdentityConverter(fromClass, toClass); >+ } >+ Pair key = new Pair(getKeyForClass(fromType, currentFromClass), >+ getKeyForClass(toType, toClass)); >+ Object converterOrClassname = converterMap.get(key); >+ if (converterOrClassname instanceof IConverter) { >+ return (IConverter) converterOrClassname; >+ } else if (converterOrClassname instanceof String) { >+ String classname = (String) converterOrClassname; >+ Class converterClass; >+ try { >+ converterClass = Class.forName(classname); >+ IConverter result = (IConverter) converterClass >+ .newInstance(); >+ converterMap.put(key, result); >+ return result; >+ } catch (Exception e) { >+ Policy >+ .getLog() >+ .log( >+ new Status( >+ IStatus.ERROR, >+ Policy.JFACE_DATABINDING, >+ 0, >+ "Error while instantiating default converter", e)); //$NON-NLS-1$ >+ } >+ } >+ } >+ // Since we found no converter yet, try a "downcast" converter; >+ // the IdentityConverter will automatically check the actual types at >+ // runtime. >+ if (fromClass.isAssignableFrom(toClass)) { >+ return new IdentityConverter(originalFromClass, originalToClass); >+ } >+ return null; >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToByteConverters(Map map, >+ NumberFormat numberFormat, Class[] fromTypes) { >+ >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(Byte.class) && !fromType.equals(Byte.TYPE)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, BYTE_TYPE), new NumberToByteConverter(numberFormat, fromType, true)); >+ map.put(new Pair(fromName, Byte.class.getName()), new NumberToByteConverter(numberFormat, fromType, false)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToShortConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(Short.class) && !fromType.equals(Short.TYPE)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, SHORT_TYPE), new NumberToShortConverter(numberFormat, fromType, true)); >+ map.put(new Pair(fromName, Short.class.getName()), new NumberToShortConverter(numberFormat, fromType, false)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToIntegerConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(Integer.class) && !fromType.equals(Integer.TYPE)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, INTEGER_TYPE), new NumberToIntegerConverter(numberFormat, fromType, true)); >+ map.put(new Pair(fromName, Integer.class.getName()), new NumberToIntegerConverter(numberFormat, fromType, false)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToLongConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(Long.class) && !fromType.equals(Long.TYPE)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, LONG_TYPE), new NumberToLongConverter(numberFormat, fromType, true)); >+ map.put(new Pair(fromName, Long.class.getName()), new NumberToLongConverter(numberFormat, fromType, false)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToFloatConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(Float.class) && !fromType.equals(Float.TYPE)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, FLOAT_TYPE), new NumberToFloatConverter(numberFormat, fromType, true)); >+ map.put(new Pair(fromName, Float.class.getName()), new NumberToFloatConverter(numberFormat, fromType, false)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToDoubleConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(Double.class) && !fromType.equals(Double.TYPE)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, DOUBLE_TYPE), new NumberToDoubleConverter(numberFormat, fromType, true)); >+ map.put(new Pair(fromName, Double.class.getName()), new NumberToDoubleConverter(numberFormat, fromType, false)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToBigIntegerConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(BigInteger.class)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, BigInteger.class.getName()), new NumberToBigIntegerConverter(numberFormat, fromType)); >+ } >+ } >+ } >+ >+ /** >+ * Registers converters to boxed and unboxed types from a list of from classes. >+ * >+ * @param map >+ * @param numberFormat >+ * @param fromTypes >+ */ >+ private static void addNumberToBigDecimalConverters(Map map, NumberFormat numberFormat, Class[] fromTypes) { >+ for (int i = 0; i < fromTypes.length; i++) { >+ Class fromType = fromTypes[i]; >+ if (!fromType.equals(BigDecimal.class)) { >+ String fromName = (fromType.isPrimitive()) ? getKeyForClass(fromType, null) : fromType.getName(); >+ >+ map.put(new Pair(fromName, BigDecimal.class.getName()), new NumberToBigDecimalConverter(numberFormat, fromType)); >+ } >+ } >+ } >+ >+ >+ private static String getKeyForClass(Object originalValue, Class filteredValue) { >+ if (originalValue instanceof Class) { >+ Class originalClass = (Class) originalValue; >+ if (originalClass.equals(Integer.TYPE)) { >+ return INTEGER_TYPE; >+ } else if (originalClass.equals(Byte.TYPE)) { >+ return BYTE_TYPE; >+ } else if (originalClass.equals(Boolean.TYPE)) { >+ return BOOLEAN_TYPE; >+ } else if (originalClass.equals(Double.TYPE)) { >+ return DOUBLE_TYPE; >+ } else if (originalClass.equals(Float.TYPE)) { >+ return FLOAT_TYPE; >+ } else if (originalClass.equals(Long.TYPE)) { >+ return LONG_TYPE; >+ } else if (originalClass.equals(Short.TYPE)) { >+ return SHORT_TYPE; >+ } >+ } >+ return filteredValue.getName(); >+ } >+ >+ /** >+ * @param fromType >+ * @param toType >+ * @return whether fromType is assignable to toType >+ */ >+ public Boolean isAssignableFromTo(Object fromType, Object toType) { >+ if (fromType instanceof Class && toType instanceof Class) { >+ Class toClass = (Class) toType; >+ if (toClass.isPrimitive()) { >+ toClass = autoboxed(toClass); >+ } >+ Class fromClass = (Class) fromType; >+ if (fromClass.isPrimitive()) { >+ fromClass = autoboxed(fromClass); >+ } >+ return toClass.isAssignableFrom(fromClass) ? Boolean.TRUE >+ : Boolean.FALSE; >+ } >+ return null; >+ } >+ >+ >+ >+ private static Map getConverterMap() { >+ // using string-based lookup avoids loading of too many classes >+ if (converterMap == null) { >+ //NumberFormat to be shared across converters for the formatting of integer values >+ NumberFormat integerFormat = NumberFormat.getIntegerInstance(); >+ //NumberFormat to be shared across converters for formatting non integer values >+ NumberFormat numberFormat = NumberFormat.getNumberInstance(); >+ >+ converterMap = new HashMap(); >+ converterMap >+ .put( >+ new Pair("java.util.Date", "java.lang.String"), "org.eclipse.core.internal.databinding.conversion.DateToStringConverter"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ converterMap >+ .put( >+ new Pair("java.lang.String", "java.lang.Boolean"), "org.eclipse.core.internal.databinding.conversion.StringToBooleanConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >+ converterMap >+ .put( >+ new Pair("java.lang.String", "java.lang.Byte"), StringToByteConverter.toByte(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap >+ .put( >+ new Pair("java.lang.String", "java.lang.Character"), "org.eclipse.core.internal.databinding.conversion.StringToCharacterConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >+ converterMap >+ .put( >+ new Pair("java.lang.String", "java.util.Date"), "org.eclipse.core.internal.databinding.conversion.StringToDateConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >+ converterMap >+ .put( >+ new Pair("java.lang.String", "java.lang.Short"), StringToShortConverter.toShort(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ >+ converterMap.put(new Pair("java.lang.String", "java.lang.Integer"), StringToNumberConverter.toInteger(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.String", "java.lang.Double"), StringToNumberConverter.toDouble(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.String", "java.lang.Long"), StringToNumberConverter.toLong(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.String", "java.lang.Float"), StringToNumberConverter.toFloat(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.String", "java.math.BigInteger"), StringToNumberConverter.toBigInteger(integerFormat)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.Integer", "java.lang.String"), NumberToStringConverter.fromInteger(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.Long", "java.lang.String"), NumberToStringConverter.fromLong(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.Double", "java.lang.String"), NumberToStringConverter.fromDouble(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.Float", "java.lang.String"), NumberToStringConverter.fromFloat(numberFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.math.BigInteger", "java.lang.String"), NumberToStringConverter.fromBigInteger(integerFormat)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.Byte", "java.lang.String"), IntegerToStringConverter.fromByte(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ converterMap.put(new Pair("java.lang.Short", "java.lang.String"), IntegerToStringConverter.fromShort(integerFormat, false)); //$NON-NLS-1$//$NON-NLS-2$ >+ >+ converterMap >+ .put( >+ new Pair("java.lang.Object", "java.lang.String"), "org.eclipse.core.internal.databinding.conversion.ObjectToStringConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >+ >+ // Integer.TYPE >+ converterMap.put(new Pair("java.lang.String", INTEGER_TYPE), StringToNumberConverter.toInteger(integerFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(INTEGER_TYPE, "java.lang.Integer"), new IdentityConverter(Integer.TYPE, Integer.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(INTEGER_TYPE, "java.lang.Object"), new IdentityConverter(Integer.TYPE, Object.class)); //$NON-NLS-1$ >+ converterMap.put(new Pair(INTEGER_TYPE, "java.lang.String"), NumberToStringConverter.fromInteger(integerFormat, true)); //$NON-NLS-1$ >+ >+ // Byte.TYPE >+ converterMap >+ .put( >+ new Pair("java.lang.String", BYTE_TYPE), StringToByteConverter.toByte(integerFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(BYTE_TYPE, "java.lang.Byte"), new IdentityConverter(Byte.TYPE, Byte.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(BYTE_TYPE, "java.lang.String"), IntegerToStringConverter.fromByte(integerFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(BYTE_TYPE, "java.lang.Object"), new IdentityConverter(Byte.TYPE, Object.class)); //$NON-NLS-1$ >+ >+ // Double.TYPE >+ converterMap.put(new Pair("java.lang.String", DOUBLE_TYPE), StringToNumberConverter.toDouble(numberFormat, true)); //$NON-NLS-1$ >+ converterMap.put(new Pair(DOUBLE_TYPE, "java.lang.String"), NumberToStringConverter.fromDouble(numberFormat, true)); //$NON-NLS-1$ >+ >+ converterMap >+ .put( >+ new Pair(DOUBLE_TYPE, "java.lang.Double"), new IdentityConverter(Double.TYPE, Double.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(DOUBLE_TYPE, "java.lang.Object"), new IdentityConverter(Double.TYPE, Object.class)); //$NON-NLS-1$ >+ >+ // Boolean.TYPE >+ converterMap >+ .put( >+ new Pair("java.lang.String", BOOLEAN_TYPE), "org.eclipse.core.internal.databinding.conversion.StringToBooleanPrimitiveConverter"); //$NON-NLS-1$ //$NON-NLS-2$ >+ converterMap >+ .put( >+ new Pair(BOOLEAN_TYPE, "java.lang.Boolean"), new IdentityConverter(Boolean.TYPE, Boolean.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(BOOLEAN_TYPE, "java.lang.String"), new ObjectToStringConverter(Boolean.TYPE)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(BOOLEAN_TYPE, "java.lang.Object"), new IdentityConverter(Boolean.TYPE, Object.class)); //$NON-NLS-1$ >+ >+ // Float.TYPE >+ converterMap.put(new Pair("java.lang.String", FLOAT_TYPE), StringToNumberConverter.toFloat(numberFormat, true)); //$NON-NLS-1$ >+ converterMap.put(new Pair(FLOAT_TYPE, "java.lang.String"), NumberToStringConverter.fromFloat(numberFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(FLOAT_TYPE, "java.lang.Float"), new IdentityConverter(Float.TYPE, Float.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(FLOAT_TYPE, "java.lang.Object"), new IdentityConverter(Float.TYPE, Object.class)); //$NON-NLS-1$ >+ >+ // Short.TYPE >+ converterMap >+ .put( >+ new Pair("java.lang.String", SHORT_TYPE), StringToShortConverter.toShort(integerFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(SHORT_TYPE, "java.lang.Short"), new IdentityConverter(Short.TYPE, Short.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(SHORT_TYPE, "java.lang.String"), IntegerToStringConverter.fromShort(integerFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(SHORT_TYPE, "java.lang.Object"), new IdentityConverter(Short.TYPE, Object.class)); //$NON-NLS-1$ >+ >+ // Long.TYPE >+ converterMap.put(new Pair("java.lang.String", LONG_TYPE), StringToNumberConverter.toLong(integerFormat, true)); //$NON-NLS-1$ >+ converterMap.put(new Pair(LONG_TYPE, "java.lang.String"), NumberToStringConverter.fromLong(integerFormat, true)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(LONG_TYPE, "java.lang.Long"), new IdentityConverter(Long.TYPE, Long.class)); //$NON-NLS-1$ >+ converterMap >+ .put( >+ new Pair(LONG_TYPE, "java.lang.Object"), new IdentityConverter(Long.TYPE, Object.class)); //$NON-NLS-1$ >+ >+ converterMap >+ .put( >+ new Pair("org.eclipse.core.runtime.IStatus", "java.lang.String"), "org.eclipse.core.internal.databinding.conversion.StatusToStringConverter"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ >+ >+ addNumberToByteConverters(converterMap, integerFormat, integerClasses); >+ addNumberToByteConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToShortConverters(converterMap, integerFormat, integerClasses); >+ addNumberToShortConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToIntegerConverters(converterMap, integerFormat, integerClasses); >+ addNumberToIntegerConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToLongConverters(converterMap, integerFormat, integerClasses); >+ addNumberToLongConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToFloatConverters(converterMap, integerFormat, integerClasses); >+ addNumberToFloatConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToDoubleConverters(converterMap, integerFormat, integerClasses); >+ addNumberToDoubleConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToBigIntegerConverters(converterMap, integerFormat, integerClasses); >+ addNumberToBigIntegerConverters(converterMap, numberFormat, floatClasses); >+ >+ addNumberToBigDecimalConverters(converterMap, integerFormat, integerClasses); >+ addNumberToBigDecimalConverters(converterMap, numberFormat, floatClasses); >+ } >+ >+ return converterMap; >+ } >+} >Index: src/org/eclipse/core/databinding/conversion/IConverterProvider.java >=================================================================== >RCS file: src/org/eclipse/core/databinding/conversion/IConverterProvider.java >diff -N src/org/eclipse/core/databinding/conversion/IConverterProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/databinding/conversion/IConverterProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.core.databinding.conversion; >+ >+/** >+ * @since 3.3 >+ * >+ */ >+public interface IConverterProvider { >+ /** >+ * @param fromType >+ * @param toType >+ * @return the converter >+ */ >+ public IConverter createConverter(Object fromType, Object toType); >+ >+ /** >+ * @param fromType >+ * @param toType >+ * @return null >+ */ >+ public Boolean isAssignableFromTo(Object fromType, Object toType); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 203492
: 80312 |
82601