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 final StringBuffer format(Object arguments, StringBuffer result, FieldPosition pos) 

Source Link

Document

Formats an array of objects and appends the MessageFormat's pattern, with format elements replaced by the formatted objects, to the provided StringBuffer.

Usage

From source file:com.asakusafw.thundergate.runtime.cache.mapreduce.Invalidation.java

/**
 * Initializes invalidation timestamp.//from  ww  w. j  av a2  s .co  m
 * @param configuration the target configuration
 * @param tableName the target table name
 */
public static void setupInvalidationTimestamp(Configuration configuration, String tableName) {
    long timestamp = getTimestamp(configuration);
    if (timestamp > 0L && isTarget(configuration, tableName)) {
        LOG.info(MessageFormat.format("enabling ThunderGate cache invalidation: {0} until {1}", tableName,
                configuration.get(KEY_INVALIDATION_TIMESTAMP)));
        configuration.setLong(KEY_INTERNAL_TIMESTAMP, timestamp);
    }
}

From source file:com.microsoft.tfs.client.eclipse.resourcedata.ResourceData.java

/**
 * {@inheritDoc}//from w  w  w.  j  a v  a  2  s  .c  om
 */
@Override
public String toString() {
    return MessageFormat.format("{0} {1}", serverItem, Integer.toString(changesetId)); //$NON-NLS-1$
}

From source file:edu.sjsu.cohort6.esp.common.BaseModel.java

@JsonAnySetter
public void handleUnknown(String key, Object value) {
    log.warning(MessageFormat.format("Unknown property key {0} value {1}", key, value));
}

From source file:com.microsoft.tfs.core.internal.db.ConnectionPool.java

public synchronized DBConnection getConnection() {
    if (shutdown) {
        throw new IllegalStateException(Messages.getString("ConnectionPool.ConnectionPoolHasBeenShutdown")); //$NON-NLS-1$
    }// w  ww  . j  a va 2 s .c  om
    if (pooledConnections.size() > 0) {
        final DBConnection connection = (DBConnection) pooledConnections.remove(0);
        givenConnections.put(connection, MessageFormat.format("gave connection to [{0}] at [{1}]", //$NON-NLS-1$
                Thread.currentThread().getName(), new Date()));
        return connection;
    } else if (givenConnections.size() < POOL_SIZE) {
        final DBConnection connection = connectionConfiguration.createNewConnection();
        givenConnections.put(connection, MessageFormat.format("gave connection to [{0}] at [{1}]", //$NON-NLS-1$
                Thread.currentThread().getName(), new Date()));
        return connection;
    }
    throw new IllegalStateException(
            MessageFormat.format("no connections left in pool ({0})", givenConnections)); //$NON-NLS-1$
}

From source file:com.microsoft.tfs.core.internal.db.Configuration.java

public Configuration(final Class cls, final String resourceName) {
    InputStream input = null;/*from  w  w  w . j  a v  a  2s  .c  o  m*/
    try {
        input = cls.getResourceAsStream(resourceName);
        if (input != null) {
            props.load(input);
        } else {
            log.warn(MessageFormat.format("configuration [{0}] from class [{1}] does not exist", //$NON-NLS-1$
                    resourceName, cls.getName()));
        }
    } catch (final IOException ex) {
        log.warn(
                MessageFormat.format("error loading configuration [{0}] from class [{1}]", resourceName, //$NON-NLS-1$
                        cls.getName()), ex);
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (final IOException e) {
                log.warn(MessageFormat.format("error closing configuration [{0}] from class [{1}]", //$NON-NLS-1$
                        resourceName, cls.getName()), e);
            }
        }
    }
}

From source file:org.eclipse.skalli.model.ext.maven.internal.GitBlitMavenPomResolver.java

@Override
protected URL resolvePath(String scmLocation, String relativePath) throws MalformedURLException {
    if (!isValidNormalizedPath(relativePath)) {
        throw new IllegalArgumentException("not a valid path: " + relativePath);
    }//from   w  ww  .  j a v  a  2 s. c  om

    String repositoryRoot = getRepositoryRoot(scmLocation);
    if (StringUtils.isBlank(repositoryRoot)) {
        throw new IllegalArgumentException(
                MessageFormat.format("{0} is not applicable for scmLocation={1}", getClass(), scmLocation));
    }

    StringBuilder sb = new StringBuilder();
    sb.append(repositoryRoot);
    sb.append("&p="); //$NON-NLS-1$

    String fileName = getPomFileName(relativePath);
    sb.append(fileName).append("&h=HEAD"); //$NON-NLS-1$

    return new URL(sb.toString());
}

From source file:com.alibaba.stonelab.toolkit.autoconf.Autoconf.java

