Example usage for org.apache.commons.lang StringUtils abbreviate

List of usage examples for org.apache.commons.lang StringUtils abbreviate

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils abbreviate.

Prototype

public static String abbreviate(String str, int maxWidth) 

Source Link

Document

Abbreviates a String using ellipses.

Usage

From source file:com.fortify.bugtracker.tgt.octane.processor.OctaneTargetProcessorSubmitIssues.java

@Override
protected TargetIssueLocator submitIssue(Context context, LinkedHashMap<String, Object> issueData) {
    OctaneAuthenticatingRestConnection conn = OctaneConnectionFactory.getConnection(context);
    issueData.put("name", StringUtils.abbreviate((String) issueData.get("name"), 254));
    return conn.submitIssue(
            new OctaneSharedSpaceAndWorkspaceId(ICLIOptionsOctane.CLI_OCTANE_SHARED_SPACE_UID.getValue(context),
                    ICLIOptionsOctane.CLI_OCTANE_WORKSPACE_ID.getValue(context)),
            issueData);//from   w w  w . j a v  a 2s .  co m
}

From source file:de.tudarmstadt.lt.n2n.preparsed.annotators.GoogleSyntacticNgramsAnnotator.java

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
    try {/*from www . ja  v a 2  s  . com*/
        // assert line.trim().split("\n", 2).length < 2 : "Too many lines, expected only one!";
        parseCasLines(aJCas);
    } catch (Exception e) {
        LOG.warn("Could not process cas {}, text: '{}' ({}: {})", DocumentMetaData.get(aJCas).getDocumentId(),
                StringUtils.abbreviate(aJCas.getDocumentText(), 50), e.getClass().getSimpleName(),
                e.getMessage());
        if (_fail_early)
            throw new AnalysisEngineProcessException(e);
    }
}

From source file:de.fu_berlin.inf.dpp.activities.TextEditActivity.java

@Override
public String toString() {
    String newText = StringEscapeUtils.escapeJava(StringUtils.abbreviate(text, 150));
    String oldText = StringEscapeUtils.escapeJava(StringUtils.abbreviate(replacedText, 150));
    return "TextEditActivity(offset: " + offset + ", new: '" + newText + "', old: '" + oldText + "', path: "
            + getPath() + ", src: " + getSource() + ")";
}

From source file:de.iteratec.iteraplan.presentation.flow.FlowEntry.java

public String getTruncatedLabel() {
    if (label == null) {
        return null;
    }// w  w w  . ja v  a  2  s  .  com
    return StringUtils.abbreviate(label, Constants.LENGTH_LABEL_TRUNCATED_BUILDINGBLOCK);
}

From source file:aos.lucene.search.advanced.SortingExample.java

public void displayResults(Query query, Sort sort) //
        throws IOException {
    IndexSearcher searcher = new IndexSearcher(directory);

    searcher.setDefaultFieldSortScoring(true, false); //

    TopDocs results = searcher.search(query, null, //
            20, sort); //

    LOGGER.info("\nResults for: " + //
            query.toString() + " sorted by " + sort);

    LOGGER.info(StringUtils.rightPad("Title", 30) + StringUtils.rightPad("pubmonth", 10)
            + StringUtils.center("id", 4) + StringUtils.center("score", 15));

    PrintStream out = new PrintStream(System.out, true, "UTF-8"); //

    DecimalFormat scoreFormatter = new DecimalFormat("0.######");
    for (ScoreDoc sd : results.scoreDocs) {
        int docID = sd.doc;
        float score = sd.score;
        Document doc = searcher.doc(docID);
        out.println(StringUtils.rightPad( //
                StringUtils.abbreviate(doc.get("title"), 29), 30) + //
                StringUtils.rightPad(doc.get("pubmonth"), 10) + //
                StringUtils.center("" + docID, 4) + //
                StringUtils.leftPad( //
                        scoreFormatter.format(score), 12)); //
        out.println("   " + doc.get("category"));
        //out.println(searcher.explain(query, docID));   //
    }// w  w  w  .j  av a2  s  . c  o m

    searcher.close();
}

From source file:com.fortify.bugtracker.tgt.jira.processor.JiraTargetProcessorSubmitIssues.java

@Override
protected TargetIssueLocator submitIssue(Context context, LinkedHashMap<String, Object> issueFields) {
    JiraRestConnection conn = JiraConnectionFactory.getConnection(context);
    issueFields.put("project.key", ICLIOptionsJira.CLI_JIRA_PROJECT_KEY.getValue(context));
    issueFields.put("issuetype.name", getIssueType());
    issueFields.put("summary", StringUtils.abbreviate((String) issueFields.get("summary"), 254));
    return conn.submitIssue(issueFields);
}

