return formatter;
}
private DefaultFormatter createFormatter(Class<?> valueClass, FormatProvider formatProvider)
{
DefaultFormatter formatter;
//PM:18/3/08 BMO-22
//CraigM: 28/04/2008: Added back in so Domain classes will work
if (DomainDataValue.class.isAssignableFrom(valueClass) && format == null) {
// Represents a user defined DataValue
formatter = new DataFieldFormatter();
}
else if (DateTimeData.class.isAssignableFrom(valueClass)) {
if (format != null) {
formatter = new DateTimeDataFormatter(formatProvider.getDateFormat(format));
}
else {
formatter = new DateTimeDataFormatter(formatProvider.getDefaultDateFormat());
}
}
// Handle DecimalDatas differently from DoubleDatas as they have a different default. CraigM: 24/03/2008
else if (DecimalData.class.isAssignableFrom(valueClass)) {
if (format != null) {
formatter = NumericDataFormatter.getDecimalDataInstance(formatProvider.getDecimalFormat(format));
}
else {
formatter = NumericDataFormatter.getDecimalDataInstance(formatProvider.getDefaultDecimalFormat());
}
}
else if (DoubleData.class.isAssignableFrom(valueClass)) {
if (format != null) {
formatter = NumericDataFormatter.getDecimalDataInstance(formatProvider.getDecimalFormat(format));
}
else {
formatter = NumericDataFormatter.getDecimalDataInstance(formatProvider.getDefaultDoubleFormat());
}
}
else if (IntegerData.class.isAssignableFrom(valueClass)) {
if (format != null) {
formatter = NumericDataFormatter.getIntegerDataInstance(formatProvider.getDecimalFormat(format));
}
else {
formatter = NumericDataFormatter.getIntegerDataInstance(formatProvider.getDefaultIntegerFormat());
}
}
// TF:14/10/2009:If we're using a primitive numeric type like double, we want these mapped the same as if we're using Double.class
else if(Number.class.isAssignableFrom(valueClass) || valueClass.isPrimitive()) {
if (format != null) {
formatter = new ForteNumberFormatter(formatProvider.getDecimalFormat(format));
}
else {
formatter = new ForteNumberFormatter(formatProvider.getDefaultDoubleFormat());
}
}
else {
formatter = new DataFieldFormatter();
}
formatter.setValueClass(valueClass);
return applyInputMask(formatter);
}