core/src/main/java/nl/nn/adapterframework/util/Misc.java
/**
	 * Hides the input string according to the given regex and mode.
	 * If mode is set to 1, then the first half of the string gets hidden.
	 * Else, all of it.
	 */
Hides the input string according to the given regex and mode.
If mode is set to 1, then the first half of the string gets hidden.
Else, all of it.
Hides the input string according to the given regex and mode . If mode is set to 1 then the first half of the string gets hidden . Else all of it .
public static String hideAll(String inputString, String regex, int mode) {
		StringBuilder result = new StringBuilder();
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(inputString);
		int previous = 0;
		while (matcher.find()) {
			result.append(inputString.substring(previous, matcher.start()));
			int len = matcher.end() - matcher.start();
			if (mode == 1) {
				int lenFirstHalf = (int) Math.ceil((double) len / 2);
				result.append(StringUtils.repeat("*", lenFirstHalf));
				result.append(inputString.substring(matcher.start()
						+ lenFirstHalf, matcher.start() + len));
			} else {
				result.append(StringUtils.repeat("*", len));
			}
			previous = matcher.end();
		}
		result.append(inputString.substring(previous, inputString.length()));
		return result.toString();
	}
public static String hideAll ( String inputString , String regex , int mode ) { StringBuilder result = new StringBuilder ( ) ; Pattern pattern = Pattern . compile ( regex ) ; Matcher matcher = pattern . matcher ( inputString ) ; int previous = 0 ; while ( matcher . find ( ) ) { result . append ( inputString . substring ( previous , matcher . start ( ) ) ) ; int len = matcher . end ( ) - matcher . start ( ) ; if ( mode == 1 ) { int lenFirstHalf = ( int ) Math . ceil ( ( double ) len / 2 ) ; result . append ( StringUtils . repeat ( "*" , lenFirstHalf ) ) ; result . append ( inputString . substring ( matcher . start ( ) + lenFirstHalf , matcher . start ( ) + len ) ) ; } else { result . append ( StringUtils . repeat ( "*" , len ) ) ; } previous = matcher . end ( ) ; } result . append ( inputString . substring ( previous , inputString . length ( ) ) ) ; return result . toString ( ) ; }
Hides the input string according to the given regex and mode.
Hides the input string according to the given regex and mode .