Example usage for org.apache.commons.lang StringUtils remove

List of usage examples for org.apache.commons.lang StringUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils remove.

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:jetbrick.tools.chm.reader.ApiReader.java

private Set<String> getAllFiles(File rootdir, Set<String> files) {
    for (File resource : rootdir.listFiles()) {
        if (resource.isDirectory()) {
            getAllFiles(resource, files);
        } else {//from  w  w  w .j  a va  2 s. co m
            String filename = resource.getAbsolutePath();
            filename = StringUtils.remove(filename, Config.apiLocation.getAbsolutePath() + "\\");
            filename = filename.replace('\\', '/');
            files.add(filename);
        }
    }
    return files;
}

From source file:edu.cornell.kfs.fp.businessobject.USBankRecordFieldUtils.java

/**
 * Extracts a KualiDecimal from a substring less any ending whitespace for a given beginning and ending position.
 * /*from   w  w w  .j a  va 2s  .  co  m*/
 * @param line Superstring
 * @param begin Beginning index
 * @param end Ending index
 * @param lineCount The current line number
 * @return The KualiDecimal parsed from the trimmed substring
 * @throws ParseException When unable to parse the KualiDecimal
 */
public static KualiDecimal extractDecimal(String line, int begin, int end, int lineCount)
        throws ParseException {
    KualiDecimal theDecimal;
    try {
        String sanitized = line.substring(begin, end);
        sanitized = StringUtils.remove(sanitized, '-');
        sanitized = StringUtils.remove(sanitized, '+');
        theDecimal = new KualiDecimal(sanitized);
    } catch (StringIndexOutOfBoundsException | IllegalArgumentException e) {
        // May encounter a StringIndexOutOfBoundsException if the string bounds do not match or 
        // an IllegalArgumentException if the Decimal does not parse correctly
        throw new ParseException(
                "Unable to parse " + line.substring(begin, end) + " into a decimal value on line " + lineCount,
                lineCount);
    }
    return theDecimal;
}

From source file:com.acc.storefront.interceptors.beforeview.UiThemeResourceBeforeViewHandler.java

@Override
public void beforeView(final HttpServletRequest request, final HttpServletResponse response,
        final ModelAndView modelAndView) {
    final CMSSiteModel currentSite = cmsSiteService.getCurrentSite();

    final String siteName = currentSite.getUid();
    final String themeName = getThemeNameForSite(currentSite);
    final String uiExperienceCode = uiExperienceService.getUiExperienceLevel().getCode();
    final String uiExperienceCodeLower = uiExperienceCode.toLowerCase();
    final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    final String contextPath = StringUtils.remove(request.getContextPath(),
            (urlEncodingAttributes != null) ? urlEncodingAttributes.toString() : "");

    final String siteRootUrl = contextPath + "/_ui/" + uiExperienceCodeLower;
    final String sharedResourcePath = contextPath + "/_ui/" + SHARED;
    final String siteResourcePath = siteRootUrl + "/site-" + siteName;
    final String themeResourcePath = siteRootUrl + "/theme-" + themeName;
    final String commonResourcePath = siteRootUrl + "/" + COMMON;
    final LanguageModel currentLanguage = commerceCommonI18NService.getCurrentLanguage();

    modelAndView.addObject("contextPath", contextPath);
    modelAndView.addObject("sharedResourcePath", sharedResourcePath);
    modelAndView.addObject("siteResourcePath", siteResourcePath);
    modelAndView.addObject("themeResourcePath", themeResourcePath);
    modelAndView.addObject("commonResourcePath", commonResourcePath);
    modelAndView.addObject("siteRootUrl", siteRootUrl);
    modelAndView.addObject("language", (currentLanguage != null ? currentLanguage.getIsocode() : "en"));
    modelAndView.addObject("CSRFToken", CSRFTokenManager.getTokenForSession(request.getSession()));

    modelAndView.addObject("uiExperienceLevel", uiExperienceCode);

    final String detectedUiExperienceCode = uiExperienceService.getDetectedUiExperienceLevel().getCode();
    modelAndView.addObject("detectedUiExperienceCode", detectedUiExperienceCode);

    final UiExperienceLevel overrideUiExperienceLevel = uiExperienceService.getOverrideUiExperienceLevel();
    if (overrideUiExperienceLevel == null) {
        modelAndView.addObject("uiExperienceOverride", Boolean.FALSE);
    } else {//from w  w  w .ja  va  2  s .  com
        modelAndView.addObject("uiExperienceOverride", Boolean.TRUE);
        modelAndView.addObject("overrideUiExperienceCode", overrideUiExperienceLevel.getCode());
    }

    final DeviceData currentDetectedDevice = deviceDetectionFacade.getCurrentDetectedDevice();
    modelAndView.addObject("detectedDevice", currentDetectedDevice);

    final List<String> dependantAddOns = requiredAddOnsNameProvider
            .getAddOns(request.getSession().getServletContext().getServletContextName());

    modelAndView.addObject("addOnCommonCssPaths",
            getAddOnCommonCSSPaths(contextPath, uiExperienceCodeLower, dependantAddOns));
    modelAndView.addObject("addOnThemeCssPaths",
            getAddOnThemeCSSPaths(contextPath, themeName, uiExperienceCodeLower, dependantAddOns));
    modelAndView.addObject("addOnJavaScriptPaths",
            getAddOnJSPaths(contextPath, siteName, uiExperienceCodeLower, dependantAddOns));

}

