@Test public void testBuildPatternWithLiteralParsingAndWholeWord() throws Exception { Pattern actualPattern = ReplaceString.buildPattern( true, true, true, LITERAL_STRING, false ); Matcher matcher = actualPattern.matcher( INPUT_STRING ); String actualString = matcher.replaceAll( "are" ); Assert.assertEquals( INPUT_STRING, actualString ); }
@VisibleForTesting static Pattern buildPattern( boolean literalParsing, boolean caseSensitive, boolean wholeWord, String patternString, boolean isUnicode ) { int flags = 0; if ( literalParsing && !wholeWord ) { flags |= Pattern.LITERAL; } if ( !caseSensitive ) { flags |= Pattern.CASE_INSENSITIVE; } if ( isUnicode ) { flags |= Pattern.UNICODE_CHARACTER_CLASS; } if ( wholeWord ) { if ( literalParsing ) { patternString = "\\Q" + patternString + "\\E"; } patternString = "\\b" + patternString + "\\b"; } return Pattern.compile( patternString, flags ); }
ReplaceString extends BaseStep implements StepInterface { @VisibleForTesting static Pattern buildPattern( boolean literalParsing, boolean caseSensitive, boolean wholeWord, String patternString, boolean isUnicode ) { int flags = 0; if ( literalParsing && !wholeWord ) { flags |= Pattern.LITERAL; } if ( !caseSensitive ) { flags |= Pattern.CASE_INSENSITIVE; } if ( isUnicode ) { flags |= Pattern.UNICODE_CHARACTER_CLASS; } if ( wholeWord ) { if ( literalParsing ) { patternString = "\\Q" + patternString + "\\E"; } patternString = "\\b" + patternString + "\\b"; } return Pattern.compile( patternString, flags ); } }
ReplaceString extends BaseStep implements StepInterface { @VisibleForTesting static Pattern buildPattern( boolean literalParsing, boolean caseSensitive, boolean wholeWord, String patternString, boolean isUnicode ) { int flags = 0; if ( literalParsing && !wholeWord ) { flags |= Pattern.LITERAL; } if ( !caseSensitive ) { flags |= Pattern.CASE_INSENSITIVE; } if ( isUnicode ) { flags |= Pattern.UNICODE_CHARACTER_CLASS; } if ( wholeWord ) { if ( literalParsing ) { patternString = "\\Q" + patternString + "\\E"; } patternString = "\\b" + patternString + "\\b"; } return Pattern.compile( patternString, flags ); } ReplaceString( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
ReplaceString extends BaseStep implements StepInterface { @VisibleForTesting static Pattern buildPattern( boolean literalParsing, boolean caseSensitive, boolean wholeWord, String patternString, boolean isUnicode ) { int flags = 0; if ( literalParsing && !wholeWord ) { flags |= Pattern.LITERAL; } if ( !caseSensitive ) { flags |= Pattern.CASE_INSENSITIVE; } if ( isUnicode ) { flags |= Pattern.UNICODE_CHARACTER_CLASS; } if ( wholeWord ) { if ( literalParsing ) { patternString = "\\Q" + patternString + "\\E"; } patternString = "\\b" + patternString + "\\b"; } return Pattern.compile( patternString, flags ); } ReplaceString( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); static String replaceString( String originalString, Pattern pattern, String replaceByString ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
ReplaceString extends BaseStep implements StepInterface { @VisibleForTesting static Pattern buildPattern( boolean literalParsing, boolean caseSensitive, boolean wholeWord, String patternString, boolean isUnicode ) { int flags = 0; if ( literalParsing && !wholeWord ) { flags |= Pattern.LITERAL; } if ( !caseSensitive ) { flags |= Pattern.CASE_INSENSITIVE; } if ( isUnicode ) { flags |= Pattern.UNICODE_CHARACTER_CLASS; } if ( wholeWord ) { if ( literalParsing ) { patternString = "\\Q" + patternString + "\\E"; } patternString = "\\b" + patternString + "\\b"; } return Pattern.compile( patternString, flags ); } ReplaceString( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); static String replaceString( String originalString, Pattern pattern, String replaceByString ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); void dispose( StepMetaInterface smi, StepDataInterface sdi );  }