private void mapText ( String oldText , Map < String , String > replacements ) { char c2 = 0 ; if ( oldText != null && oldText . length ( ) != 0 && ! replacements . containsKey ( oldText ) ) { StringBuilder newText = new StringBuilder ( oldText . length ( ) ) ; for ( int loop = 0 ; loop < oldText . length ( ) ; loop ++ ) { char c = oldText . charAt ( loop ) ; if ( Character . isUpperCase ( c ) ) { newText . append ( ' ' ) ; } else { if ( Character . isLowerCase ( c ) ) { newText . append ( ' ' ) ; } else { if ( Character . isDigit ( c ) ) { newText . append ( ' ' ) ; } else { if ( Character . isLetter ( c ) ) { // Handle other codepages etc. If possible find a way to // maintain the same code page as original. // E.g. replace with a character from the same alphabet. // This 'should' work for most cases if ( c2 == 0 ) { c2 = c ; } newText . append ( c2 ) ; } else { newText . append ( c ) ; } } } } } replacements . put ( oldText , newText . toString ( ) ) ; } }
Converts plan text into anonymous text . Preserves upper case lower case punctuation whitespace and digits while making the text unreadable .