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:org.artifactory.rest.common.list.KeyValueList.java
private String replaceBackslashes(String s) { return StringUtils.replaceEach(s, new String[] { "\\,", "\\=", "\\|", "\\" }, new String[] { ",", "=", "|", "\\" }); }
From source file:org.diffkit.util.DKStringUtil.java
@SuppressWarnings("unchecked") public static String replaceEach(String target_, Map<String, String> replacements_) { if (target_ == null) return null; if (MapUtils.isEmpty(replacements_)) return target_; Object[] entries = replacements_.entrySet().toArray(); String[] originals = new String[entries.length]; String[] subs = new String[entries.length]; for (int i = 0; i < entries.length; i++) { originals[i] = ((Map.Entry<String, String>) entries[i]).getKey(); subs[i] = ((Map.Entry<String, String>) entries[i]).getValue(); }/*from w w w . j a v a 2 s .c o m*/ return StringUtils.replaceEach(target_, originals, subs); }
From source file:org.eclipse.skalli.core.destination.DestinationComponent.java
private void setProxy(HttpClient client, URL url) { if (isLocalDomain(url)) { return;//from ww w .j a v a 2 s .c o m } String protocol = url.getProtocol(); // use the system properties as default String defaultProxyHost = System.getProperty(HTTP_PROXY_HOST); String defaultProxyPort = System.getProperty(HTTP_PROXY_PORT); String proxyHost = HTTPS.equals(protocol) ? System.getProperty(HTTPS_PROXY_HOST, defaultProxyHost) : defaultProxyHost; int proxyPort = NumberUtils.toInt( HTTPS.equals(protocol) ? System.getProperty(HTTPS_PROXY_PORT, defaultProxyPort) : defaultProxyPort); String nonProxyHosts = System.getProperty(NON_PROXY_HOSTS, StringUtils.EMPTY); // allow to overwrite the system properties with configuration /api/config/proxy if (configService != null) { ProxyConfig proxyConfig = configService.readConfiguration(ProxyConfig.class); if (proxyConfig != null) { String defaultConfigProxyHost = proxyConfig.getHost(); String defaultConfigProxyPort = proxyConfig.getPort(); String configProxyHost = HTTPS.equals(protocol) ? proxyConfig.getHostSSL() : defaultConfigProxyHost; int configProxyPort = NumberUtils .toInt(HTTPS.equals(protocol) ? proxyConfig.getPortSSL() : defaultConfigProxyPort); if (StringUtils.isNotBlank(configProxyHost) && configProxyPort > 0) { proxyHost = configProxyHost; proxyPort = configProxyPort; } String configNonProxyHosts = proxyConfig.getNonProxyHosts(); if (StringUtils.isNotBlank(configNonProxyHosts)) { nonProxyHosts = configNonProxyHosts; } } } // sanitize the nonProxyHost pattern (remove whitespace etc.) if (StringUtils.isNotBlank(nonProxyHosts)) { nonProxyHosts = StringUtils.replaceEach(StringUtils.deleteWhitespace(nonProxyHosts), RE_SEARCH, RE_REPLACE); } if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0 && !Pattern.matches(nonProxyHosts, url.getHost())) { HttpHost proxy = new HttpHost(proxyHost, proxyPort, HTTP); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } }
From source file:org.fireflow.webdesigner.tag.ProcessDiagramTag.java
protected String buildToolBarJs() { String tmp = new String(toolbar_js_fragment); HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); String contextPath = request.getContextPath(); if (contextPath == null) contextPath = ""; if (contextPath.endsWith("/")) { contextPath = contextPath.substring(0, contextPath.length() - 1); }/*from ww w.jav a 2 s. co m*/ String[] search = new String[] { "DIAGRAM_ID", "CONTEXT_PATH", "PROCESS_ID", "PROCESS_VERSION", "PROCESS_TYPE", "SVG_VML_WRAPPER_ID", "SUB_PROCESS_NAME", "SVG_VML_ID" }; String[] replacement = new String[] { id, contextPath, this.processId, Integer.toString(this.version), FpdlConstants.PROCESS_TYPE_FPDL20, this.svgVmlWrapperDivId, this.subProcessName, this.svgVmlId }; String js = StringUtils.replaceEach(tmp, search, replacement); // System.out.println("=========subProcessName is ==========================="+this.subProcessName); // System.out.println("=========original js is ==========================="); // System.out.println(tmp); // System.out.println("=========new js is ==========================="); // System.out.println(js); return js; }
From source file:org.fireflow.webdesigner.tag.ProcessDiagramTag.java
protected String buildToolBarDiv() { String tmp = new String(toolbar_tag_fragment); HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); String contextPath = request.getContextPath(); if (contextPath == null) contextPath = ""; if (contextPath.endsWith("/")) { contextPath = contextPath.substring(0, contextPath.length() - 1); }// w ww. j ava 2s . c o m String[] search = new String[] { "DIAGRAM_ID", "CONTEXT_PATH", "PROCESS_ID", "PROCESS_VERSION", "PROCESS_TYPE", "SVG_VML_ID" }; String[] replacement = new String[] { id, contextPath, this.processId, Integer.toString(this.version), FpdlConstants.PROCESS_TYPE_FPDL20, this.svgVmlId }; String toolhtml = StringUtils.replaceEach(tmp, search, replacement); //subProcessSelector StringBuffer buf = new StringBuffer(toolhtml); buf.append("\n").append("<select id=\"").append(this.id).append("_subprocess_selector\" ").append( " title=\"??\" class=\"ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only\"") .append(" style=\"width:160px;text-align:left"); if (showSubProcessSelector) { buf.append("\">"); } else { buf.append(";display:none\">\n"); } //?subProcessoption WorkflowProcess process = getWorkflowProcess(); List<SubProcess> subProcessList = process == null ? null : process.getLocalSubProcesses(); StringBuffer optionsBuf = new StringBuffer(); StringBuffer mainSubProcBuf = new StringBuffer(); if (subProcessList != null) { for (SubProcess subProcess : subProcessList) { String displayName = subProcess.getDisplayName(); String name = subProcess.getName(); if (displayName == null || displayName.trim().equals("")) { displayName = name; } if (WorkflowProcess.MAIN_PROCESS_NAME.equals(name)) { mainSubProcBuf.append("<option value=\"").append(name).append("\"").append(">") .append(displayName).append("</option>\n"); } else { optionsBuf.append("<option value=\"").append(name).append("\"").append(">").append(displayName) .append("</option>\n"); } } } buf.append(mainSubProcBuf).append(optionsBuf); buf.append("</select>\n"); buf.append("</div>\n"); // System.out.println("=========original is ==========================="); // System.out.println(tmp); // System.out.println("=========new is ==========================="); // System.out.println(toolhtml); return buf.toString(); }
From source file:org.fireflow.webdesigner.tag.ProcessDiagramTag.java
public static void main(String[] args) { String[] search = new String[] { "DIAGRAM_ID", "CONTEXT_PATH", "PROCESS_ID", "PROCESS_VERSION", "PROCESS_TYPE" }; String[] replacement = new String[] { "processdiagram1", "/demo", "process111", "1", FpdlConstants.PROCESS_TYPE_FPDL20 }; String tmp = " }).click(function(event){" + "//???" + "$ff.get(\"/CONTEXT_PAT-H/FireflowClientWidgetServlet\"," + "{workflowActionType:\"GET_PROCESS_DEFS\"," + "processId:\"PROCESS_ID\"," + "processVersion:\"PROCESS_VERSION\"," + "processType:\"PROCESS_TYPE\"}) DIAGRAM_ID"; String toolhtml = StringUtils.replaceEach(tmp, search, replacement); System.out.println(toolhtml); }
From source file:org.hippoecm.frontend.usagestatistics.UsageStatisticsExternalUrl.java
public static String get() { final SortedMap<String, String> parameters = new TreeMap<>(); parameters.put(RELEASE_VERSION, new SystemInfoDataProvider().getReleaseVersion()); final Calendar now = Calendar.getInstance(); parameters.put(YEAR, String.valueOf(now.get(Calendar.YEAR))); parameters.put(MONTH, String.valueOf(now.get(Calendar.MONTH) + 1)); parameters.put(DAY, String.valueOf(now.get(Calendar.DAY_OF_MONTH))); final String[] search = parameters.keySet().toArray(new String[parameters.size()]); final String[] replacements = parameters.values().toArray(new String[parameters.size()]); return StringUtils.replaceEach(getServer(), search, replacements); }
From source file:org.jahia.modules.irclogs.eggdrop.EggChatlogChannel.java
public List<IRClogLine> getLines(Integer year, Integer month, Integer day) { String[] lines = getLogData(year, month, day).split("\n"); List<IRClogLine> parsedLines = new ArrayList<IRClogLine>(); for (String line : lines) { Matcher matcher = linePattern.matcher(line); if (matcher.find()) { // get a time object String[] timeParsed = matcher.group(1).split(":"); Calendar timeOfLine = Calendar.getInstance(); timeOfLine.set(Calendar.YEAR, year); timeOfLine.set(Calendar.MONTH, month); timeOfLine.set(Calendar.DAY_OF_MONTH, day); timeOfLine.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timeParsed[0])); timeOfLine.set(Calendar.MINUTE, Integer.parseInt(timeParsed[1])); IRClogLine entry;/*from w w w . ja v a2s . c om*/ entry = new IRClogLine(timeOfLine, StringUtils.replaceEach(matcher.group(2), new String[] { "&", "\"", "<", ">", "#" }, new String[] { "&", """, "<", ">", "#" }), defaultLineReplacements(matcher.group(3)), false); parsedLines.add(entry); } } return parsedLines; }
From source file:org.jahia.modules.irclogs.eggdrop.EggChatlogChannel.java
/** * This function replaces links and make the output html 'save' * * TODO: Make this more universal, possibly in a top level class somehow, or as a taglib? * * @param line/*from w ww .j a va2s . c o m*/ * @return */ private String defaultLineReplacements(String line) { final Pattern userPattern = Pattern.compile("Users/\\S+/?\\S*", Pattern.CASE_INSENSITIVE); final Pattern homePattern = Pattern.compile("Home/\\S+/?\\S*", Pattern.CASE_INSENSITIVE); final Pattern emailPattern = Pattern.compile( "([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})", Pattern.CASE_INSENSITIVE); final Pattern urlPattern = Pattern.compile("(\\A|\\s)((http|https|ftp):\\S+)(\\s|\\z)", Pattern.CASE_INSENSITIVE); line = userPattern.matcher(line).replaceAll("Users/<removed>/..."); line = homePattern.matcher(line).replaceAll("Home/<removed>/..."); line = emailPattern.matcher(line).replaceAll("(obscured mail address)"); line = StringUtils.replaceEach(line, new String[] { "&", "\"", "<", ">", "#" }, new String[] { "&", """, "<", ">", "#" }); line = urlPattern.matcher(line).replaceAll("$1<a target=\"_blank\" href=\"$2\">$2</a>$4"); return line; }
From source file:org.jahia.services.render.filter.cache.AclCacheKeyPartGenerator.java
private String encodeSpecificChars(String toEncode) { return StringUtils.replaceEach(toEncode, SPECIFIC_STR, SUBSTITUTION_STR); }