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.tfs.client.common.ui.vcexplorer.versioncontrol.VersionControlEditorItemBrowser.java

/**
 * {@inheritDoc}//from ww w.  j ava 2 s. c  o m
 */
@Override
public boolean browse(final String serverPath) {
    Check.notNull(serverPath, "serverPath"); //$NON-NLS-1$

    VersionControlEditor editor;

    /* Try to find the version control editor */
    try {
        /**
         * Opening an editor using the {@link VersionControlEditorInput}
         * will guarantee that we will not open multiple source control
         * explorers.
         */
        final IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                .openEditor(new VersionControlEditorInput(), VersionControlEditor.ID);

        if (!(editorPart instanceof VersionControlEditor)) {
            log.warn(MessageFormat.format("Opened editor {0} but received a {1}", VersionControlEditor.ID, //$NON-NLS-1$
                    editorPart));
            return false;
        }

        editor = (VersionControlEditor) editorPart;
    } catch (final PartInitException e) {
        log.warn(MessageFormat.format("Could not open version control editor for item {0}", serverPath), e); //$NON-NLS-1$
        return false;
    }

    editor.setSelectedFolder(new ServerItemPath(serverPath));

    return true;
}

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

/**
 * remedy root path//from  w w  w.ja  v a  2 s. com
 */
public static String getRemedyRoot(Long channelId, Long pipelineId) {
    // ?channelId , pipelineIdpath
    return MessageFormat.format(ArbitrateConstants.NODE_REMEDY_ROOT, String.valueOf(channelId),
            String.valueOf(pipelineId));
}

From source file:com.diversityarrays.kdxplore.vistool.VisToolData.java

static private void appendLines(String fmt, Bag<String> bag, List<String> lines) {
    for (String s : bag.uniqueSet()) {
        lines.add("  " + MessageFormat.format(fmt, s, bag.getCount(s))); //$NON-NLS-1$
    }//from  w w  w  .  j  a v a 2  s  .  c  o  m
}

From source file:com.asakusafw.runtime.report.CommonsLoggingReport.java

@Override
public void report(Level level, String message) {
    if (level == Level.ERROR) {
        if (LOG.isErrorEnabled()) {
            LOG.error(message, new Exception("error"));
        }/*from   w w  w.j av a 2  s.co  m*/
    } else if (level == Level.WARN) {
        if (LOG.isWarnEnabled()) {
            LOG.warn(message, new Exception("warn"));
        }
    } else if (level == Level.INFO) {
        LOG.info(message);
    } else {
        LOG.fatal(MessageFormat.format("Unknown level \"{0}\": {1}", level, message));
    }
}

From source file:pzalejko.iot.client.web.controller.ItemController.java

@MessageMapping(WebSocketConfig.APP_GET_TOPIC)
@SendTo(WebSocketConfig.CONNECTION_PUSH_TOPIC)
public loginResult logIn(LoginInput input) {
    try {//from  ww w .  j a v  a 2  s. co  m
        mqttHandler.connect(input.getName(), mqttHostName);
        return new loginResult(MessageFormat.format(LOG_FORMAT, mqttHostName, input.getName()));
    } catch (Exception e) {
        return new loginResult(e.getMessage());
    }
}

From source file:com.microsoft.tfs.jni.NTLMEngine.java

private NTLMEngine() {
    NTLM i = null;// w w w  .  ja  va 2s.c o  m
    try {
        if (NativeNTLM.isAvailable()) {
            i = new NativeNTLM();
        }
    } catch (final Exception e) {
        log.warn(MessageFormat.format("{0} reported itself available, but failed to load; falling back to {1}", //$NON-NLS-1$
                NativeNTLM.class.getName(), JavaNTLM.class.getName()), e);
    }

    if (i == null) {
        i = new JavaNTLM();
    }

    impl = i;
}

From source file:cherry.foundation.onetimetoken.OneTimeTokenTag.java

private String handleToken(OneTimeToken token) {
    return MessageFormat.format(template, htmlEscaper().escape(token.getName()),
            htmlEscaper().escape(token.getValue()));
}

From source file:net.abhinavsarkar.spelhelper.ReadOnlyGenericPropertyAccessor.java

@Override
public final void write(final EvaluationContext context, final Object target, final String name,
        final Object newValue) throws AccessException {
    throw new AccessException(MessageFormat.format("Cannot write property: {0} of target: {1}", name, target));
}

From source file:org.apache.asterix.experiment.action.derived.RunRESTIOWaitAction.java

@Override
public void doPerform() throws Exception {
    String uri = MessageFormat.format(REST_URI_TEMPLATE, restHost, String.valueOf(restPort));
    HttpGet get = new HttpGet(uri);
    HttpEntity entity = httpClient.execute(get).getEntity();
    EntityUtils.consume(entity);//www  .  j  a  v a2 s . com
}

From source file:com.macrossx.wechat.impl.WechatUserHelper.java

public Optional<WechatUserGet> userGet(String nextOpenid) {
    try {/*from  ww  w. ja va 2 s .  co  m*/
        Optional<WechatAccessToken> token = helper.getAccessToken();
        if (token.isPresent()) {
            WechatAccessToken accessToken = token.get();
            HttpGet httpGet = new HttpGet();

            httpGet.setURI(new URI(MessageFormat.format(WechatConstants.USER_GET_URL,
                    accessToken.getAccess_token(), nextOpenid == null ? "" : nextOpenid)));
            return new WechatHttpClient().send(httpGet, WechatUserGet.class);
        }
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        log.info(e.getMessage());
    }
    return Optional.empty();
}