List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:com.fluidops.iwb.ui.templates.ServletPageParameters.java
/** * Configures the search box with a default value. * /*www. jav a2 s. c o m*/ * This method is invoked when the user is on the main search page. * * @param pc */ private static void configureSearchInput(SearchPageContext pc, SearchTextInput searchInput) { // configure the search input dependent on the request // Check if the query did not come from the SparqlServlet (in this case, SPARQL is provided as a request parameter) String preSetLanguage = pc.getRequestParameter("queryLanguage"); if (StringUtil.isNullOrEmpty(preSetLanguage) || !preSetLanguage.equalsIgnoreCase("SPARQL")) { // If keyword search, just display in the search input box if (pc.queryLanguage.equals("KEYWORD")) { searchInput.setSearchString(pc.query); } else { // Otherwise (SPARQL, SQL, ...), display together with the prefix // TODO: replace with a proper helper method, if such one exists: // there is no dedicated method in StringUtils. // Currently, System.lineSeparator() does not work on Windows: default separator is "\r\n", // while the query received from a SearchWidget only contains "\n" // So, for now deleting both \r and \n. String sQuery = StringUtils.remove(pc.query, "\r"); sQuery = StringUtils.replace(sQuery, "\n", " "); searchInput.setSearchString(pc.queryLanguage + ": " + sQuery); } } }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.security.impl.WebHttpSessionRequestCache.java
/** * Converts the given url into a relative url * //w w w.j a v a 2 s . co m * @param contextPath * @param url * @return relative url */ protected String calculateRelativeRedirectUrl(final String contextPath, final String url) { if (UrlUtils.isAbsoluteUrl(url)) { String relUrl = url.substring(url.indexOf("://") + 3); String modifiedContextPath = contextPath; final String urlEncodingAttributes = getSessionService() .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES); if (urlEncodingAttributes != null && !url.contains(urlEncodingAttributes) && modifiedContextPath.contains(urlEncodingAttributes)) { modifiedContextPath = StringUtils.remove(modifiedContextPath, urlEncodingAttributes); } if (StringUtils.isEmpty(relUrl)) { relUrl = "/"; } else { relUrl = relUrl.substring(relUrl.indexOf(modifiedContextPath) + modifiedContextPath.length()); } return relUrl; } else { return url; } }
From source file:hydrograph.ui.expression.editor.util.ExpressionEditorUtil.java
public String lastString(String field, String seperator) { String result = Constants.EMPTY_STRING; if (StringUtils.isNotBlank(field)) { String[] strArray = StringUtils.split(field, seperator); result = strArray[strArray.length - 1]; if (StringUtils.endsWith(result, Constants.SEMICOLON)) { result = StringUtils.remove(result, Constants.SEMICOLON); }/*w w w .ja va 2 s .c o m*/ } return result; }
From source file:com.edgenius.core.GlobalSetting.java
/** * Remove suppress from current suppress string, and do nothing if it doesn't exist. * @param supress/*from ww w. j av a 2s . c o m*/ */ public void removeSuppress(String newSuppress) { if (StringUtils.isBlank(suppress) || suppress.toUpperCase().indexOf(newSuppress.toUpperCase()) == -1) return; suppress = StringUtils.remove(suppress.toUpperCase(), newSuppress.toUpperCase()); if (suppress.length() > 0) { if (suppress.startsWith(",")) { //first suppress removed, and has more suppress = suppress.substring(1); } else if (suppress.endsWith(",")) { //last suppress removed, and has more suppress = suppress.substring(0, suppress.length() - 1); } else { //middle suppress removed suppress = suppress.replace(",,", ","); } } }
From source file:com.jnj.b2b.storefront.security.impl.WebHttpSessionRequestCache.java
protected String calculateRelativeRedirectUrl(final String contextPath, final String url) { if (UrlUtils.isAbsoluteUrl(url)) { String relUrl = url.substring(url.indexOf("://") + 3); String modifiedContextPath = contextPath; final String urlEncodingAttributes = getSessionService() .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES); if (urlEncodingAttributes != null && !url.contains(urlEncodingAttributes) && modifiedContextPath.contains(urlEncodingAttributes)) { modifiedContextPath = StringUtils.remove(modifiedContextPath, urlEncodingAttributes); }//from ww w.jav a2 s . c om if (StringUtils.isEmpty(relUrl) || StringUtils.isEmpty(modifiedContextPath)) { relUrl = "/"; } else { relUrl = relUrl.substring(relUrl.indexOf(modifiedContextPath) + modifiedContextPath.length()); } return relUrl; } else { return url; } }
From source file:com.acc.storefront.security.impl.WebHttpSessionRequestCache.java
protected String calculateRelativeRedirectUrl(final String contextPath, final String url) { if (UrlUtils.isAbsoluteUrl(url)) { String relUrl = url.substring(url.indexOf("://") + 3); String modifiedContextPath = contextPath; String urlEncodingAttributes = getSessionService().getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES); if (urlEncodingAttributes != null && !url.contains(urlEncodingAttributes) && modifiedContextPath.contains(urlEncodingAttributes)) { modifiedContextPath = StringUtils.remove(modifiedContextPath, urlEncodingAttributes); }//from w w w . j a v a2 s .c o m if (StringUtils.isEmpty(relUrl)) { relUrl = "/"; } else { relUrl = relUrl.substring(relUrl.indexOf(modifiedContextPath) + modifiedContextPath.length()); } return relUrl; } else { return url; } }
From source file:com.hangum.tadpole.rdb.core.editors.main.function.MainEditorBrowserFunctionService.java
/** * parse last object //from w w w.j av a2 s. co m */ private String parseLastObject(String obj) { String strObject = StringUtils.remove((String) obj, ","); if (StringUtils.contains(strObject, '(')) { strObject = StringUtils.substringBefore(strObject, "("); } if (StringUtils.contains(strObject, ')')) { strObject = StringUtils.substringAfter(strObject, ")"); } return strObject; }
From source file:com.epam.storefront.security.impl.WebHttpSessionRequestCache.java
protected String calculateRelativeRedirectUrl(final String contextPath, final String url) { if (UrlUtils.isAbsoluteUrl(url)) { String relUrl = url.substring(url.indexOf("://") + 3); String modifiedContextPath = contextPath; final String urlEncodingAttributes = getSessionService() .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES); if (urlEncodingAttributes != null && !url.contains(urlEncodingAttributes) && modifiedContextPath.contains(urlEncodingAttributes)) { modifiedContextPath = StringUtils.remove(modifiedContextPath, urlEncodingAttributes); }//from ww w . j a va2 s. co m if (StringUtils.isEmpty(relUrl)) { relUrl = "/"; } else { relUrl = relUrl.substring(relUrl.indexOf(modifiedContextPath) + modifiedContextPath.length()); } return relUrl; } else { return url; } }
From source file:de.hybris.platform.acceleratorstorefrontcommons.controllers.pages.checkout.steps.AbstractCheckoutStepController.java
@ModelAttribute("checkoutSteps") public List<CheckoutSteps> addCheckoutStepsToModel() { final CheckoutGroup checkoutGroup = getCheckoutGroup(); final Map<String, CheckoutStep> progressBarMap = checkoutGroup.getCheckoutProgressBar(); final List<CheckoutSteps> checkoutSteps = new ArrayList<CheckoutSteps>(progressBarMap.size()); for (final Map.Entry<String, CheckoutStep> entry : progressBarMap.entrySet()) { final CheckoutStep checkoutStep = entry.getValue(); if (checkoutStep.isEnabled()) { checkoutSteps.add(new CheckoutSteps(checkoutStep.getProgressBarId(), StringUtils.remove(checkoutStep.currentStep(), REDIRECT_PREFIX), Integer.valueOf(entry.getKey()))); }// ww w . java 2 s. co m } return checkoutSteps; }
From source file:net.mikaboshi.intra_mart.tools.log_stats.parser.LineLogParser.java
/** * 1?????Map??//from w w w . j a va 2 s. c om * ?????????null? * @param line * @return */ protected Map<LogLayoutItemType, Object> parseLine(String line) { this.nLine++; if (line == null) { throw new IllegalArgumentException("line is null"); } Matcher matcher = this.logLayoutPattern.matcher(line); if (!matcher.matches()) { warn("Unparsable line"); this.parameter.getErrorCounter().increment(); return null; } Map<LogLayoutItemType, Object> lineMap = new HashMap<LogLayoutItemType, Object>(); for (int i = 0; i < this.layoutItems.length; i++) { LayoutItem item = this.layoutItems[i]; String value = matcher.group(i + 1); if (value != null) { value = value.trim(); } switch (item.type) { case DATE: try { lineMap.put(item.type, item.dateFormat.parse(value)); } catch (ParseException e) { warn("Invalid date : %s", value); this.parameter.getErrorCounter().increment(); } break; case LEVEL: lineMap.put(item.type, Level.toEnum(value)); break; case MDC_LOG_REPORT_SEQUENCE: try { // V6??????? value = StringUtils.remove(value, ','); lineMap.put(item.type, Integer.parseInt(value)); } catch (NumberFormatException e) { warn("Invalid integer : %s", value); this.parameter.getErrorCounter().increment(); } break; case MDC_REQUEST_PAGE_TIME: case MDC_TRANSITION_TIME_RESPONSE: try { // V6??????? value = StringUtils.remove(value, ','); lineMap.put(item.type, Long.parseLong(value)); } catch (NumberFormatException e) { warn("Invalid long : %s", value); this.parameter.getErrorCounter().increment(); } break; case MDC_REQUEST_ACCEPT_TIME: try { lineMap.put(item.type, this.requestAcceptTimeFormat.parse(value)); } catch (ParseException e) { warn("Invalid request accept time : %s", value); this.parameter.getErrorCounter().increment(); } break; case MDC_TRANSITION_LOG_TYPE_ID: lineMap.put(item.type, TransitionType.toEnum(value)); break; default: lineMap.put(item.type, value); } } return lineMap; }