Package java.text

Examples of java.text.MessageFormat$MessageFormatElement


      }

      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


   * {@inheritDoc}
   */
  @Override
  protected MessageFormat resolveCode(String code, Locale locale) {
    String codePart = code;
    MessageFormat res = super.resolveCode(codePart, locale);
    if (res == null) {
      MessageSource parent = getParentMessageSource();
      if (parent instanceof EnhancedResourceBundleMessageSource) {
        res = ((EnhancedResourceBundleMessageSource) parent).baseResolveCode(
            code, locale);
View Full Code Here

    {
      exceptionPattern = "[{0} - {1}] {2} {3} \nException in {4}: {6} \n{7} ";
    }
    setExceptionPattern(exceptionPattern);

    logMessageFormat = new MessageFormat(logPattern);
    exceptionMessageFormat = new MessageFormat(exceptionPattern);

    dateFormat = new SimpleDateFormat(timeFormat);
  }
View Full Code Here

    logFormat = logFormat.replace("%PARAM0%", "{6}");
    logFormat = logFormat.replace("%PARAM1%", "{7}");

    this.logPattern = logFormat;

    logMessageFormat = new MessageFormat(logPattern);
  }
View Full Code Here

    exceptionFormat = exceptionFormat.replace("%EXCEPTION%", "{6}");
    exceptionFormat = exceptionFormat.replace("%STACKTRACE%", "{7}");

    this.exceptionPattern = exceptionFormat;

    exceptionMessageFormat = new MessageFormat(logPattern);
  }
View Full Code Here

  private void monitorGc(YajswConfigurationImpl config)
  {
    if (config.containsKey("wrapper.java.monitor.gc"))
    try
    {
      final MessageFormat format = new MessageFormat(config.getString("wrapper.java.monitor.gc"));
      final long cycle = config.getLong("wrapper.java.monitor.gc.interval", 1)*1000;
      GarbageCollectorMXBean minorGCBeanX = null;
      GarbageCollectorMXBean fullGCBeanX = null;
      List<GarbageCollectorMXBean> gcMBeans = ManagementFactory.getGarbageCollectorMXBeans();

         for (GarbageCollectorMXBean gcBean : gcMBeans) {
             if ("Copy".equals(gcBean.getName())) {
                 minorGCBeanX = gcBean;
             } else if ("MarkSweepCompact".equals(gcBean.getName())) {
                 fullGCBeanX = gcBean;
             } else if ("ParNew".equals(gcBean.getName())) {
                 minorGCBeanX = gcBean;
             } else if ("ConcurrentMarkSweep".equals(gcBean.getName())) {
                 fullGCBeanX = gcBean;
             } else {
                 System.err.println("Unable to classify GarbageCollectorMXBean [" + gcBean.getName() + "]");
             }
         }
      final GarbageCollectorMXBean minorGCBean = minorGCBeanX;
      final GarbageCollectorMXBean fullGCBean = fullGCBeanX;
      final MemoryMXBean bean = ManagementFactory.getMemoryMXBean();

      System.err.println("monitor gc: start");
      executor.execute(new Runnable()
      {
        private long lastMinorCollectionCount;
        private long lastMinorCollectionTime;

        private long lastFullCollectionCount;
        private long lastFullCollectionTime;
       
        Long usedHeap = null;
        Long timeMinorGC = null;
        Long timeFullGC = null;

        public void run()
        {
          if (minorGCBean == null)
          {
            System.err.println("monitor gc: could not find minorGCBean -> abort monitor");
            return;
          }
          if (fullGCBean == null)
          {
            System.err.println("monitor gc: could not find fullGCBean -> abort monitor");
            return;
          }
          try
          {
            while (!_stopping)
          {
            if (minorGCBean.getCollectionCount() != lastMinorCollectionCount) {
                       long diffCount = minorGCBean.getCollectionCount() - lastMinorCollectionCount;
                       long diffTime = minorGCBean.getCollectionTime() - lastMinorCollectionTime;
                       if (diffCount!= 0 && diffCount != 1)
                         timeMinorGC = diffTime/diffCount;
                       else
                         timeMinorGC = diffTime;
                       usedHeap = bean.getHeapMemoryUsage().getUsed();
                 
                       lastMinorCollectionCount = minorGCBean.getCollectionCount();
                       lastMinorCollectionTime = minorGCBean.getCollectionTime();
                   }
             
                   if (fullGCBean.getCollectionCount() != lastFullCollectionCount) {
                       long diffCount = fullGCBean.getCollectionCount() - lastFullCollectionCount;
                       long diffTime = fullGCBean.getCollectionTime() - lastFullCollectionTime;
                       if (diffCount!= 0 && diffCount != 1)
                         timeFullGC = diffTime/diffCount;
                       else
                         timeFullGC = diffTime;
                       usedHeap = bean.getHeapMemoryUsage().getUsed();
                 
                       lastFullCollectionCount = fullGCBean.getCollectionCount();
                       lastFullCollectionTime = fullGCBean.getCollectionTime();
                   }
                   if (usedHeap != null)
                   {
                     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

        new Object[] { new Double(10.01)}));
  }

  @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

    public void performAction() {
        wizardDescriptor = new WizardDescriptor(getPanels());
        step1.setWizardDescriptor(wizardDescriptor);
        step2.setWizardDescriptor(wizardDescriptor);
        // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
        wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
        wizardDescriptor.setTitle(getName());
        Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
        dialog.setVisible(true);
        dialog.toFront();
        boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
View Full Code Here

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

        return format.format(args);
    }
View Full Code Here

TOP

Related Classes of java.text.MessageFormat$MessageFormatElement

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.