List of usage examples for org.apache.commons.lang StringUtils replaceEach
public static String replaceEach(String text, String[] searchList, String[] replacementList)
Replaces all occurrences of Strings within another String.
From source file:com.nridge.connector.common.con_com.transform.TContentClean.java
private String cleanControl(String aValue) { String cleanValue;/*from w ww .ja v a 2s . c o m*/ if (StringUtils.isNotEmpty(aValue)) { String[] nlReplace = new String[] { " ", " ", " " }; String[] nlPattern = new String[] { "\r", "\n", "\t" }; String replaceValue = StringUtils.replaceEach(aValue, nlPattern, nlReplace); replaceValue = StringUtils.trim(replaceValue); cleanValue = replaceValue.replaceAll("\\p{Cntrl}", ""); StringBuilder asciiValue = new StringBuilder(cleanValue.length()); int strLength = cleanValue.length(); for (int i = 0; i < strLength; i++) { if (isASCII(cleanValue.charAt(i))) asciiValue.append(cleanValue.charAt(i)); } cleanValue = asciiValue.toString(); } else cleanValue = StringUtils.EMPTY; return cleanValue; }
From source file:com.gigiozzz.sjstats.core.logger.impl.StatsDLoggerExecutor.java
public void doLog(CommonStats stats) { logger.info("[{}] [{}] [{}] [{}]", new Object[] { stats.getHostname(), stats.getServer(), stats.getMetric(), stats.getValue() }); // elimino punti o spazi String cleanHostName = StringUtils.replaceEach(stats.getHostname(), searchList, replaceList); String cleanServer = StringUtils.replaceEach(stats.getServer(), searchList, replaceList); statsd.recordExecutionTime(cleanHostName + "." + cleanServer + "." + stats.getMetric(), stats.getValue()); }
From source file:msi.gama.util.GAML.java
public static String toText(final String s) { if (s == null) { return ""; }// ww w. j a v a2 s . c o m return breakStringToLines(StringUtils.replaceEach(s, HTML_TAGS, REPLACEMENTS), 120, Strings.LN); }
From source file:com.careerly.utils.TextUtils.java
public static String escapeNormalString(String text) { if (StringUtils.isBlank(text)) { return StringUtils.EMPTY; }// w ww . j ava 2s. c o m return StringUtils.replaceEach(text, new String[] { "<", ">", """, "\\\\", """ }, new String[] { "<", ">", "\"", "\\", "\'" }); }
From source file:com.qualinsight.plugins.sonarqube.badges.ws.SVGImageGenerator.java
/** * Generates a SVG image object from a provided Data object. * * @param data Data object holding data required to produce a SVGGraphics2D object * @return generated InputStream to read SVG image from *//*from w w w.j a v a2 s. c o m*/ public InputStream generateFor(final SVGImageData data) { final Map<String, String> replacements = new HashMap<>(); replacements.put("{{fontFamily}}", data.fontFamily()); replacements.put("{{labelText}}", data.labelText()); replacements.put("{{labelBackgroundColor}}", data.labelBackgroundColor().hexColor()); replacements.put("{{labelWidth}}", data.labelWidth()); replacements.put("{{labelHalfWidth}}", data.labelHalfWidth()); replacements.put("{{valueText}}", data.valueText()); replacements.put("{{valueBackgroundColor}}", data.valueBackgroundColor().hexColor()); replacements.put("{{valueWidth}}", data.valueWidth()); replacements.put("{{valueHalfWidth}}", data.valueHalfWidth()); replacements.put("{{totalWidth}}", data.totalWidth()); return IOUtils.toInputStream(StringUtils.replaceEach(data.template().content(), replacements.keySet().toArray(new String[0]), replacements.values().toArray(new String[0]))); }
From source file:de.awtools.grooocle.varray.VarrayTest.java
@BeforeClass public static void setUpClass() throws Exception { String[] tokens = new String[] { "${user}", "${pwd}", "${url}" }; String user = System.getProperty("groovy.oracle.test.user"); String pwd = System.getProperty("groovy.oracle.test.password"); String url = System.getProperty("groovy.oracle.test.url"); String[] replacements = new String[] { user, pwd, url }; DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); String oracleUrl = StringUtils.replaceEach(ORACLE_URL, tokens, replacements); conn = DriverManager.getConnection(oracleUrl, user, pwd); conn.setAutoCommit(false);//from w w w .j a va2s . c om Statement stmt = conn.createStatement(); stmt.execute("CREATE TYPE t_string_varray AS VARRAY(10) OF VARCHAR2(100)"); stmt.execute( "CREATE PROCEDURE call_me(p_strings IN t_string_varray, p_retcode OUT NUMBER) IS BEGIN p_retcode := p_strings.COUNT; END call_me;"); // Doesnt work: // stmt.execute("CREATE OR REPLACE PACKAGE TEST_PACKAGE IS PROCEDURE log(p_stichmon IN NUMBER); END;"); // stmt.execute("CREATE OR REPLACE PACKAGE BODY TEST_PACKAGE IS PROCEDURE log(p_stichmon IN NUMBER) IS BEGIN NULL; END log; END ;"); stmt.execute("ALTER PROCEDURE call_me COMPILE"); }
From source file:ch.csnc.extension.httpclient.PKCS11Configuration.java
private static String escapeBackslashesAndQuotationMarks(String value) { String[] searchValues = new String[] { "\\", "\"" }; String[] replacementValues = new String[] { "\\\\", "\\\"" }; return StringUtils.replaceEach(value, searchValues, replacementValues); }
From source file:ch.algotrader.option.OptionSymbol.java
/** * Generates the symbole for the specified {@link ch.algotrader.entity.security.OptionFamily}. * * Example//ww w .ja v a 2 s . c o m * <table> * <tr><td><b>Pattern</b></td><td><b>Description</b></td><td><b>Example</b></td></tr> * <tr><td>N</td><td>Name</td><td>CrudeOil</td></tr> * <tr><td>CR</td><td>SymbolRoot</td><td>CL</td></tr> * <tr><td>C</td><td>Currency</td><td>USD</td></tr> * <tr><td>CS</td><td>ContractSize</td><td>1000</td></tr> * <tr><td>M</td><td>Month 1-digit</td><td>6</td></tr> * <tr><td>MM</td><td>Month 2-digit</td><td>06</td></tr> * <tr><td>MMM</td><td>Month Short</td><td>JUN</td></tr> * <tr><td>MMMM</td><td>Month Long</td><td>June</td></tr> * <tr><td>YY</td><td>Year 2-digit</td><td>16</td></tr> * <tr><td>YYYY</td><td>Year 4-digit</td><td>2016</td></tr> * <tr><td>W</td><td>Week of Month</td><td>3</td></tr> * <tr><td>T</td><td>Type Short</td><td>C</td></tr> * <tr><td>TT</td><td>Type Long</td><td>CALL</td></tr> * <tr><td>S</td><td>Strike</td><td>500</td></tr> * </table> */ public static String getSymbol(OptionFamily family, LocalDate expiration, OptionType type, BigDecimal strike, String pattern) { String[] placeHolders = new String[] { "N", "SR", "CS", "C", "MMMM", "MMM", "MM", "MR", "YYYY", "YY", "YR", "W", "TT", "T", "S" }; String[] values = new String[] { family.getName(), family.getSymbolRoot(), RoundUtil.getBigDecimal(family.getContractSize(), 0).toString(), family.getCurrency().toString(), DateTimePatterns.MONTH_LONG.format(expiration).toUpperCase(), DateTimePatterns.MONTH_SHORT.format(expiration).toUpperCase(), DateTimePatterns.MONTH_2_DIGIT.format(expiration).toUpperCase(), OptionType.CALL.equals(type) ? monthCallEnc[expiration.getMonth().getValue() - 1] : monthPutEnc[expiration.getMonthValue() - 1], DateTimePatterns.YEAR_4_DIGIT.format(expiration), DateTimePatterns.YEAR_2_DIGIT.format(expiration), yearEnc[expiration.getYear() % 10], DateTimePatterns.WEEK_OF_MONTH.format(expiration), type.toString(), type.toString().substring(0, 1), strike.toString() }; return StringUtils.replaceEach(pattern, placeHolders, values); }
From source file:com.careerly.utils.TextUtils.java
/** * ???// w ww . j a v a 2 s. c o m * * @param text * @return */ public static String reductionNotNormalString(String text) { if (StringUtils.isBlank(text)) { return StringUtils.EMPTY; } return StringUtils.replaceEach(text, new String[] { "&", "<", ">", """, "\\\\", """, "[", "]" }, new String[] { "&", "<", ">", "\"", "\\", "\'", "<", ">" }); }
From source file:com.cloudbees.jenkins.support.filter.InetAddressContentFilter.java
@Override public @Nonnull String filter(@Nonnull String input) { ContentMappings mappings = ContentMappings.get(); Matcher m = IP_ADDRESS.matcher(input); List<String> searchList = new ArrayList<>(); List<String> replacementList = new ArrayList<>(); while (m.find()) { String ip = m.group();/*from w ww .j a v a 2s .c o m*/ if (!mappings.getStopWords().contains(ip)) { ContentMapping map = mappings.getMappingOrCreate(ip, InetAddressContentFilter::newMapping); searchList.add(ip); replacementList.add(map.getReplacement()); } } String filtered = input; if (!searchList.isEmpty()) { filtered = StringUtils.replaceEach(input, searchList.toArray(new String[0]), replacementList.toArray(new String[0])); } return filtered; }