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:mobi.chouette.model.Company.java

/**
 * set phone number <br/>/* w  w w . j  av  a  2  s.  c  o m*/
 * truncated to 255 characters if too long
 * 
 * @param value
 *            New value
 */
public void setPhone(String value) {
    phone = StringUtils.abbreviate(value, 255);
}

From source file:at.tfr.securefs.data.ProcessFilesData.java

private String abbreviate(Exception e) {
    StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    return StringUtils.abbreviate(sw.toString(), 100);
}

From source file:com.reizes.shiva.utils.CommonUtil.java

/**
 * HTML   ? ? escape //from  w  w w  . jav  a  2  s. co  m
 * @param str -
 * @param length - ? ? ?
 * @return - ? String
 */
public static String getAbbrHTMLString(String str, int length) {
    return StringEscapeUtils.escapeHtml(StringUtils.abbreviate(str, length));
}

From source file:eu.uqasar.model.qmtree.QModel.java

@JsonIgnore
private String getAbbreviatedName(int maxLength) {
    return StringUtils.abbreviate(getName(), maxLength);
}

From source file:net.certiv.authmgr.task.section.model.AnalyzeModel.java

private void analyzeWords(String category, String partition, HashMap<String, WordProbabilityPT> wordsMap) {

    // convert to sorted set
    WordProbPTComparator sorter = new WordProbPTComparator();
    TreeSet<WordProbabilityPT> wordProbs = new TreeSet<WordProbabilityPT>(sorter);
    wordProbs.addAll(wordsMap.values());

    // now accumulate and print statistics
    StringBuffer wordlist = new StringBuffer();
    int k = 0;// w w w  . j  av a 2  s  .  c o  m
    for (Iterator<WordProbabilityPT> it = wordProbs.iterator(); it.hasNext() && k < 20; k++) {
        WordProbabilityPT wp = it.next();
        String word = wp.getWord();
        double prob = wp.getProbability();
        double count = wp.getMatchingCount();

        BigDecimal probBD = new BigDecimal(prob).setScale(8, BigDecimal.ROUND_HALF_UP);
        String countStr = Util.rightAlign("" + count, 6);
        String wordAbbr = StringUtils.abbreviate(word, 13);
        wordlist.append(Util.leftAlign(wordAbbr, 14) + probBD + "/" + countStr + "| ");
    }
    Log.info(this, Util.leftAlign(partition + ":", 14) + Util.rightAlign("" + wordProbs.size(), 5) + " = "
            + wordlist.toString());
}

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

/**
 * set street name <br/>/*from   w ww.  j  a va 2 s.co m*/
 * truncated to 255 characters if too long
 * 
 * @param value
 *            New value
 */
public void setStreetName(String value) {
    streetName = StringUtils.abbreviate(value, 255);
}

From source file:com.sfs.captor.model.DesignConstraint.java

/**
 * @return the description
 */
public String getDescriptionAbbrv() {
    return StringUtils.abbreviate(description, Constants.ABBRV_DESC_LEN);
}

From source file:com.sfs.captor.model.GlossaryTerm.java

/**
 * @return the definition abbreviated/*from  w ww.j  a va 2s. com*/
 */
public String getDefinitionAbbrv() {
    return StringUtils.abbreviate(this.definition, Constants.ABBRV_DESC_LEN);
}

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

/**
 * set fax number <br/>//  www. j a v a2  s  .  com
 * truncated to 255 characters if too long
 * 
 * @param value
 *            New value
 */
public void setFax(String value) {
    fax = StringUtils.abbreviate(value, 255);
}

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

