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.nearinfinity.blur.log.LogImpl.java

public void trace(Object message, Throwable t, Object... args) {
    if (isTraceEnabled()) {
        log.trace(MessageFormat.format(message.toString(), args), t);
    }/*from  w w w  . j ava2 s .  c o  m*/
}

From source file:info.magnolia.module.admininterface.dialogs.ConfiguredDialog.java

public static Content getConfigNode(HttpServletRequest request, String name) {

    if (name == null) {
        // should never happen
        log.error("getConfigNode called with a null name."); //$NON-NLS-1$
        return null;
    }/*from  www.  j  a v a 2 s.c  om*/

    HierarchyManager hm = MgnlContext.getHierarchyManager(ContentRepository.CONFIG);
    try {
        return hm.getContent(name);
    } catch (RepositoryException e) {
        log.error(MessageFormat.format("Missing configuration for {0}. Check node {1}{0}", //$NON-NLS-1$
                new Object[] { name, "/modules/templating/Paragraphs/" })); //$NON-NLS-1$
    }
    return null;
}

From source file:ch.cyberduck.ui.cocoa.controller.LimitedListAlertController.java

@Override
public void loadBundle() {
    final NSAlert alert = NSAlert.alert();
    alert.setAlertStyle(NSAlert.NSInformationalAlertStyle);
    alert.setMessageText(MessageFormat.format(LocaleFactory.localizedString("Listing directory {0}", "Status"),
            StringUtils.EMPTY));//from  w ww. j a  va 2  s.c  om
    alert.setInformativeText(MessageFormat.format(
            LocaleFactory.localizedString("Continue listing directory with more than {0} files.", "Alert"),
            e.getChunk().size()));
    alert.addButtonWithTitle(LocaleFactory.localizedString("Continue", "Credentials"));
    alert.addButtonWithTitle(LocaleFactory.localizedString("Cancel"));
    alert.setShowsSuppressionButton(true);
    alert.suppressionButton().setTitle(LocaleFactory.localizedString("Always"));
    super.loadBundle(alert);
}

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

public static void init() {
    String url = PropertiesManager.getValue(PropertiesManager.KEY_SOLR_URL);
    if (StringUtils.isNotBlank(url)) {
        log.log(Level.INFO, MessageFormat.format("Connecting to Solr at {0}", url));
        solrServer = new HttpSolrServer(url);

    } else {//ww  w .  j av  a 2  s .c  o  m
        log.log(Level.WARNING, "Solr property (" + PropertiesManager.KEY_SOLR_URL
                + ") is not set in openstorefront.properties. Search service unavailible. Using Mock");
        solrServer = new SolrServer() {

            @Override
            public NamedList<Object> request(SolrRequest request) throws SolrServerException, IOException {
                NamedList<Object> results = new NamedList<>();
                log.log(Level.INFO, "Mock Solr recieved request: " + request);
                return results;
            }

            @Override
            public void shutdown() {
                //do nothing
            }
        };
    }
}

From source file:com.dv.sharer.restclients.ImageRestClient.java

public byte[] downloadFile(String id) throws ClientErrorException {
    WebTarget resource = getWebTarget();
    resource = resource.path(MessageFormat.format("download/{0}", new Object[] { id }));
    String response = resource.request(MediaType.TEXT_PLAIN).get(String.class);
    return Base64.decodeBase64(response);
}

From source file:com.eryansky.common.utils.io.ResourceUtils.java

/**
 *  {res}.properties  key ??/*from  w ww  .  ja  va  2 s  . co  m*/
 * 
 * @param locale
 * @param baseName
 * @param key
 * @param args
 * @return
 */
public static String getStringForLocale(Locale locale, String baseName, String key, Object... args) {
    String text = _getStringForLocale(locale, baseName, key);
    return (text != null) ? MessageFormat.format(text, args) : null;
}

From source file:fr.certu.chouette.plugin.report.ReportItem.java

/**
 * @param locale/*  ww w  .  j  ava  2  s . c o m*/
 * @return
 */
public String getLocalizedMessage(Locale locale) {
    String format = "";
    String message = "";
    try {
        ResourceBundle bundle = ResourceBundle.getBundle(this.getClass().getName(), locale);
        format = bundle.getString(getMessageKey());
        message = MessageFormat.format(format, messageArgs.toArray());
    } catch (MissingResourceException e1) {
        try {
            ResourceBundle bundle = ResourceBundle.getBundle(this.getClass().getName());
            format = bundle.getString(getMessageKey());
            message = MessageFormat.format(format, messageArgs.toArray());
        } catch (MissingResourceException e2) {
            message = getMessageKey();
            if (messageArgs != null)
                message += " : " + Arrays.toString(messageArgs.toArray());
        }
    }

    return message;
}

From source file:ch.cyberduck.ui.action.DeleteWorker.java

@Override
public String getActivity() {
    return MessageFormat.format(Locale.localizedString("Deleting {0}", "Status"), StringUtils.EMPTY);
}

From source file:com.jsonstore.util.JSONStoreUtil.java

public static String formatString(String pattern, Object... args) {
    return MessageFormat.format(pattern, args);
}

From source file:com.eu.evaluation.server.dao.DefaultDAO.java

/**
 * ?/*  ww w . j a  v  a  2s .c om*/
 * @param <T>
 * @param className ???
 * @param id ?ID
 * @param evaluateVersionID ?
 * @return 
 */
public <T> T findEvaluateData(String className, String id, String evaluateVersionID,
        AccessSystem accessSystem) {
    String jpql = "select t from {0} t where t.id = :id and t.evaluateVersion.id = :evID and t.position = :position";
    jpql = MessageFormat.format(jpql, new Object[] { className });
    MapSqlParameterSource params = new MapSqlParameterSource("id", id);
    params.addValue("evID", evaluateVersionID);
    params.addValue("position", accessSystem.getCode());
    List<T> result = find(jpql, params);
    if (result.isEmpty()) {
        String msg = "??{0}  ?ID {1}  ? {2} , ? {3}";
        throw new RuntimeException(MessageFormat.format(msg,
                new Object[] { className, id, evaluateVersionID, accessSystem.getName() }));
    } else if (result.size() == 1) {
        return result.get(0);
    } else {
        String msg = "????{0}  ?ID {1}  ? {2} , ? {3}";
        throw new RuntimeException(MessageFormat.format(msg,
                new Object[] { className, id, evaluateVersionID, accessSystem.getName() }));
    }
}