Package de.cxp.ocs.preprocessor.impl
Class ReplacePatternInValuesDataProcessor
java.lang.Object
de.cxp.ocs.preprocessor.ConfigureableDataprocessor<PatternWithReplacementConfiguration>
de.cxp.ocs.preprocessor.impl.ReplacePatternInValuesDataProcessor
- All Implemented Interfaces:
DocumentPreProcessor
public class ReplacePatternInValuesDataProcessor
extends ConfigureableDataprocessor<PatternWithReplacementConfiguration>
ConfigureableDataprocessor
implementation which replaces all
occurrences of a regular expression within a fields value. Will be auto
configured and can be further
configuration like described below:
data-processor-configuration: processors: - ReplacePatternInValuesDataProcessor configuration: ReplacePatternInValuesDataProcessor: someFieldName: ".*\\d+.*" someFieldName_replacement: "foo" someFieldName_destination: "someDestinationField"This would replace all word between a number with 'foo' from the field with the name 'someFieldName'. If no *_replacement is provided, the matched pattern will be replaced by
StringUtils.EMPTY
. Furthermore if a
*_destination is configured, the original value stays untouched and the
replaced value will be written into the configured field.-
Field Summary
Fields inherited from class de.cxp.ocs.preprocessor.ConfigureableDataprocessor
patternConf, properties
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PatternWithReplacementConfiguration
Returns theConfigureableField
holding the parsed configuration for every configured key.protected BiConsumer
<PatternWithReplacementConfiguration, Object> getProcessConsumer
(Document doc, boolean visible) Returns aBiConsumer
whose input is the configuredConfigureableField
with the value of the currently processed record.Methods inherited from class de.cxp.ocs.preprocessor.ConfigureableDataprocessor
initialize, isRecordVisible, process
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.cxp.ocs.spi.indexer.DocumentPreProcessor
finish
-
Constructor Details
-
ReplacePatternInValuesDataProcessor
public ReplacePatternInValuesDataProcessor()
-
-
Method Details
-
getPatternConfiguration
protected PatternWithReplacementConfiguration getPatternConfiguration(String key, String value, Map<String, String> confMap) Description copied from class:ConfigureableDataprocessor
Returns theConfigureableField
holding the parsed configuration for every configured key.- Specified by:
getPatternConfiguration
in classConfigureableDataprocessor<PatternWithReplacementConfiguration>
- Parameters:
key
- a key from the data processor configuration for this data processor.value
- the value of that key.confMap
- the complete data processor configuration map.- Returns:
- the parsed configurable field for the key.
-
getProcessConsumer
protected BiConsumer<PatternWithReplacementConfiguration,Object> getProcessConsumer(Document doc, boolean visible) Description copied from class:ConfigureableDataprocessor
Returns aBiConsumer
whose input is the configuredConfigureableField
with the value of the currently processed record. The consumer gets called in theDocumentPreProcessor.process(Document, boolean)
method for each configured key.- Specified by:
getProcessConsumer
in classConfigureableDataprocessor<PatternWithReplacementConfiguration>
- Parameters:
doc
- the record datavisible
- the current visibility of the record- Returns:
- a
BiConsumer
whose accept method should handle everyPatternConfiguration
with the corresponding value.
-