Class DefaultLogger.LocalizedMessage

  • Enclosing class:
    DefaultLogger

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

      Fields 
      Modifier and Type Field Description
      private java.lang.String[] args
      Arguments for MessageFormat.
      private static java.util.Map<java.lang.String,​java.util.ResourceBundle> BUNDLE_CACHE
      A cache that maps bundle names to ResourceBundles.
      private java.lang.String key
      Key for the message format.
      private static java.util.Locale LOCALE
      The locale to localise messages to.
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalizedMessage​(java.lang.String key)
      Creates a new LocalizedMessage instance.
      LocalizedMessage​(java.lang.String key, java.lang.String... args)
      Creates a new LocalizedMessage instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.util.ResourceBundle getBundle​(java.lang.String bundleName)
      Find a ResourceBundle for a given bundle name.
      private java.lang.String getMessage()
      Gets the translated message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BUNDLE_CACHE

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

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

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

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

      • LocalizedMessage

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

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

      • getMessage

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

        private static java.util.ResourceBundle getBundle​(java.lang.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.