Example usage for java.text MessageFormat format

List of usage examples for java.text MessageFormat format

Introduction

In this page you can find the example usage for java.text MessageFormat format.

Prototype

public static String format(String pattern, Object... arguments) 

Source Link

Document

Creates a MessageFormat with the given pattern and uses it to format the given arguments.

Usage

From source file:com.googlecode.psiprobe.beans.stats.providers.StandardSeriesProvider.java

public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
        HttpServletRequest request) {//from  ww  w. j  av a  2 s  .c o m
    String seriesParam = ServletRequestUtils.getStringParameter(request, "sp", null);
    for (int i = 0; i < statNames.size(); i++) {
        String statName = (String) statNames.get(i);
        if (seriesParam != null) {
            statName = MessageFormat.format(statName, new Object[] { seriesParam });
        }
        List l = statsCollection.getStats(statName);
        if (l != null) {
            dataset.addSeries(toSeries(
                    ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i), l));
        }
    }
}

From source file:net.testdriven.psiprobe.beans.stats.providers.StandardSeriesProvider.java

public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection,
        HttpServletRequest request) {/*ww w.  java 2s.  co m*/
    String seriesParam = ServletRequestUtils.getStringParameter(request, "sp", null);
    for (int i = 0; i < statNames.size(); i++) {
        String statName = (String) statNames.get(i);
        if (seriesParam != null) {
            statName = MessageFormat.format(statName, seriesParam);
        }
        List l = statsCollection.getStats(statName);
        if (l != null) {
            dataset.addSeries(toSeries(
                    ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i), l));
        }
    }
}

From source file:com.microsoft.tfs.client.common.framework.command.ExtensionPointAsyncObjectWaiter.java

private static IAsyncObjectWaiter getExtension() {
    synchronized (extensionLock) {
        if (extension == null) {
            extension = (IAsyncObjectWaiter) ExtensionLoader.loadSingleExtensionClass(EXTENSION_POINT_ID,
                    false);/*  ww  w. j  av  a 2 s.  c o m*/

            if (extension == null) {
                log.debug(MessageFormat.format(
                        "No IAsyncObjectWaiter at extension point {0}, using simple implementation", //$NON-NLS-1$
                        EXTENSION_POINT_ID));
            }
        }

        return extension;
    }
}

From source file:com.enonic.cms.core.localization.LocalizationResourceBundle.java

public String getLocalizedPhrase(String s, Object[] arguments) {
    String message = (String) handleGetObject(s);

    return StringUtils.isNotEmpty(message) ? MessageFormat.format(message, arguments) : null;
}

From source file:com.redhat.rhevm.api.common.security.auth.BasicAuthorizationScheme.java

@Override
public String getChallenge(String realm) {
    return MessageFormat.format(CHALLANGE_TEMPLATE, realm);
}

From source file:edu.usu.sdl.openstorefront.service.manager.PluginManager.java

public static void init() {
    ServiceProxy service = ServiceProxy.getProxy();

    //start any stopped bundles
    Bundle bundles[] = OsgiManager.getFelix().getBundleContext().getBundles();
    for (Bundle bundle : bundles) {
        if (Bundle.INSTALLED == bundle.getState() || Bundle.RESOLVED == bundle.getState()) {
            log.log(Level.INFO, MessageFormat.format("Starting bundle: {0}", bundle.getLocation()));

            Plugin plugin = new Plugin();
            plugin.setLocation(bundle.getLocation());
            plugin = plugin.find();/*w ww  .  jav  a 2 s.co m*/
            service.getPluginService().activatePlugin(plugin.getPluginId());
        }
    }

    AddJobModel job = new AddJobModel();
    job.setJobClass(PluginScanJob.class);
    job.setJobName(PluginScanJob.class.getSimpleName());
    job.setDescription("Watch for plugin directory changes.");
    job.setSeconds(10);
    job.setRepeatForever(true);
    JobManager.addJob(job);
}

From source file:org.zlogic.vogon.web.controller.JspController.java

/**
 * Returns the fragment ("/fragments") path
 *
 * @param fragment the fragment name/*from   w  ww  . j  a  v  a2  s.  c o m*/
 * @return the fragment ("/fragments") path
 */
@RequestMapping(value = { "/fragments/{fragment}.fragment" })
public ModelAndView fragmentModelAndView(@PathVariable String fragment) {
    String target = MessageFormat.format("fragments/{0}", new Object[] { fragment }); //NOI18N
    ModelAndView model = new ModelAndView(target);
    model.addObject("configuration", configuration); //NOI18N
    return model;
}

From source file:com.microsoft.tfs.client.eclipse.project.ProjectCloseListener.java

@Override
public void resourceChanged(final IResourceChangeEvent event) {
    if (event.getType() != IResourceChangeEvent.PRE_CLOSE || !(event.getResource() instanceof IProject)) {
        return;// w w  w  .  j  a va  2  s  .c om
    }

    final IProject project = (IProject) event.getResource();

    if (!project.isOpen()) {
        /* Sanity check */
        log.error(MessageFormat.format(
                "Project Manager received close notification for project {0} (already closed)", //$NON-NLS-1$
                project.getName()));

        return;
    }

    /* Exit if we don't manage this project */
    String providerName;
    try {
        providerName = project.getPersistentProperty(TeamUtils.PROVIDER_PROP_KEY);
    } catch (final CoreException e) {
        log.warn(MessageFormat.format(
                "Could not query repository manager for project {0} (when handling close notification)", //$NON-NLS-1$
                project.getName()), e);
        return;
    }

    if (providerName == null || !providerName.equals(TFSRepositoryProvider.PROVIDER_ID)) {
        return;
    }

    /*
     * If this is the only project for this connection, it will be
     * disconnected, thus we need to prompt for unsaved WIT changes.
     */
    final TFSRepository repository = projectManager.getRepository(project);

    if (repository != null) {
        final IProject[] allRepositoryProjects = projectManager.getProjectsForRepository(repository);

        if (allRepositoryProjects.length == 1 && allRepositoryProjects[0] == project) {
            /*
             * Note: we have to ignore the cancel button here, there is no
             * way to prevent the close from occurring.
             */
            ProjectManagerDataProviderFactory.getDataProvider().promptForDisconnect();
        }
    }

    projectManager.close(project);
}

From source file:com.summit.jbeacon.util.AutomaticallyRetryingOperation.java

public T execute() throws Exception {
    T results = null;/*from  w ww  .ja v a 2  s  .c o  m*/
    for (int i = 1; i <= this.maxRetries; i++) {
        try {
            results = operationToRetry();
            if (i > 1 && logger.isWarnEnabled()) {
                logger.warn(MessageFormat.format(
                        "Operation succeeded on the {0, number,integer}{0, choice, 1#st | 2#nd | 3#rd | 3<th} attempt.",
                        i));
            }
            break;
        } catch (Exception ex) {
            if (i < this.maxRetries) {
                if (logger.isWarnEnabled()) {
                    logger.warn(MessageFormat.format(
                            "Operation failed for the {0, number,integer}{0, choice, 1#st | 2#nd | 3#rd | 3<th} time.  Retrying.",
                            i));
                }
            } else {
                throw ex;
            }
        }
    }
    return results;
}

From source file:hadoopInstaller.logging.MessageFormattingLog.java

public void debug(String format, Object... arguments) {
    this.log.debug(MessageFormat.format(Messages.getString(format), arguments));
}