Class MessageFactory


  • public final class MessageFactory
    extends java.lang.Object
    Factory for creating localized JDBC pool messages.

    The messages are read from the LocalStrings resource bundle of this package, which the JVM resolves once, under the default locale in effect at class initialization. A message is handed out unchanged by get(String) and passed through MessageFormat by get(String, Object...), so bundle text must match how its key is fetched: a key fetched without arguments is written literally, while a key fetched with arguments follows the MessageFormat conventions, where a literal single quote is written ''.

    • Constructor Summary

      Constructors 
      Constructor Description
      MessageFactory​(java.util.ResourceBundle bundle)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String get​(java.lang.String key)
      Get a localized message.
      static java.lang.String get​(java.lang.String key, java.lang.Object... args)
      Get a localized message with arguments substituted by MessageFormat.
      protected java.lang.String getInternal​(java.lang.String key)
      Get a message from the bundle.
      protected java.lang.String getInternal​(java.lang.String key, java.lang.Object... args)
      Get a message from the bundle with arguments.
      • Methods inherited from class java.lang.Object

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

      • MessageFactory

        public MessageFactory​(java.util.ResourceBundle bundle)
        Constructor.
        Parameters:
        bundle - the resource bundle
    • Method Detail

      • get

        public static java.lang.String get​(java.lang.String key)
        Get a localized message. The message is returned exactly as written in the bundle, with no argument substitution and no MessageFormat applied.
        Parameters:
        key - the message key
        Returns:
        the message
      • get

        public static java.lang.String get​(java.lang.String key,
                                           java.lang.Object... args)
        Get a localized message with arguments substituted by MessageFormat. The argument array is never modified. A pattern that MessageFormat cannot apply is returned unformatted rather than reported as a failure.
        Parameters:
        key - the message key
        args - the arguments
        Returns:
        the message
      • getInternal

        protected java.lang.String getInternal​(java.lang.String key)
        Get a message from the bundle.
        Parameters:
        key - the message key
        Returns:
        the message
      • getInternal

        protected java.lang.String getInternal​(java.lang.String key,
                                               java.lang.Object... args)
        Get a message from the bundle with arguments.
        Parameters:
        key - the message key
        args - the arguments
        Returns:
        the message