Blog

  • 2024
  • 2023
  • 2022
  • 2021
  • 2020
  • 2019
  • 2018
  • 2017
  • 2016
  • 2015
  • 2014
  • 2013
  • 2012




The library smartics exception for Java has been released with version 0.12.0.

This release adds a new feature that allows methods for message parameters to create locale dependent representations. Such a method simply adds a parameter of type java.util.Locale and gets the locale passed from the calling framework. Here is an example of a method that generates the replacement for a message parameter that is dependent on the locale:

@MessageParam("violations")
public final String getViolationsAsText(final Locale locale) {
  final StringBuilder buffer = new StringBuilder();
  if (propertyViolations != null && !propertyViolations.isEmpty()) {
    for (final PropertyException violation : propertyViolations) {
      buffer.append("  ")
            .append(violation.getLocalizedMessage(locale))
            .append('\n');
    }
  }
  return StringUtils.chomp(buffer.toString());
} 

A second new feature allows to call the locale-aware message getter on the cause of an I18N smartics exception. Prior to this the getLocalizedMessage had been called that used the system’s default locale, which usually did not return the desired representation.

For details on this version of the library please visit the project’s homepage, for changes since the last version, please consult the release report.


Link

Link

Posts