public void parseLine(JCas aJCas, boolean create_sentences, boolean create_tokens, boolean create_dependencies,
        boolean create_collapsed_dependencies, boolean create_constituents, boolean write_penntree,
        int bline_offset, int eline_offset) throws IllegalStateException {

    DocumentMetaData metadata = DocumentMetaData.get(aJCas);
    String cas_id = metadata.getDocumentId();
    String cas_text = aJCas.getDocumentText();
    String line_text = cas_text.substring(bline_offset, eline_offset);
    LOG.trace("[{}] Trying to parse line '{}'.", cas_id, StringUtils.abbreviate(line_text, 50));
    if (line_text.trim().isEmpty()) {
        LOG.warn("[{}] Line is empty.", cas_id);
        return;//www .j  av a  2  s.  c o m
    }

    List<Integer> tab_idxs = new ArrayList<Integer>();
    for (int index = 0; (index = line_text.indexOf('\t', index) + 1) > 0; tab_idxs.add(index + bline_offset))
        ;
    if (tab_idxs.get(tab_idxs.size() - 1) < line_text.length()) // if line doesn't end with a tab character
        tab_idxs.add(line_text.length() + 1);

    LOG.debug("[{}] Found {} tab characters -> {} columns [{}]", cas_id, tab_idxs.size(), tab_idxs.size() + 1,
            StringUtils.abbreviate(line_text, 50));

    /*
     * 0 = sentence -- currently ignored
     * 1 = token/pos-tag (separated by ' ')
     * 2 = StanfordDependencies (separated by ;;;;;) -- currently ignored
     * 3 = collapsed dependencies with positions (separated by ';' or ',')
     * 4 = penn tree string
     * 5 = if existent should be empty
     */
    String text = cas_text.substring(bline_offset, tab_idxs.size() >= 1 ? tab_idxs.get(0) - 1 : eline_offset); // currently unused
    LOG.trace("[{}] Sentence text '{}'.", cas_id, text);

    int token_list_begin_offset_in_cas = tab_idxs.size() >= 2 ? tab_idxs.get(0) : bline_offset,
            token_list_end_offset_in_cas = tab_idxs.size() >= 2 ? tab_idxs.get(1) - 1 : bline_offset;
    String token_tag_list = tab_idxs.size() >= 2
            ? cas_text.substring(token_list_begin_offset_in_cas, token_list_end_offset_in_cas)
            : null;
    LOG.trace("[{}] Token+tag-list text '{}'.", cas_id, token_tag_list);

    String dependency_list = tab_idxs.size() >= 3 ? cas_text.substring(tab_idxs.get(1), tab_idxs.get(2) - 1)
            : null; // currently unused
    LOG.trace("[{}] Dependency-list text '{}'.", cas_id, dependency_list);

    String collapsed_dependency_list = tab_idxs.size() >= 4
            ? cas_text.substring(tab_idxs.get(2), tab_idxs.get(3) - 1)
            : null;
    LOG.trace("[{}] Collapsed dependency-list text '{}'.", cas_id, collapsed_dependency_list);

    String penn_tree_string = tab_idxs.size() >= 5
            ? cas_text.substring(tab_idxs.get(3), tab_idxs.get(4) - 1).trim()
            : null; // trim because sometimes there is a trailing tab character
    LOG.trace("[{}] Collapsed penn-tree-string '{}'.", cas_id, penn_tree_string);

    // create token annotations?
    if (create_tokens && StringUtils.isNotBlank(token_tag_list))
        parseTokens(aJCas, token_tag_list, cas_id, token_list_begin_offset_in_cas,
                token_list_end_offset_in_cas);

    // create collapsed dependency annotations?
    if (create_collapsed_dependencies && StringUtils.isNotBlank(collapsed_dependency_list))
        parseCollapsedDependencies(aJCas, collapsed_dependency_list, cas_id);

    // create penntree string annotation?
    if (write_penntree && StringUtils.isNotBlank(penn_tree_string))
        parsePennTree(aJCas, penn_tree_string, token_list_begin_offset_in_cas, token_list_end_offset_in_cas);

    // create sentence annotation?
    if (create_sentences && StringUtils.isNotBlank(token_tag_list))
        new Sentence(aJCas, token_list_begin_offset_in_cas, token_list_end_offset_in_cas).addToIndexes();

    // TODO: create constituents annotations
    // TODO: create stanford dependencies annotations

}