/** * {@inheritDoc} */ public FormatterFactory getFormatterFactory() { return messageContextConfig.getFormatterFactory(); } }
/** * {@inheritDoc} */ public FormatterFactory getFormatterFactory() { return messageContextConfig.getFormatterFactory(); } }
@SuppressWarnings({"unchecked"}) protected Object formatAsString(MessageContext messageContext, Object value) { if (value == null) { return null; } if (value instanceof String) { return value; } if (messageContext.config().getFormatterFactory() != null) { Formatter formatter = messageContext.config().getFormatterFactory().findFormatter(value.getClass()); if (formatter != null) { return formatter.format(messageContext, value); } } if (value instanceof Localizable) { return ((Localizable) value).toString(messageContext); } return value; } }
@SuppressWarnings({"unchecked"}) protected Object formatAsString(MessageContext messageContext, Object value) { if (value == null) { return null; } if (value instanceof String) { return value; } if (messageContext.config().getFormatterFactory() != null) { Formatter formatter = messageContext.config().getFormatterFactory().findFormatter(value.getClass()); if (formatter != null) { return formatter.format(messageContext, value); } } if (value instanceof Localizable) { return ((Localizable) value).toString(messageContext); } return value; } }
formatter = this.messageContext.config().getFormatterFactory().findFormatter(argument.getClass());
formatter = this.messageContext.config().getFormatterFactory().findFormatter(argument.getClass());
/** * {@inheritDoc} */ public String format(MessageContext messageContext, Number valueToFormat) { Locale locale = messageContext.getLocale(); GenericConfig formatterConfig = messageContext.config().getFormatterFactory() .findFormatterConfig(Number.class, locale); if (formatterConfig != null) { useCustomConfig(formatterConfig); } if (valueToFormat instanceof BigDecimal || valueToFormat instanceof Double || valueToFormat instanceof Float) { return getDecimalFormat(locale).format(valueToFormat); } else { return getNumberFormat(locale).format(valueToFormat); } }
/** * {@inheritDoc} */ public String format(MessageContext messageContext, Number valueToFormat) { Locale locale = messageContext.getLocale(); GenericConfig formatterConfig = messageContext.config().getFormatterFactory() .findFormatterConfig(Number.class, locale); if (formatterConfig != null) { useCustomConfig(formatterConfig); } if (valueToFormat instanceof BigDecimal || valueToFormat instanceof Double || valueToFormat instanceof Float) { return getDecimalFormat(locale).format(valueToFormat); } else { return getNumberFormat(locale).format(valueToFormat); } }
private DefaultMessageContextConfig(MessageContextConfig messageContextConfigTemplate) { this(); this.messageInterpolator = messageContextConfigTemplate.getMessageInterpolator(); this.messageResolver = messageContextConfigTemplate.getMessageResolver(); MessageHandler newMessageHandler = messageContextConfigTemplate.getMessageHandler(); if (newMessageHandler instanceof CompositeMessageHandler) { this.messageHandlers.addAll(((CompositeMessageHandler) newMessageHandler).getMessageHandlers()); } else { this.messageHandlers.add(newMessageHandler); } this.localeResolver = messageContextConfigTemplate.getLocaleResolver(); this.formatterFactory = messageContextConfigTemplate.getFormatterFactory(); }
private DefaultMessageContextConfig(MessageContextConfig messageContextConfigTemplate) { this(); this.messageInterpolator = messageContextConfigTemplate.getMessageInterpolator(); this.messageResolver = messageContextConfigTemplate.getMessageResolver(); MessageHandler newMessageHandler = messageContextConfigTemplate.getMessageHandler(); if (newMessageHandler instanceof CompositeMessageHandler) { this.messageHandlers.addAll(((CompositeMessageHandler) newMessageHandler).getMessageHandlers()); } else { this.messageHandlers.add(newMessageHandler); } this.localeResolver = messageContextConfigTemplate.getLocaleResolver(); this.formatterFactory = messageContextConfigTemplate.getFormatterFactory(); }