List of usage examples for org.apache.commons.lang3 StringUtils replaceEach
public static String replaceEach(final String text, final String[] searchList, final String[] replacementList)
Replaces all occurrences of Strings within another String.
From source file:de.vandermeer.translation.helements.Text2AsciiDoc.java
@Override public String tmp2target(String input) { return StringUtils.replaceEach(input, this.replacementListHE, this.adListHE); }
From source file:de.vandermeer.translation.helements.Text2Latex.java
@Override public String tmp2target(String input) { return StringUtils.replaceEach(input, this.replacementListHE, this.latexListHE); }
From source file:de.vandermeer.translation.helements.Text2AsciiDoc.java
@Override public String translateHtmlElements(String input) { return StringUtils.replaceEach(input, this.searchListHE, this.adListHE); }
From source file:de.tor.tribes.util.bb.KillStatsFormatter.java
@Override public String formatElements(List<Stats> pElements, boolean pShowAll) { StringBuilder b = new StringBuilder(); int cnt = 1;//w w w. jav a 2 s . co m NumberFormat f = getNumberFormatter(pElements.size()); String beforeList = getHeader(); String listItemTemplate = getLineTemplate(); String afterList = getFooter(); String replacedStart = StringUtils.replaceEach(beforeList, new String[] { ELEMENT_COUNT }, new String[] { f.format(pElements.size()) }); b.append(replacedStart); Collections.sort(pElements, Stats.BASH_OFF_COMPARATOR); int idx = 0; for (Stats s : pElements) { String[] replacements = getStatSpecificReplacements(s); String itemLine = StringUtils.replaceEach(listItemTemplate, STAT_SPECIFIC_VARIABLES, replacements); itemLine = StringUtils.replaceEach(itemLine, new String[] { ELEMENT_ID, ELEMENT_COUNT }, new String[] { f.format(cnt), f.format(pElements.size()) }); b.append(itemLine).append("\n"); idx++; if (idx == 10 && !pShowAll) { //show only top10 break; } cnt++; } String replacedEnd = StringUtils.replaceEach(afterList, new String[] { ELEMENT_COUNT }, new String[] { f.format(pElements.size()) }); b.append(replacedEnd); return b.toString(); }
From source file:de.tor.tribes.util.bb.DefStatsFormatter.java
@Override public String formatElements(List<Stats> pElements, boolean pShowAll) { StringBuilder b = new StringBuilder(); int cnt = 1;// w w w . j a v a 2 s . c o m NumberFormat f = getNumberFormatter(pElements.size()); String beforeList = getHeader(); String listItemTemplate = getLineTemplate(); String afterList = getFooter(); String replacedStart = StringUtils.replaceEach(beforeList, new String[] { ELEMENT_COUNT }, new String[] { f.format(pElements.size()) }); b.append(replacedStart); Collections.sort(pElements, Stats.BASH_DEF_COMPARATOR); int idx = 0; for (Stats s : pElements) { String[] replacements = getStatSpecificReplacements(s); String itemLine = StringUtils.replaceEach(listItemTemplate, STAT_SPECIFIC_VARIABLES, replacements); itemLine = StringUtils.replaceEach(itemLine, new String[] { ELEMENT_ID, ELEMENT_COUNT }, new String[] { f.format(cnt), f.format(pElements.size()) }); b.append(itemLine).append("\n"); cnt++; idx++; if (idx == 10 && !pShowAll) { //show only top10 break; } } String replacedEnd = StringUtils.replaceEach(afterList, new String[] { ELEMENT_COUNT }, new String[] { f.format(pElements.size()) }); b.append(replacedEnd); return b.toString(); }
From source file:de.vandermeer.translation.helements.Text2Latex.java
@Override public String translateHtmlElements(String input) { return StringUtils.replaceEach(input, this.searchListHE, this.latexListHE); }
From source file:com.adguard.commons.lang.Wildcard.java
/** * Escapes regexp special characters: \, *, +, ?, |, {, [, (,), ^, $,., #, and white space * * @param pattern Pattern to escape//from www . j av a 2 s . co m * @return Escaped pattern */ private static String escapeRegexp(String pattern) { String[] specialCharacters = new String[] { "\\", "*", "+", "?", "|", "{", "[", "(", ")", "^", "$", ".", "#" }; String[] escapedCharacters = new String[] { "\\\\", "\\*", "\\+", "\\?", "\\|", "\\{", "\\[", "\\(", "\\)", "\\^", "\\$", "\\.", "\\#" }; return StringUtils.replaceEach(pattern, specialCharacters, escapedCharacters); }
From source file:com.cognifide.aet.job.common.comparators.w3chtml5.parser.W3cHtml5IssueDeserializer.java
@Override public W3cHtml5Issue deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext jsonDeserializationContext) { JsonObject jo = json.getAsJsonObject(); String type = getAsString(jo, TYPE); String subtype = getAsString(jo, SUBTYPE); String message = getAsString(jo, MESSAGE); String extract = getAsString(jo, EXTRACT); int lastLine = getAsInt(jo, LAST_LINE); int lastColumn = getAsInt(jo, LAST_COLUMN); int hiliteStart = getAsInt(jo, HILITE_START); int hiliteLength = getAsInt(jo, HILITE_LENGTH); String beforeHilite = StringUtils.substring(extract, 0, hiliteStart); String hilite = StringUtils.substring(extract, hiliteStart, hiliteStart + hiliteLength); String afterHilite = StringUtils.substring(extract, hiliteStart + hiliteLength); // problem with left and right double quotation mark not being displayed correctly message = StringUtils.replaceEach(message, new String[] { "\u00E2\u20AC\u015B", "\u00E2\u20AC" + "\u0165" }, new String[] { "", "" }); // messages often contain HTML entities, escaping them, so they are displayed literally message = StringEscapeUtils.escapeHtml4(message); return new W3cHtml5Issue(lastLine, lastColumn, message, beforeHilite, afterHilite, hilite, null, W3cHtml5IssueType.getType(type, subtype)); }
From source file:de.tor.tribes.util.bb.PointStatsFormatter.java
@Override public String formatElements(List<Stats> pElements, boolean pShowAll) { StringBuilder b = new StringBuilder(); int cnt = 1;//from ww w . j ava 2s . c om NumberFormat f = getNumberFormatter(pElements.size()); String beforeList = getHeader(); String listItemTemplate = getLineTemplate(); String afterList = getFooter(); String replacedStart = StringUtils.replaceEach(beforeList, new String[] { ELEMENT_COUNT }, new String[] { f.format(pElements.size()) }); b.append(replacedStart); Collections.sort(pElements, Stats.POINTS_COMPARATOR); int idx = 0; for (Stats s : pElements) { String[] replacements = getStatSpecificReplacements(s); String itemLine = StringUtils.replaceEach(listItemTemplate, STAT_SPECIFIC_VARIABLES, replacements); itemLine = StringUtils.replaceEach(itemLine, new String[] { ELEMENT_ID, ELEMENT_COUNT }, new String[] { f.format(cnt), f.format(pElements.size()) }); b.append(itemLine).append("\n"); cnt++; idx++; if (idx == 10 && !pShowAll) { //show only top10 break; } } String replacedEnd = StringUtils.replaceEach(afterList, new String[] { ELEMENT_COUNT }, new String[] { f.format(pElements.size()) }); b.append(replacedEnd); return b.toString(); }
From source file:com.hazelcast.examples.Tutorial.java
private final void prepareSourceCode() { String source = "/" + getClass().getName().replaceAll("\\.", "/") + ".java"; try {// ww w . j a v a2s.c o m String code = StringUtils.replaceEach(IOUtils.toString(getClass().getResourceAsStream(source)), new String[] { "&", "<", ">", "\"", "'", "/" }, new String[] { "&", "<", ">", """, "'", "/" }); Label c = new Label("<pre class='prettyprint'>" + code + "</pre>"); c.setContentMode(ContentMode.HTML); c.setSizeUndefined(); addSelectedTabChangeListener(e -> JavaScript.eval("setTimeout(function(){prettyPrint();},300);")); sourceCode.add(c); } catch (IOException e) { e.printStackTrace(); } }