From source file:com.ctc.storefront.interceptors.beforeview.UiThemeResourceBeforeViewHandler.java

@Override
public void beforeView(final HttpServletRequest request, final HttpServletResponse response,
        final ModelAndView modelAndView) {
    final CMSSiteModel currentSite = cmsSiteService.getCurrentSite();

    final String siteName = currentSite.getUid();
    final String themeName = getThemeNameForSite(currentSite);
    final String uiExperienceCode = uiExperienceService.getUiExperienceLevel().getCode();
    final String uiExperienceCodeLower = uiExperienceViewResolver.getUiExperienceViewPrefix().isEmpty()
            ? uiExperienceCode.toLowerCase()
            : StringUtils.remove(uiExperienceViewResolver.getUiExperienceViewPrefix()
                    .get(uiExperienceService.getUiExperienceLevel()), "/");
    final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    final String contextPath = StringUtils.remove(request.getContextPath(),
            urlEncodingAttributes != null ? urlEncodingAttributes.toString() : "");

    final String siteRootUrl = contextPath + "/_ui/" + uiExperienceCodeLower;
    final String sharedResourcePath = contextPath + "/_ui/" + SHARED;
    final String siteResourcePath = siteRootUrl + "/site-" + siteName;
    final String themeResourcePath = siteRootUrl + "/theme-" + themeName;
    final String commonResourcePath = siteRootUrl + "/" + COMMON;
    final String encodedContextPath = request.getContextPath();
    final LanguageModel currentLanguage = commerceCommonI18NService.getCurrentLanguage();

    modelAndView.addObject("contextPath", contextPath);
    modelAndView.addObject("sharedResourcePath", sharedResourcePath);
    modelAndView.addObject("siteResourcePath", siteResourcePath);
    modelAndView.addObject("themeResourcePath", themeResourcePath);
    modelAndView.addObject("commonResourcePath", commonResourcePath);
    modelAndView.addObject("encodedContextPath", encodedContextPath);
    modelAndView.addObject("siteRootUrl", siteRootUrl);
    modelAndView.addObject("language", currentLanguage != null ? currentLanguage.getIsocode() : "en");
    modelAndView.addObject("CSRFToken", CSRFTokenManager.getTokenForSession(request.getSession()));
    modelAndView.addObject("themeName", themeName);

    modelAndView.addObject("uiExperienceLevel", uiExperienceCode);

    final String detectedUiExperienceCode = uiExperienceService.getDetectedUiExperienceLevel().getCode();
    modelAndView.addObject("detectedUiExperienceCode", detectedUiExperienceCode);

    final UiExperienceLevel overrideUiExperienceLevel = uiExperienceService.getOverrideUiExperienceLevel();
    if (overrideUiExperienceLevel == null) {
        modelAndView.addObject("uiExperienceOverride", Boolean.FALSE);
    } else {//from  ww  w  .  j av a2s .c o  m
        modelAndView.addObject("uiExperienceOverride", Boolean.TRUE);
        modelAndView.addObject("overrideUiExperienceCode", overrideUiExperienceLevel.getCode());
    }

    final DeviceData currentDetectedDevice = deviceDetectionFacade.getCurrentDetectedDevice();
    modelAndView.addObject("detectedDevice", currentDetectedDevice);

    final List<String> dependantAddOns = requiredAddOnsNameProvider
            .getAddOns(request.getSession().getServletContext().getServletContextName());

    modelAndView.addObject("addOnCommonCssPaths",
            getAddOnCommonCSSPaths(contextPath, uiExperienceCodeLower, dependantAddOns));
    modelAndView.addObject("addOnThemeCssPaths",
            getAddOnThemeCSSPaths(contextPath, themeName, uiExperienceCodeLower, dependantAddOns));
    modelAndView.addObject("addOnJavaScriptPaths",
            getAddOnJSPaths(contextPath, siteName, uiExperienceCodeLower, dependantAddOns));

}

