List of usage examples for org.apache.commons.lang StringUtils abbreviate
public static String abbreviate(String str, int maxWidth)
Abbreviates a String using ellipses.
From source file:StringUtilsTrial.java
public static void main(String[] args) { // String can be max 12 chars including the ... System.out.println("1) Abbreviate Once upon a time >>>" + StringUtils.abbreviate("Once upon a time ", 12)); }
From source file:net.codjo.dataprocess.gui.util.sqleditor.components.ResultTabbedPane.java
public void addResult(EventsBinder eventsBinder, StringBuffer resultString, String sql, WaitingPanel waitingPanel, int pageSize, SQLEditorTools sqlEditorTools) throws EventBinderException { ResultPaneLogic paneLogic = new ResultPaneLogic(eventsBinder, this, waitingPanel, pageSize, sqlEditorTools); ResultPaneGui paneGui = paneLogic.getResultPane(); paneGui.init(sql, resultString, pageSize, paneLogic.getNavigationPanelLogic(), sqlEditorTools); add(StringUtils.abbreviate(sql, 30), paneGui); setSelectedIndex(getTabCount() - 1); }
From source file:com.github.cv.htmlcheck.rules.NoInlineCssStyleElementRule.java
@SuppressWarnings("unchecked") public void addErrorsTo(List<HtmlCheckError> errors) throws Exception { List<Element> styles = XPath.selectNodes(page.getRoot(), "//style"); for (Element style : styles) { errors.add(new HtmlCheckError( String.format("BANNED ELEMENT: inline style element found: %s, containing: %s", Selector.from(style), StringUtils.abbreviate(style.getText(), 60)))); }//from ww w. j a v a2 s . c o m }
From source file:com.github.cv.htmlcheck.rules.NoInlineScriptElementRule.java
@SuppressWarnings("unchecked") public void addErrorsTo(List<HtmlCheckError> errors) throws Exception { List<Element> scripts = XPath.selectNodes(page.getRoot(), "//script[not(@src)]"); for (Element script : scripts) { errors.add(new HtmlCheckError( String.format("BANNED ELEMENT: inline script element found: %s, containing: %s", Selector.from(script), StringUtils.abbreviate(script.getText(), 60)))); }//from w ww. ja v a 2s . co m }
From source file:it.jugpadova.po.EventLink.java
@Transient public String getAbbreviatedUrl() { return StringUtils.abbreviate(url, 40); }
From source file:com.acc.conv.StringValueConverter.java
@Override public String toString(final Object obj) { if (obj == null) { return null; }//from w ww . j a v a2s. com if (obj instanceof String) { String stringValue = (String) obj; if (limit != LIMIT_NO_DEFINED) { stringValue = StringUtils.abbreviate(stringValue, limit); } return stringValue.replaceAll("\\<.*?\\>", ""); } return obj.toString(); }
From source file:com.liveramp.cascading_ext.flow_step_strategy.RenameJobStrategy.java
private static String formatJobName(FlowStep<JobConf> flowStep) { // WordCount [(2/5) input_1, input_2] -> output_1232_ABCDEF123456789... String jobName = String .format("%s [(%d/%d) %s] -> %s", flowStep.getFlowName(), flowStep.getStepNum(), flowStep.getFlow().getFlowSteps().size(), StringUtils.abbreviate(join(getPrettyNamesForTaps(flowStep.getSources(), true)), MAX_SOURCE_PATH_NAMES_LENGTH), join(getPrettyNamesForTaps(flowStep.getSinks(), false))); return StringUtils.abbreviate(jobName, MAX_JOB_NAME_LENGTH); }
From source file:com.github.cv.htmlcheck.rules.HeaderWordLimitRule.java
public void addErrorsTo(List<HtmlCheckError> errors) throws Exception { @SuppressWarnings("unchecked") List<Element> headers = XPath.selectNodes(page.getRoot(), "//" + header); for (Element header : headers) { int foundLength = header.getText().split("\\W+").length; if (foundLength > wordLimit) { errors.add(new HtmlCheckError( String.format("HEADER WORD LIMIT: %s should have at most %d words, but had %d (%s)", Selector.from(header), wordLimit, foundLength, StringUtils.abbreviate(header.getText(), 60)))); }//from www. j a v a2 s . co m } }
From source file:com.pinterest.secor.message.Message.java
protected String fieldsToString() { return "topic='" + mTopic + '\'' + ", kafkaPartition=" + mKafkaPartition + ", offset=" + mOffset + ", payload=" + StringUtils.abbreviate(new String(mPayload), 140); }
From source file:de.tudarmstadt.lt.lm.service.PreTokenizedStringProvider.java
@Override public List<String>[] getNgrams(String text, String language_code) throws Exception { LOG.trace(String.format("Computing ngrams from text: %s", StringUtils.abbreviate(text, 200))); List<String>[] ngrams = null; text = text.trim();/*from ww w. j a va 2 s .com*/ for (LineIterator iter = new LineIterator(new StringReader(text)); iter.hasNext();) { List<String> tokens = tokenizeSentence(iter.nextLine()); LOG.trace(String.format("Current sentence: %s", StringUtils.abbreviate(tokens.toString(), 200))); if (tokens.size() < getLanguageModel().getOrder()) { LOG.trace("Too few tokens."); continue; } List<String>[] current_ngrams = getNgramSequenceFromSentence(tokens); LOG.trace(String.format("Current ngrams: %s", StringUtils.abbreviate(Arrays.toString(current_ngrams), 200))); if (ngrams == null) ngrams = current_ngrams; else ngrams = ArrayUtils.getConcatinatedArray(ngrams, current_ngrams); } LOG.trace(String.format("Ngrams for text: %n\t'%s'%n\t%s ", StringUtils.abbreviate(text, 200), StringUtils.abbreviate(Arrays.toString(ngrams), 200))); return ngrams; }