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.microsoft.gittf.core.util.TagUtil.java

/**
 * Creates a tfs tag for the changeset specified
 * /*w  w w.  ja  v a 2s . c om*/
 * @param repository
 *        the git repository
 * @param commitID
 *        the commit id that the changeset maps to
 * @param changesetID
 *        the changeset id
 * @return
 */
public static boolean createTFSChangesetTag(final Repository repository, ObjectId commitID, int changesetID) {
    GitTFConfiguration configuration = GitTFConfiguration.loadFrom(repository);

    if (!configuration.getTag()) {
        return false;
    }

    String tagName = Messages.formatString("CreateCommitTask.TagNameFormat", //$NON-NLS-1$
            Integer.toString(changesetID));

    PersonIdent tagOwner = new PersonIdent(GitTFConstants.GIT_TF_NAME, MessageFormat.format("{0} - {1}", //$NON-NLS-1$
            configuration.getServerURI().toString(), configuration.getServerPath()));

    return createTag(repository, commitID, tagName, tagOwner);
}

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

@Override
protected URL resolvePath(String scmLocation, String relativePath) throws MalformedURLException {
    StringBuilder sb = new StringBuilder();
    if (!isValidNormalizedPath(relativePath)) {
        throw new IllegalArgumentException("not a valid path: " + relativePath);
    }//from www  . j ava 2 s  .c  o  m

    String repositoryRoot = getRepositoryRoot(scmLocation);
    if (StringUtils.isBlank(repositoryRoot)) {
        throw new IllegalArgumentException(
                MessageFormat.format("{0} is not applicable for scmLocation={1}", getClass(), scmLocation));
    }
    sb.append(repositoryRoot);
    sb.append(";a=blob_plain;f="); //$NON-NLS-1$
    if (StringUtils.isBlank(relativePath) || ".".equals(relativePath)) { //$NON-NLS-1$
        sb.append(DEFAULT_POM_FILENAME);
    } else if (!relativePath.endsWith(DEFAULT_POM_FILENAME)) {
        appendPath(sb, relativePath);
        if (!relativePath.endsWith("/")) { //$NON-NLS-1$
            sb.append("/"); //$NON-NLS-1$
        }
        sb.append(DEFAULT_POM_FILENAME);
    } else {
        appendPath(sb, relativePath);
    }
    sb.append(";hb=HEAD"); //$NON-NLS-1$
    return new URL(sb.toString());
}

From source file:com.ibm.watson.movieapp.dialog.rest.UtilityFunctions.java

/**
 * Parses response to JSON object/*from   www .  j  a  v  a  2s  . co  m*/
 * <p>
 * This extracts a JSON object response from a CloseableHttpResponse.</p>
 * 
 * @param response the CloseableHttpResponse
 * @return the JSON object response
 * @throws IllegalStateException if the response stream cannot be parsed correctly
 * @throws IOException if it is unable to parse the response
 * @throws HttpException if the HTTP call responded with a status code other than 200 or 201
 */
public static JsonObject parseHTTPResponse(CloseableHttpResponse response, String uri)
        throws IllegalStateException, IOException, HttpException {
    int statusCode = response.getStatusLine().getStatusCode();

    // Messages.setInfo(response.getLocale());
    if (statusCode != 200 && statusCode != 201) {
        logger.error(MessageFormat.format(Messages.getString("UtilityFunctions.HTTP_STATUS"), //$NON-NLS-1$
                response.getStatusLine().getStatusCode(), uri));
        throw new HttpException(MessageFormat.format(Messages.getString("UtilityFunctions.HTTP_STATUS"),
                response.getStatusLine().getStatusCode(), uri));
    }
    HttpEntity entity = response.getEntity();
    String strResponse = EntityUtils.toString(entity);
    JsonElement je = new JsonParser().parse(strResponse);
    JsonObject jo = je.getAsJsonObject();
    return jo;
}

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

/**
 * getProcess path (??config?)//from  w  w  w.  ja  v a2 s. c o  m
 */
public static String getProcessRoot(Long channelId, Long pipelineId) {
    // ?channelId , pipelineId path
    return MessageFormat.format(ArbitrateConstants.NODE_PROCESS_ROOT, String.valueOf(channelId),
            String.valueOf(pipelineId));
}

From source file:com.asakusafw.shafu.core.net.ShafuNetwork.java

private static <T> T processHttpContent(URL url, IContentProcessor<T> processor) throws IOException {
    HttpClient client = Activator.getHttpClient();
    HttpGet request = new HttpGet(url.toExternalForm());
    HttpResponse response = client.execute(request);
    try {/*from   w w  w  . j a va2s.c  o  m*/
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            return processor.process(response.getEntity().getContent());
        } else {
            throw new IOException(MessageFormat.format(Messages.ShafuNetwork_failedToOpenHttpContent,
                    request.getURI(), response.getStatusLine()));
        }
    } finally {
        closeQuietly(response);
    }
}

From source file:hadoopInstaller.configurationGeneration.EnvShBuilder.java

public void build() throws IOException {
    try (Writer writer = new PrintWriter(this.file.getContent().getOutputStream())) {
        for (Entry<String, String> entry : this.parameters.entrySet()) {
            writer.write(MessageFormat.format("export {0}={1}\n", entry.getKey(), entry.getValue())); //$NON-NLS-1$
        }//  w w  w.j  ava  2s  .c o  m
        writer.write(this.customConfig);
    }
}

From source file:com.xeiam.xchange.btce.dto.trade.BTCECancelOrderResult.java

@Override
public String toString() {

    return MessageFormat.format("BTCECancelOrderResult[orderId={0}, funds={1}]", orderId, funds);
}

From source file:au.org.ala.delta.intkey.ui.DirectiveAction.java

@Override
public void actionPerformed(ActionEvent e) {
    try {/*from  www .  j av a 2 s . c om*/
        _directive.parseAndProcess(_context, null);
    } catch (IntkeyDirectiveParseException ex) {
        ex.printStackTrace();
        String msg = ex.getMessage();
        JOptionPane.showMessageDialog(UIUtils.getMainFrame(), msg, "Error", JOptionPane.ERROR_MESSAGE);
        Logger.error(msg);
    } catch (Exception ex) {
        ex.printStackTrace();
        String msg = MessageFormat.format(UIUtils.getResourceString("ErrorWhileProcessingCommand.error"),
                StringUtils.join(_directive.getControlWords(), " ").toUpperCase(), ex.getMessage());
        JOptionPane.showMessageDialog(UIUtils.getMainFrame(), msg, "Error", JOptionPane.ERROR_MESSAGE);
        Logger.error(msg);
        Logger.error(ex);
    }
}