From source file:com.razorfish.interceptors.beforeview.UiThemeResourceBeforeViewHandler.java

@Override
public void beforeView(final HttpServletRequest request, final HttpServletResponse response,
        final ModelAndView modelAndView) {
    final CMSSiteModel currentSite = cmsSiteService.getCurrentSite();

    final String siteName = currentSite.getUid();
    final String themeName = getThemeNameForSite(currentSite);
    final String uiExperienceCode = uiExperienceService.getUiExperienceLevel().getCode();
    final String uiExperienceCodeLower = uiExperienceCode.toLowerCase();
    final Object urlEncodingAttributes = request.getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
    final String contextPath = StringUtils.remove(request.getContextPath(),
            (urlEncodingAttributes != null) ? urlEncodingAttributes.toString() : "");

    final String siteRootUrl = contextPath + "/_ui/" + uiExperienceCodeLower;
    final String sharedResourcePath = contextPath + "/_ui/" + SHARED;
    final String siteResourcePath = siteRootUrl + "/site-" + siteName;
    final String themeResourcePath = siteRootUrl + "/theme-" + themeName;
    final String commonResourcePath = siteRootUrl + "/" + COMMON;
    final String encodedContextPath = request.getContextPath();
    final LanguageModel currentLanguage = commerceCommonI18NService.getCurrentLanguage();

    modelAndView.addObject("contextPath", contextPath);
    modelAndView.addObject("sharedResourcePath", sharedResourcePath);
    modelAndView.addObject("siteResourcePath", siteResourcePath);
    modelAndView.addObject("themeResourcePath", themeResourcePath);
    modelAndView.addObject("commonResourcePath", commonResourcePath);
    modelAndView.addObject("encodedContextPath", encodedContextPath);
    modelAndView.addObject("siteRootUrl", siteRootUrl);
    modelAndView.addObject("language", (currentLanguage != null ? currentLanguage.getIsocode() : "en"));
    modelAndView.addObject("CSRFToken", CSRFTokenManager.getTokenForSession(request.getSession()));

    modelAndView.addObject("uiExperienceLevel", uiExperienceCode);

    final String detectedUiExperienceCode = uiExperienceService.getDetectedUiExperienceLevel().getCode();
    modelAndView.addObject("detectedUiExperienceCode", detectedUiExperienceCode);

    final UiExperienceLevel overrideUiExperienceLevel = uiExperienceService.getOverrideUiExperienceLevel();
    if (overrideUiExperienceLevel == null) {
        modelAndView.addObject("uiExperienceOverride", Boolean.FALSE);
    } else {//w  w w.  j ava 2 s . c  o  m
        modelAndView.addObject("uiExperienceOverride", Boolean.TRUE);
        modelAndView.addObject("overrideUiExperienceCode", overrideUiExperienceLevel.getCode());
    }

    final DeviceData currentDetectedDevice = deviceDetectionFacade.getCurrentDetectedDevice();
    modelAndView.addObject("detectedDevice", currentDetectedDevice);

    final List<String> dependantAddOns = requiredAddOnsNameProvider
            .getAddOns(request.getSession().getServletContext().getServletContextName());

    modelAndView.addObject("addOnCommonCssPaths",
            getAddOnCommonCSSPaths(contextPath, uiExperienceCodeLower, dependantAddOns));
    modelAndView.addObject("addOnThemeCssPaths",
            getAddOnThemeCSSPaths(contextPath, themeName, uiExperienceCodeLower, dependantAddOns));
    modelAndView.addObject("addOnJavaScriptPaths",
            getAddOnJSPaths(contextPath, siteName, uiExperienceCodeLower, dependantAddOns));

}