public void validate() {
    for (Propinfo prop : props) {
        boolean flag = usedProps.contains(prop.getProp());
        for (AutoconfTemplate at : templates) {
            flag |= at.contains(prop.getProp());
        }/*  w  w  w .j ava  2 s .co  m*/
        if (!flag) {
            System.out.println(MessageFormat.format(MSG_NOT_USED, prop.getProp(), prop.getDefFile()));
        }
    }
}

From source file:com.asakusafw.runtime.trace.TraceDriverLifecycleManager.java

private static TraceActionFactory extractFactory(ResourceConfiguration configuration) throws IOException {
    String factoryClass = configuration.get(KEY_FACTORY_CLASS, null);
    if (factoryClass == null) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(MessageFormat.format("The configuration key \"{0}\" is not set, we use \"{1}\"", //$NON-NLS-1$
                    KEY_FACTORY_CLASS, DEFAULT_FACTORY_CLASS));
        }//  w  w w  . j  a va 2  s.  c  om
        factoryClass = DEFAULT_FACTORY_CLASS;
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug(MessageFormat.format("Data-flow tracing support: {0}", //$NON-NLS-1$
                    factoryClass));
        }
    }
    try {
        return configuration.getClassLoader().loadClass(factoryClass).asSubclass(TraceActionFactory.class)
                .newInstance();
    } catch (Exception e) {
        throw new IOException(
                MessageFormat.format("Failed to initialize trace action factory: {0}", factoryClass), e);
    }
}

From source file:elaborate.editor.solr.ElaborateEditorQueryComposer.java

@Override
public void compose(ElaborateSearchParameters sp) {
    super.compose(sp);
    String joinedTermQuery = super.getSearchQuery();

    boolean joinedTermQueryIsEmpty = StringUtils.isEmpty(joinedTermQuery);
    ElaborateEditorSearchParameters esp = (ElaborateEditorSearchParameters) sp;
    searchQuery = joinedTermQueryIsEmpty
            ? MessageFormat.format("{0}:{1,number,#}", SolrFields.PROJECT_ID, esp.getProjectId()) //
            : MessageFormat.format("({0}) AND {1}:{2,number,#}", joinedTermQuery, SolrFields.PROJECT_ID,
                    esp.getProjectId());
}

From source file:com.microsoft.tfs.core.exceptions.TFSUnauthorizedException.java

/**
 * Builds more detailed message strings than
 * {@link UnauthorizedException#getMessage()} because it can use the
 * {@link ProfileUtils} class to expand NT and Kerberos credentials.
 *
 * @param e//www  . j a v a2  s  .c  o m
 *        the {@link UnauthorizedException} to generate a message string for
 *        (must not be <code>null</code>)
 * @return a message string describing the authorization failure
 */
private static String buildMessage(final UnauthorizedException e) {
    Check.notNull(e, "e"); //$NON-NLS-1$

    final String displayURIString = getDisplayURIString(e.getURI());

    final Credentials credentials = e.getCredentials();

    if (credentials instanceof DefaultNTCredentials) {
        final String username = UserNameUtil.getCurrentUserName();
        final String domain = UserNameUtil.getCurrentUserDomain();

        if (username != null) {
            return MessageFormat.format(
                    Messages.getString("TFSUnauthorizedException.AccessDeniedAuthenticatingAsFormat"), //$NON-NLS-1$
                    displayURIString, new TFSUser(username, domain).toString());
        } else {
            return MessageFormat.format(
                    Messages.getString(
                            "TFSUnauthorizedException.AccessDeniedAuthenticatingAsCurrentUserFormat"), //$NON-NLS-1$
                    displayURIString);
        }
    } else if (credentials instanceof UsernamePasswordCredentials) {
        final UsernamePasswordCredentials upCrendentials = (UsernamePasswordCredentials) credentials;

        return MessageFormat.format(
                Messages.getString("TFSUnauthorizedException.AccessDeniedAuthenticatingAsFormat"), //$NON-NLS-1$
                displayURIString, upCrendentials.getUsername());
    } else if (credentials instanceof CookieCredentials) {
        return MessageFormat.format(
                //@formatter:off
                Messages.getString(
                        "TFSUnauthorizedException.AccessDeniedAuthenticatingUsingFederatedCredentialsFormat"), //$NON-NLS-1$
                //@formatter:on
                displayURIString);
    } else if (credentials instanceof JwtCredentials) {
        return MessageFormat.format(
                Messages.getString(
                        "TFSUnauthorizedException.AccessDeniedAuthenticatingUsingServiceCredentialsFormat"), //$NON-NLS-1$
                displayURIString);
    }

    if (credentials != null) {
        return MessageFormat.format(
                Messages.getString("TFSUnauthorizedException.AccessDeniedAuthenticatingUsingCredentialsFormat"), //$NON-NLS-1$
                displayURIString, credentials);
    }

    // No credentials available.
    return MessageFormat.format(
            Messages.getString("TFSUnauthorizedException.AccessDeniedAuthenticatingNoCredentialsFormat"), //$NON-NLS-1$
            displayURIString);
}