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.microsoft.tfs.client.common.ui.framework.compare.internal.CompatibleCompareUI.java

public static void openCompareDialog(final CompareEditorInput input) {
    Shell shell = null;/*w  w  w  .j  a  v a  2  s . c  om*/
    final IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    if (activeWindow != null) {
        shell = ShellUtils.getBestParent(activeWindow.getShell());
    }

    if (shell == null) {
        log.error(MessageFormat.format(
                "Could not open compare dialog for {0}, no active workbench window shell found", //$NON-NLS-1$
                input.getName()));
        return;
    }

    /* Prepare the compare input */
    final PrepareCompareCommand prepareCommand = new PrepareCompareCommand(input);
    final IStatus prepareStatus = UICommandExecutorFactory.newUICommandExecutor(shell).execute(prepareCommand);

    if (!prepareStatus.isOK()) {
        return;
    }

    if (input.getCompareResult() == null) {
        MessageDialog.openInformation(shell,
                Messages.getString("CompatibleCompareUI.CompareNoDifferencesTitle"), //$NON-NLS-1$
                Messages.getString("CompatibleCompareUI.CompareNoDifferencesMessage")); //$NON-NLS-1$
        return;
    }

    final CompatibleCompareDialog dialog = new CompatibleCompareDialog(shell, input);
    dialog.open();
}

From source file:com.alibaba.otter.shared.arbitrate.impl.manage.helper.ManagePathUtils.java

/**
 * node path/*  w  ww  . j ava  2  s . c o m*/
 */
public static String getNode(Long nodeId) {
    // ?nodeIdpath
    return MessageFormat.format(ArbitrateConstants.NODE_NID_FORMAT, String.valueOf(nodeId));
}

From source file:Main.java

static String localize(Locale locale, String baseName, String messageId, Object... parameters) {
    //Log.v(LOG_TAG, String.format("locale=%s, baseName=%s, messageId=%s, parameters=%s", locale, baseName, messageId, Arrays.asList(parameters)));
    if (locale == null) {
        locale = Locale.getDefault();
    }/*from  www  .j  a  v a  2 s.c o  m*/
    try {
        ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale);
        String source = bundle.getString(messageId);
        return MessageFormat.format(source, parameters);
    } catch (MissingResourceException e) {
        return "message '" + messageId + "' could not be localized (" + e.getMessage() + ")";
    }
}

From source file:com.rest.restservice.processors.AutoProcessor.java

@Override
public void process(Exchange exchange) throws Exception {
    LOG.info(MessageFormat.format(HTTPConstants.AUTO_START_JOB, exchange.getFromRouteId()));
    Method method = AutoProcessor.class.getMethod(exchange.getFromRouteId());
    method.invoke(this);
}

From source file:edu.usu.sdl.openstorefront.core.util.TranslateUtil.java

public static <T extends LookupEntity> String translate(Class<T> lookupClass, String code) {
    String translated = code;// ww  w  .j a va2 s  .  c  o m
    if (StringUtils.isNotBlank(code)) {
        Service serviceProxy = ServiceProxyFactory.getServiceProxy();
        LookupEntity lookupEntity = serviceProxy.getLookupService().getLookupEnity(lookupClass, code);
        if (lookupEntity != null) {
            translated = lookupEntity.getDescription();
        } else {
            log.log(Level.WARNING, MessageFormat.format("Unable to find: {0} in lookup: {1}",
                    new Object[] { code, lookupClass.getName() }));
        }
    }
    return translated;
}

From source file:com.microsoft.tfs.core.clients.framework.configuration.internal.ReportingFolderEntityUtils.java

public static String getFullItemPath(final ReportingFolderEntity folder) {
    Check.notNull(folder, "folder"); //$NON-NLS-1$

    final Stack<String> path = new Stack<String>();

    TFSEntity facet = folder;/*from  w  ww. ja va  2  s .c  o  m*/

    /* Walk the parentage to build the path to this object */
    while (facet != null) {
        if (facet instanceof ReportingFolderEntity) {
            final String itemPath = ((ReportingFolderEntity) facet).getItemPath();

            if (itemPath != null && itemPath.length() > 0) {
                path.push(itemPath);
            }

            facet = ((ReportingFolderEntity) facet).getReferencedResource();
        } else if (facet instanceof ReportingServerEntity) {
            /* Stop */
            break;
        } else {
            log.warn(MessageFormat.format("Invalid type {0} along reporting folder dependency chain", //$NON-NLS-1$
                    facet.getClass().getCanonicalName()));
            break;
        }
    }

    // Construct the full item path.
    String fullItemPath = ""; //$NON-NLS-1$

    while (path.size() > 0) {
        String pathSegment = path.pop();

        pathSegment = pathSegment.trim();

        while (pathSegment.startsWith("/") || pathSegment.startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$
        {
            pathSegment = pathSegment.substring(1);
        }

        fullItemPath = URIUtils.combinePaths(fullItemPath, pathSegment);
    }

    // Full item paths always start with a '/'
    if (fullItemPath.startsWith("/")) //$NON-NLS-1$
    {
        return fullItemPath;
    }

    return "/" + fullItemPath; //$NON-NLS-1$

}

From source file:gov.nih.nci.caarray.web.helper.EmailHelper.java

/**
 * @param registrationRequest request/*from   w ww  . j a  v  a2 s . com*/
 * @throws MessagingException on other error
 */
public static void registerEmail(RegistrationRequest registrationRequest) throws MessagingException {
    DataConfiguration config = ConfigurationHelper.getConfiguration();

    if (!config.getBoolean(ConfigParamEnum.SEND_CONFIRM_EMAIL.name())) {
        return;
    }

    String subject = config.getString(ConfigParamEnum.CONFIRM_EMAIL_SUBJECT.name());
    String from = config.getString(ConfigParamEnum.EMAIL_FROM.name());
    String mailBodyPattern = config.getString(ConfigParamEnum.CONFIRM_EMAIL_CONTENT.name());
    String mailBody = MessageFormat.format(mailBodyPattern, registrationRequest.getId());

    EmailUtil.sendMail(Collections.singletonList(registrationRequest.getEmail()), from, subject, mailBody);
}

From source file:com.microsoft.tfs.client.eclipse.filemodification.TFSFileModificationStatusReporter.java

public void reportError(final String title, final IStatus status) {
    log.error(MessageFormat.format("Could not pend edit: {0}", status.getMessage())); //$NON-NLS-1$
}

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

/**
 *  {res}.properties  key ??//ww w  .  j  av  a 2 s.  co  m
 * 
 * @param baseName
 * @param key
 * @param args
 * @return
 */
public static String getString(String baseName, String key, Object... args) {
    String text = getString(baseName, key);
    return (text != null) ? MessageFormat.format(text, args) : null;
}

From source file:com.microsoft.tfs.client.common.ui.teamexplorer.internal.TeamExplorerConfigHelpers.java

public static Object createInstance(final IConfigurationElement element, final String id) {
    try {/*from   ww w.ja  v  a2 s  . c  o  m*/
        return element.createExecutableExtension(TeamExplorerBaseConfig.CLASS_ATTR_NAME);
    } catch (final CoreException e) {
        log.error(MessageFormat.format("Error creating TE class {0}", id), e); //$NON-NLS-1$
        return null;
    }
}