From source file:com.yahoo.semsearch.fastlinking.utils.Normalize.java

License:asdf

/**
 * Extracts the modifiers from a query. Given a query and an entity linked in the query it maps the entity to
 * its "canonical form" (this is, its Wiki id), removing any possible type information from the Wiki id, this is
 * Tennis_(band) would be mapped to Tennis
 * Then it tries to remove the canonical name from the alias to which the entity is linked to in the query, and returns
 * any words left in the query after this process.
 *
 * @param q query to normalize//from  www .  j  av  a2  s  .c  om
 * @param result entity id linked in the query
 * @return modifiers of the query (intent)
 */
public static String getIntentPart(String q, String result) {
    String normalizedId = result.replaceAll("(.*?)(%28)" + "(.*?)" + "(%29.*)", "$1");
    normalizedId = StringUtils.remove(normalizedId, "%3A");
    normalizedId = Normalize.normalize(normalizedId.replaceAll("[^A-Za-z0-9]", " "));
    for (String sw : ID_SW) {
        normalizedId = normalizedId.replaceAll(sw, " ");
        q = q.replaceAll(sw, " ");
    }
    return StringUtils.remove(q, normalizedId);
}

From source file:com.htmlhifive.tools.jslint.engine.option.CheckOptionPropertyWrapper.java

/**
 * ??./*from   w w w .j av a  2  s  . c  o m*/
 * 
 * @param enable ????????.
 * @return ?.
 */
private CheckOption[] getOptions(boolean enable) {

    Set<Object> keySet = optionProp.keySet();
    List<CheckOption> optionList = new ArrayList<CheckOption>();
    for (Object obj : keySet) {
        String key = (String) obj;
        if (StringUtils.startsWith(key, getPrefix())) {
            String optionKey = StringUtils.remove(key, getPrefix());
            CheckOption option = getOption(optionKey, "engine");
            if (!enable) {
                optionList.add(option);
            } else if (option.isEnable()) {
                optionList.add(option);
            }

        }

    }
    return (CheckOption[]) optionList.toArray(new CheckOption[optionList.size()]);
}

From source file:hydrograph.ui.propertywindow.widgets.utility.OutputRecordCountUtility.java

