Package java.text

Examples of java.text.MessageFormat


      ResourceBundle bundle = ResourceBundle.getBundle(getResourceBundleName(), aLocale);
      // retrieve the message from the resource bundle
      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

      synchronized (Messages.class) {
        init()// TODO Remove lazy call to init
      }
    }

    MessageFormat mf;
    String msg;

    try {
      mf = (MessageFormat) formats.get(message);
      if (mf == null) {
        try {
          msg = messages.getString(message);
        } catch (MissingResourceException except) {
          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

        roleBase = (String) options.get(ROLE_BASE);
        roleName = (String) options.get(ROLE_NAME);
        roleSearchMatching = (String) options.get(ROLE_SEARCH_MATCHING);
        roleSearchSubtree = (String) options.get(ROLE_SEARCH_SUBTREE);
        userRoleName = (String) options.get(USER_ROLE_NAME);
        userSearchMatchingFormat = new MessageFormat(userSearchMatching);
        roleSearchMatchingFormat = new MessageFormat(roleSearchMatching);
        userSearchSubtreeBool = new Boolean(userSearchSubtree).booleanValue();
        roleSearchSubtreeBool = new Boolean(roleSearchSubtree).booleanValue();
    }
View Full Code Here

        String rawMessage = _messages.getString("OPEN");

        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

        String rawMessage = _messages.getString("LISTENING");

        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

        String rawMessage = _messages.getString("SSL_KEYSTORE");

        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

        String rawMessage = _messages.getString("STOPPED");

        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

        String rawMessage = _messages.getString("CLOSE");

        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

        String rawMessage = _messages.getString("SHUTTING_DOWN");

        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

Related Classes of java.text.MessageFormat

Copyright © 2018 www.massapicom. 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.