Class DefaultLogger.LocalizedMessage

  • Enclosing class:
    DefaultLogger

    private static final class DefaultLogger.LocalizedMessage
    extends Object
    Represents a message that can be localised. The translations come from message.properties files. The underlying implementation uses java.text.MessageFormat.
    • Field Detail

      • BUNDLE_CACHE

        private static final Map<String,​ResourceBundle> BUNDLE_CACHE
        A cache that maps bundle names to ResourceBundles. Avoids repetitive calls to ResourceBundle.getBundle().
      • LOCALE

        private static final Locale LOCALE
        The locale to localise messages to.
      • key

        private final String key
        Key for the message format.
      • args

        private final String[] args
        Arguments for MessageFormat.
    • Constructor Detail

      • LocalizedMessage

        LocalizedMessage​(String key)
        Creates a new LocalizedMessage instance.
        Parameters:
        key - the key to locate the translation.
      • LocalizedMessage

        LocalizedMessage​(String key,
                         String... args)
        Creates a new LocalizedMessage instance.
        Parameters:
        key - the key to locate the translation.
        args - arguments for the translation.
    • Method Detail

      • getMessage

        private String getMessage()
        Gets the translated message.
        Returns:
        the translated message.
      • getBundle

        private static ResourceBundle getBundle​(String bundleName)
        Find a ResourceBundle for a given bundle name. Uses the classloader of the class emitting this message, to be sure to get the correct bundle.
        Parameters:
        bundleName - the bundle name.
        Returns:
        a ResourceBundle.