private String getPortCount(String sourceTerminalId) {
    String portCount = null;//ww w .  j  av a  2 s  . c  o  m
    if (StringUtils.startsWithIgnoreCase(sourceTerminalId, Constants.UNUSED_SOCKET_TYPE)) {
        portCount = StringUtils.remove(sourceTerminalId, Constants.UNUSED_SOCKET_TYPE);
    } else if (StringUtils.startsWithIgnoreCase(sourceTerminalId, Constants.OUTPUT_SOCKET_TYPE)) {
        portCount = StringUtils.remove(sourceTerminalId, Constants.OUTPUT_SOCKET_TYPE);
    }
    return portCount;
}

From source file:com.dream.messaging.engine.csv.CSVDataHandler.java

@Override
public Object createMessageData(Object data, Node node) throws DataConvertException {
    String formatedString = this.createStringMessage(data, node);
    if (formatedString == null) {
        return null;
    }/*from ww w  .j  a va  2  s.c om*/
    String clzName = QueryNode.getAttribute(node, ElementAttr.Attr_Class);
    if (clzName == null) {
        return formatedString;
    } else {
        if (clzName.equalsIgnoreCase(ElementClassType.CLASS_DECIMAL)
                || clzName.equalsIgnoreCase(ElementClassType.CLASS_FLOAT)
                || (clzName.equalsIgnoreCase(ElementClassType.CLASS_DOUBLE))) {
            formatedString = StringUtils.remove(formatedString, ".");
        }
    }
    return formatedString;
}

From source file:com.doculibre.constellio.spellchecker.SpellChecker.java

private void addSuggestions(String sentence, String collectionName, ListOrderedMap orderedMap,
        NamedList<Object> namedList, Locale locale) {
    if (sentence.length() > 250) {
        throw new IllegalArgumentException("String is too long, rejected by spell checker");
    }//from w w w.  j  a va  2 s .  c  om

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordCollection collection = collectionServices.get(collectionName);
    if (collection != null && collection.isSpellCheckerActive()) {
        String spellCheckerLanguage;
        if (locale != null) {
            spellCheckerLanguage = locale.getLanguage();
        } else {
            spellCheckerLanguage = collection.getSpellCheckerLanguage();
        }
        DICTIONARIES dictionary;
        if (Locale.ENGLISH.getLanguage().equals(spellCheckerLanguage)) {
            dictionary = DICTIONARIES.en_US;
        } else if ("es".equals(spellCheckerLanguage)) {
            dictionary = DICTIONARIES.es_MX;
        } else {
            dictionary = DICTIONARIES.fr_FR;
        }

        Hunspell.Dictionary hunspellDictionary = this.dictionariesMap.get(dictionary);
        String[] words = sentence.split(" ");
        if (words.length > 0) {
            for (int i = 0; i < words.length; i++) {
                String currentWord = words[i];
                currentWord = StringUtils.remove(currentWord, '(');
                currentWord = StringUtils.remove(currentWord, ')');
                String currentWordWOAccent = AsciiUtils.convertNonAscii(currentWord);
                if (hunspellDictionary.misspelled(currentWord)) {
                    List<String> suggestionsForWord = hunspellDictionary.suggest(currentWord);
                    if (suggestionsForWord.size() > 0) {
                        boolean ignoreSuggestionForWord = false;
                        for (String suggestionForWord : suggestionsForWord) {
                            String sugWOAccent = AsciiUtils.convertNonAscii(suggestionForWord);
                            if (currentWordWOAccent.toLowerCase().equals(sugWOAccent.toLowerCase())) {
                                ignoreSuggestionForWord = true;
                            }
                        }
                        if (orderedMap != null) {
                            orderedMap.put(currentWord, ignoreSuggestionForWord ? null : suggestionsForWord);
                        } else {
                            addNamedList(namedList, currentWord, !ignoreSuggestionForWord,
                                    ignoreSuggestionForWord ? null : suggestionsForWord);
                        }
                    }
                } else {
                    if (orderedMap != null) {
                        orderedMap.put(currentWord, null);
                    } else {
                        addNamedList(namedList, currentWord, false, null);
                    }
                }
            }
        }
    }
}