Examples of MessageFormat


Examples of java.text.MessageFormat

      text = "?? key " + key + " not found ??";
    }

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

    return text;
  }
View Full Code Here

Examples of java.text.MessageFormat

      }

      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

Examples of java.text.MessageFormat

   * {@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

Examples of java.text.MessageFormat

    {
      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

Examples of java.text.MessageFormat

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

    this.logPattern = logFormat;

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

Examples of java.text.MessageFormat

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

    this.exceptionPattern = exceptionFormat;

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

Examples of java.text.MessageFormat

  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

Examples of java.text.MessageFormat

  }

  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

Examples of java.text.MessageFormat

        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

Examples of java.text.MessageFormat

    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
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.