From source file:gov.guilin.plugin.pay99billBank.Pay99billBankPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    Payment payment = getPayment(sn);//from  w  w  w.jav  a  2  s  .  com
    Map<String, Object> parameterMap = new LinkedHashMap<String, Object>();
    parameterMap.put("inputCharset", "1");
    parameterMap.put("pageUrl", getNotifyUrl(sn, NotifyMethod.sync));
    parameterMap.put("bgUrl", getNotifyUrl(sn, NotifyMethod.async));
    parameterMap.put("version", "v2.0");
    parameterMap.put("language", "1");
    parameterMap.put("signType", "1");
    parameterMap.put("merchantAcctId", pluginConfig.getAttribute("partner"));
    parameterMap.put("payerIP", request.getLocalAddr());
    parameterMap.put("orderId", sn);
    parameterMap.put("orderAmount", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("orderTime", new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
    parameterMap.put("orderTimestamp", new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
    parameterMap.put("productName",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 100));
    parameterMap.put("productDesc",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 400));
    parameterMap.put("ext1", "guilin");
    parameterMap.put("payType", "10");
    String bank = request.getParameter(BANK_PARAMETER_NAME);
    parameterMap.put("bankId", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK);
    parameterMap.put("signMsg", generateSign(parameterMap));
    return parameterMap;
}

From source file:com.dianping.swallow.broker.monitor.DefaultNotifyService.java

@Override
public void alarm(String msg, Throwable t, boolean sendSms) {
    log.error(MAIL_ALARM_TITLE + " : " + msg, t);

    if (!devMode) {
        StringBuilder body = new StringBuilder();
        body.append("<strong>").append(msg).append("</strong><br/>");
        body.append("<br/>");
        if (t != null) {
            body.append("<b>").append("Exception message:").append("&nbsp;</b>").append(t.getClass().getName())
                    .append(":").append(t.getMessage()).append("<br/>");
            body.append("<i>").append("Stack trace:").append("&nbsp;<i><br/>");
            body.append(displayErrorForHtml(t));
        }/*from   www .  j  av  a  2s  . c  o m*/
        try {
            this.alarmService.sendEmail(body.toString(), MAIL_ALARM_TITLE + "_" + localIP, getMailTos());
            if (sendSms) {
                List<String> numbers = getPhoneNums();
                if (numbers != null && numbers.size() > 0) {
                    this.alarmService.sendSmsMessage(
                            "[swallow-broker Alarm]" + "_" + localIP + ":" + StringUtils.abbreviate(msg, 1000),
                            numbers);
                }
            }
        } catch (Exception e) {
            log.warn("Alarm failed. BODY: " + body);
        }
    }
}

From source file:mobi.chouette.model.NeptuneLocalizedObject.java

/**
 * set country code <br/>/* ww w. j a  v  a  2  s.c o  m*/
 * truncated to 255 characters if too long
 * 
 * @param value
 *            New value
 */
public void setCountryCode(String value) {
    countryCode = StringUtils.abbreviate(value, 255);
}

From source file:net.shopxx.plugin.pay99billBankPayment.Pay99billBankPaymentPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    PluginConfig pluginConfig = getPluginConfig();
    PaymentLog paymentLog = getPaymentLog(sn);
    Map<String, Object> parameterMap = new LinkedHashMap<String, Object>();
    parameterMap.put("inputCharset", "1");
    parameterMap.put("pageUrl", getNotifyUrl(PaymentPlugin.NotifyMethod.sync));
    parameterMap.put("bgUrl", getNotifyUrl(PaymentPlugin.NotifyMethod.async));
    parameterMap.put("version", "v2.0");
    parameterMap.put("language", "1");
    parameterMap.put("signType", "1");
    parameterMap.put("merchantAcctId", pluginConfig.getAttribute("partner"));
    parameterMap.put("payerIP", request.getLocalAddr());
    parameterMap.put("orderId", sn);
    parameterMap.put("orderAmount",
            paymentLog.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("orderTime", DateFormatUtils.format(new Date(), "yyyyMMddhhmmss"));
    parameterMap.put("orderTimestamp", DateFormatUtils.format(new Date(), "yyyyMMddhhmmss"));
    parameterMap.put("productName",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 100));
    parameterMap.put("productDesc",
            StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 400));
    parameterMap.put("ext1", "shopxx");
    parameterMap.put("payType", "10");
    String bank = request.getParameter(BANK_PARAMETER_NAME);
    parameterMap.put("bankId", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK);
    parameterMap.put("signMsg", generateSign(parameterMap));
    return parameterMap;
}