Java Code Examples for org.apache.commons.lang3.StringUtils.replaceAll()

The following are Jave code examples for showing how to use replaceAll() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: para-search-elasticsearch   File: ElasticSearchUtils.java   View Source Code Vote up 7 votes
/**
 * @param operator operator <,>,<=,>=
 * @param field field name
 * @param stringValue field value
 * @return a range query
 */
static QueryBuilder range(String operator, String field, String stringValue) {
	String key = StringUtils.replaceAll(field, "[<>=\\s]+$", "");
	boolean nestedMode = nestedMode() && field.startsWith(PROPS_PREFIX);
	RangeQueryBuilder rfb = rangeQuery(nestedMode ? getValueFieldName(stringValue) : key);
	if (">".equals(operator)) {
		rfb.gt(getNumericValue(stringValue));
	} else if ("<".equals(operator)) {
		rfb.lt(getNumericValue(stringValue));
	} else if (">=".equals(operator)) {
		rfb.gte(getNumericValue(stringValue));
	} else if ("<=".equals(operator)) {
		rfb.lte(getNumericValue(stringValue));
	}
	if (nestedMode) {
		return nestedPropsQuery(keyValueBoolQuery(key, stringValue, rfb));
	} else {
		return rfb;
	}
}
 
Example 2
Project: xm-commons   File: SpelToJpqlTranslator.java   View Source Code Vote up 5 votes
@Override
public String translate(String spel, Subject subject) {
    if (StringUtils.isNotBlank(spel)) {

        String jpql = StringUtils.replaceAll(spel, "#returnObject", "returnObject");
        jpql = replaceOperators(jpql);
        jpql = SpelTranslator.applySubject(jpql, subject);

        log.debug("SpEL was translated to JPQL for permission filtering: [{}] --> [{}]", spel, jpql);
        return jpql;
    }
    return spel;
}
 
Example 3
Project: spring-boot-start-current   File: RequestLoggingFilter.java   View Source Code Vote up 5 votes
@Override
public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    final BodyReaderWrapper wrapper = new BodyReaderWrapper((HttpServletRequest ) request);
    String requestMessage = RequestUtils.getRequestMessage(wrapper);
    if (!LogUtils.getLogger().isDebugEnabled()) {
        requestMessage = StringUtils.replaceAll( requestMessage, PASSWORD_FILTER_REGEX,
                                                 "enable password protection, if not debug so do not see");
    }
    LogUtils.getLogger().info(requestMessage);
    chain.doFilter(wrapper, response);
}
 
Example 4
Project: spring-boot-start-current   File: DefaultInjectionAttackHandler.java   View Source Code Vote up 5 votes
@Override
public String filterSqlInjection ( String rawCharacters ) {
    if ( StringUtils.isBlank( rawCharacters ) ) {
        return rawCharacters;
    }
    return StringUtils.replaceAll( rawCharacters , SQL_INJECTION_REGEX , StringUtils.EMPTY );
}
 
Example 5
Project: spring-boot-start-current   File: DefaultInjectionAttackHandler.java   View Source Code Vote up 5 votes
@Override
public String filterXSSInjection ( String rawCharacters ) {
    if ( StringUtils.isBlank( rawCharacters ) ) {
        return rawCharacters;
    }
    return StringUtils.replaceAll( rawCharacters , XSS_REGEX , StringUtils.EMPTY );
}
 
Example 6
Project: spring-boot-start-current   File: DefaultInjectionAttackHandler.java   View Source Code Vote up 5 votes
@Override
public String filterSpecialCharacters ( String rawCharacters ) {
    if ( StringUtils.isBlank( rawCharacters ) ) {
        return rawCharacters;
    }
    return StringUtils.replaceAll( rawCharacters , SPECIAL_CHARACTERS_REGEX , StringUtils.EMPTY );
}
 
Example 7
Project: smockin   File: GeneralUtils.java   View Source Code Vote up 4 votes
public static String removeAllLineBreaks(final String original) {
    return StringUtils.replaceAll(original, System.getProperty("line.separator"), "");
}
 
Example 8
Project: cyberduck   File: DAVRedirectStrategy.java   View Source Code Vote up 4 votes
@Override
protected URI createLocationURI(final String location) throws ProtocolException {
    return super.createLocationURI(StringUtils.replaceAll(location, " ", "%20"));
}
 
Example 9
Project: vscrawler   File: ReplaceAll.java   View Source Code Vote up 4 votes
@Override
protected String handle(String input, String second, String third) {
    return StringUtils.replaceAll(input, second, third);
}
 
Example 10
Project: xm-commons   File: SpelTranslator.java   View Source Code Vote up 3 votes
/**
 * Replace search string to data with quotes.
 *
 * <p>Example:
 *  jpql="big 'value' fat value"
 *  search="value"
 *  replace="frog"
 *
 * <p>result="big 'frog' fat 'frog'"
 *
 * @param jpql the jpql string
 * @param search the search string
 * @param replace the replacement string
 * @return jpql with data string
 */
static String replaceWithQuotes(String jpql, String search, String replace) {
    if (StringUtils.isNotBlank(replace)) {
        return StringUtils.replaceAll(
            StringUtils.replaceAll(jpql, "'" + search + "'", "'" + replace + "'"),
            search, "'" + replace + "'");
    }
    return jpql;
}
 
Example 11
Project: kbase-doc   File: HtmlUtils.java   View Source Code Vote up 2 votes
/**
 * 将 data 中的编码修改为 utf-8
 * @author eko.zhan at 2017年8月11日 上午9:54:34
 * @param data
 * @return
 */
public static String replaceCharset(String data){
	return StringUtils.replaceAll(data, "(?i)CONTENT=\"text/html; charset=gb2312\"", "CONTENT=\"text/html; charset=utf-8\"");
}