Package java.text

Examples of java.text.MessageFormat.format()


        // Perform the formatting. We synchronize on it in case it
        // contains date formatting, which is not thread-safe.
        synchronized(format)
        {
            return format.format(params);
        }
    }

    public ResourceBundle getBundle()
    {
View Full Code Here


            {
                return null;
            }

            final MessageFormat msg = findMessage(code);
            return msg.format(params);
        }
        catch (final MissingResourceException mre)
        {
            return "Unknown message with code \"" + code + "\".";
        }
View Full Code Here

                if (formatter == null)
                {
                    formatter = new MessageFormat(stringForKey);
                    msgFormats.put(stringForKey,formatter);
                }
                return formatter.format(msgArgs);
            }
            else
            {
                return stringForKey;
            }
View Full Code Here

  format.setLocale (locale);

  // return the formatted message
  StringBuffer  result = new StringBuffer ();

  result = format.format (parameters, result, new FieldPosition (0));
  return result.toString ();
    }


    /**
 
View Full Code Here

    }
    if (objects != null) {
      MessageFormat formatter = new MessageFormat("");
      formatter.setLocale(ctx.getLocale());
      formatter.applyPattern(pattern);
      pattern = formatter.format(objects);
    }
    return pattern;
  }
 
  private static Business getBusiness() {
View Full Code Here

    }

    if (params != null)
    {
      MessageFormat mf = new MessageFormat(text, locale);
      text = mf.format(params, new StringBuffer(), null).toString();
    }

    return text;
  }
}
View Full Code Here

      retMessage = m_bundle.getString(key);

      if (varargs.length > 0) {
        MessageFormat mf = new MessageFormat(retMessage, m_locale);
        retMessage = mf.format(varargs);
      }

      // remember these in case we are asked to get the message again in a different locale or
      // we need to reconsitute the message after being serialized.
      m_lastKey = key;
View Full Code Here

                   {
                     if (timeMinorGC == null)
                       timeMinorGC = 0L;
                     if (timeFullGC == null)
                       timeFullGC = 0L;
                       System.err.println(format.format(new Object[]{usedHeap, timeMinorGC, timeFullGC}));
                       usedHeap = null;
                       timeMinorGC = null;
                       timeFullGC = null;
                   }
             
View Full Code Here

  public static String getString(String key, String argument) {
    try {
      String message = RESOURCE_BUNDLE.getString(key);
      MessageFormat messageFormat = new MessageFormat(message);
      return messageFormat.format(new String[] { argument } );
    } catch (MissingResourceException e) {
      return '!' + key + '!';
    }
  }
}
View Full Code Here

  @Test
  public void testGetFormatter() {
    MessageFormat format = MessageFormatter.getFormat("Is this Frame2?", Locale.UK); //$NON-NLS-1$
    assertNotNull(format);
    assertEquals(Locale.UK, format.getLocale());
    assertEquals("Is this Frame2?", format.format(null)); //$NON-NLS-1$
    assertSame(format, MessageFormatter.getFormat("Is this Frame2?", Locale.UK)); //$NON-NLS-1$
  }
}
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.