Package java.text

Examples of java.text.MessageFormat.format()


     * @return String
     */
    static public String format(String pattern, Locale locale, Object[] args) {
        MessageFormat format = getFormat(pattern, locale);

        return format.format(args);
    }

    /**
     * Return a MessageFormat object for the given pattern and locale. Because
     * these objects are cached and shared between threads it is important that
View Full Code Here


    {
        for (int i=0; i<msgArgs.length; i++) {
            if (msgArgs[i] == null) msgArgs[i] = ""; // NOI18N
        }
        MessageFormat formatter = new MessageFormat(messages.getString(messageKey));
        return formatter.format(msgArgs);
    }
    /**
     * Formats message by adding a String argument
     */
    final public static String getMessage(ResourceBundle messages, String messageKey, String arg)
View Full Code Here

        if (greeting == null) {
            Locale locale = new Locale(language);
            return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
        }

        return greeting.format(new Object[]{friend});
    }

    public void addGreeting(String language, String message) {
        greetings.put(language, new MessageFormat(message));
    }
View Full Code Here

            MessageFormat format;

            if (summary != null)
            {
                format = new MessageFormat(summary, locale);
                summary = format.format(args);
            }

            if (detail != null)
            {
                format = new MessageFormat(detail, locale);
View Full Code Here

            }

            if (detail != null)
            {
                format = new MessageFormat(detail, locale);
                detail = format.format(args);
            }
        }

        return new _LabeledFacesMessage(severity, summary, detail);
    }
View Full Code Here

      String message = bundle.getString(getMessageKey());
      // if arguments exist, use MessageFormat to include them
      if (getArguments().length > 0) {
        MessageFormat fmt = new MessageFormat(message);
        fmt.setLocale(aLocale);
        return fmt.format(getArguments());
      } else
        return message;
    } catch (Exception e) {
      return "EXCEPTION MESSAGE LOCALIZATION FAILED: " + e.toString();
    }
View Full Code Here

        return sb.toString();
    }

    private void savePlan(String filename, Object[] args) {
        MessageFormat mf = new MessageFormat(PLAN_TEMPLATE);
        String plan = mf.format(args);

        try {
            File f = new File(filename);
            f.createNewFile();
            FileOutputStream fos = new FileOutputStream(f);
View Full Code Here

          return message;
        }
        mf = new MessageFormat(msg);
        formats.put(message, mf);
      }
      return mf.format(args);
    } catch (Exception except) {
      return "An internal error occured while processing message " + message;
    }
  }
View Full Code Here

        final Object[] messageArguments = {param1};
        // Create a new MessageFormat to ensure thread safety.
        // Sharing a MessageFormat and using applyPattern is not thread safe
        MessageFormat formatter = new MessageFormat(rawMessage, _currentLocale);

        final String message = formatter.format(messageArguments);

        return new LogMessage()
        {
            public String toString()
            {
View Full Code Here

        final Object[] messageArguments = {param1, param2};
        // Create a new MessageFormat to ensure thread safety.
        // Sharing a MessageFormat and using applyPattern is not thread safe
        MessageFormat formatter = new MessageFormat(rawMessage, _currentLocale);

        final String message = formatter.format(messageArguments);

        return new LogMessage()
        {
            public String toString()
            {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.