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.github.aynu.mosir.core.standard.util.MessageHelper.java

/**
 * // ww  w  . ja v a2 s . co m
 * @param message 
 * @param values 
 * @return 
 */
public static String createMessage(final String message, final Object... values) {
    Validate.notBlank(message);
    return MessageFormat.format(message, values);
}

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

public static TFSEntitySession newEntitySession(final TFSTeamProjectCollection connection) {
    Check.notNull(connection, "connection"); //$NON-NLS-1$

    if (connection.getConfigurationServer() != null) {
        log.info(MessageFormat.format("Creating catalog-based configuration entity session for {0}", //$NON-NLS-1$
                connection.getName()));// w w w  .ja  va 2 s.c  om
        return new TFSCatalogEntitySession(connection.getConfigurationServer());
    } else {
        log.info(MessageFormat.format("Creating compatibility configuration entity session for {0}", //$NON-NLS-1$
                connection.getName()));
        return new TFSCompatibilityEntitySession(connection);
    }
}

From source file:Main.java

private static ImageInputStream getResourceAsStream(Class<?> aClass, String name) throws IOException {
    final InputStream is = aClass.getResourceAsStream(name);

    if (is == null) {
        throw new IOException(MessageFormat.format("resource {0} not found", name));
    }// ww w .  j  a  v a  2s .  co m
    return new FileCacheImageInputStream(is, null);
}

From source file:jp.co.opentone.bsol.framework.test.util.ExpectedMessageStringGenerator.java

public static String generate(String msg, String actionName, Object... vars) {

    if (StringUtils.isNotEmpty(actionName)) {
        msg = msg.replace("$action$", "?[" + actionName + "]");
    }// w  w w .j  a  v a2  s. c om

    assertTrue(!msg.matches("\\$action\\$"));

    String result = MessageFormat.format(msg, vars);
    assertTrue(!result.matches("\\{[0-9]+\\}"));

    return result;
}

From source file:com.microsoft.tfs.client.common.ui.webaccessintegration.javascript.JavascriptResourceLoader.java

public static String loadJavascriptFile(final String resourceID, final String charsetName) throws IOException {
    Check.notNull(resourceID, "resourceID"); //$NON-NLS-1$
    Check.notNull(charsetName, "charsetName"); //$NON-NLS-1$

    final InputStream stream = JavascriptResourceLoader.class.getResourceAsStream(resourceID);

    if (stream == null) {
        throw new MissingResourceException(MessageFormat.format("Could not load resource {0}", resourceID), //$NON-NLS-1$
                resourceID, ""); //$NON-NLS-1$
    }//from w  ww  .  j a v a 2  s .c o m

    /*
     * Read the resource as a string and return it.
     */
    try {
        try {
            return IOUtils.toString(stream, charsetName);
        } catch (final IOException e) {
            log.error("Error reading from stream", e); //$NON-NLS-1$
            throw e;
        }
    } finally {
        try {
            stream.close();
        } catch (final IOException e) {
            log.error("Error closing resource stream", e); //$NON-NLS-1$
        }
    }
}

From source file:com.nineteendrops.tracdrops.client.core.MessageUtils.java

public static String getMessage(String key, String... parm) {
    String keyValue = getBundle().getString(key);
    return MessageFormat.format(keyValue, parm);
}

From source file:fr.inria.atlanmod.neoemf.data.hbase.util.HBaseURI.java

public static URI createURI(URI uri) {
    if (Objects.equals(PersistenceURI.FILE_SCHEME, uri.scheme())) {
        return createFileURI(FileUtils.getFile(uri.toFileString()));
    } else if (Objects.equals(SCHEME, uri.scheme())) {
        return PersistenceURI.createURI(uri);
    } else {//  w w  w.  java2  s . com
        throw new IllegalArgumentException(
                MessageFormat.format("Can not create HBaseURI from the URI scheme {0}", uri.scheme()));
    }
}

From source file:fr.inria.atlanmod.neoemf.data.mapdb.util.MapDbURI.java

public static URI createURI(URI uri) {
    URI returnValue;//from  w w  w .  j a  v a  2  s.  co  m
    if (Objects.equals(PersistenceURI.FILE_SCHEME, uri.scheme())) {
        returnValue = createFileURI(FileUtils.getFile(uri.toFileString()));
    } else if (Objects.equals(SCHEME, uri.scheme())) {
        returnValue = PersistenceURI.createURI(uri);
    } else {
        throw new IllegalArgumentException(
                MessageFormat.format("Can not create MapDbURI from the URI scheme {0}", uri.scheme()));
    }
    return returnValue;
}

From source file:fr.inria.atlanmod.neoemf.data.berkeleydb.util.BerkeleyDBURI.java

public static URI createURI(URI uri) {
    URI returnValue;//w  w  w.  j  a v  a2 s .  c  om
    if (Objects.equals(PersistenceURI.FILE_SCHEME, uri.scheme())) {
        returnValue = createFileURI(FileUtils.getFile(uri.toFileString()));
    } else if (Objects.equals(SCHEME, uri.scheme())) {
        returnValue = PersistenceURI.createURI(uri);
    } else {
        throw new IllegalArgumentException(
                MessageFormat.format("Can not create BerkeleyDBURI from the URI scheme {0}", uri.scheme()));
    }
    return returnValue;
}

From source file:fr.inria.atlanmod.neoemf.data.blueprints.util.BlueprintsURI.java

public static URI createURI(URI uri) {
    URI returnValue;// w  w w.ja  v  a  2  s .  co  m
    if (Objects.equals(PersistenceURI.FILE_SCHEME, uri.scheme())) {
        returnValue = createFileURI(FileUtils.getFile(uri.toFileString()));
    } else if (Objects.equals(SCHEME, uri.scheme())) {
        returnValue = PersistenceURI.createURI(uri);
    } else {
        throw new IllegalArgumentException(
                MessageFormat.format("Can not create NeoGraphURI from the URI scheme {0}", uri.scheme()));
    }
    return returnValue;
}