Class Messages


  • public class Messages
    extends java.lang.Object
    This class retrieves strings from a resource bundle and returns them, formatting them with MessageFormat when required.

    It is used by the system classes to provide national language support, by looking up messages in the com.itextpdf.text.geom.misc.messages resource bundle. Note that if this file is not available, or an invalid key is looked up, or resource bundle support is not available, the key itself will be returned as the associated message. This means that the KEY should a reasonable human-readable (English) string.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.ResourceBundle bundle  
    • Constructor Summary

      Constructors 
      Constructor Description
      Messages()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String format​(java.lang.String format, java.lang.Object[] args)
      Generates a formatted text string given a source string containing "argument markers" of the form "{argNum}" where each argNum must be in the range 0..9.
      static java.lang.String getString​(java.lang.String msg)
      Retrieves a message which has no arguments.
      static java.lang.String getString​(java.lang.String msg, char arg)
      Retrieves a message which takes 1 character argument.
      static java.lang.String getString​(java.lang.String msg, int arg)
      Retrieves a message which takes 1 integer argument.
      static java.lang.String getString​(java.lang.String msg, java.lang.Object arg)
      Retrieves a message which takes 1 argument.
      static java.lang.String getString​(java.lang.String msg, java.lang.Object[] args)
      Retrieves a message which takes several arguments.
      static java.lang.String getString​(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
      Retrieves a message which takes 2 arguments.
      • Methods inherited from class java.lang.Object

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

      • bundle

        private static java.util.ResourceBundle bundle
    • Constructor Detail

      • Messages

        public Messages()
    • Method Detail

      • getString

        public static java.lang.String getString​(java.lang.String msg)
        Retrieves a message which has no arguments.
        Parameters:
        msg - String the key to look up.
        Returns:
        String the message for that key in the system message bundle.
      • getString

        public static java.lang.String getString​(java.lang.String msg,
                                                 java.lang.Object arg)
        Retrieves a message which takes 1 argument.
        Parameters:
        msg - String the key to look up.
        arg - Object the object to insert in the formatted output.
        Returns:
        String the message for that key in the system message bundle.
      • getString

        public static java.lang.String getString​(java.lang.String msg,
                                                 int arg)
        Retrieves a message which takes 1 integer argument.
        Parameters:
        msg - String the key to look up.
        arg - int the integer to insert in the formatted output.
        Returns:
        String the message for that key in the system message bundle.
      • getString

        public static java.lang.String getString​(java.lang.String msg,
                                                 char arg)
        Retrieves a message which takes 1 character argument.
        Parameters:
        msg - String the key to look up.
        arg - char the character to insert in the formatted output.
        Returns:
        String the message for that key in the system message bundle.
      • getString

        public static java.lang.String getString​(java.lang.String msg,
                                                 java.lang.Object arg1,
                                                 java.lang.Object arg2)
        Retrieves a message which takes 2 arguments.
        Parameters:
        msg - String the key to look up.
        arg1 - Object an object to insert in the formatted output.
        arg2 - Object another object to insert in the formatted output.
        Returns:
        String the message for that key in the system message bundle.
      • getString

        public static java.lang.String getString​(java.lang.String msg,
                                                 java.lang.Object[] args)
        Retrieves a message which takes several arguments.
        Parameters:
        msg - String the key to look up.
        args - Object[] the objects to insert in the formatted output.
        Returns:
        String the message for that key in the system message bundle.
      • format

        public static java.lang.String format​(java.lang.String format,
                                              java.lang.Object[] args)
        Generates a formatted text string given a source string containing "argument markers" of the form "{argNum}" where each argNum must be in the range 0..9. The result is generated by inserting the toString of each argument into the position indicated in the string.

        To insert the "{" character into the output, use a single backslash character to escape it (i.e. "\{"). The "}" character does not need to be escaped.

        Parameters:
        format - String the format to use when printing.
        args - Object[] the arguments to use.
        Returns:
        String the formatted message.