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 PatternWithReplacementConfigurationReturns theConfigureableFieldholding the parsed configuration for every configured key.protected BiConsumer<PatternWithReplacementConfiguration, Object> getProcessConsumer(Document doc, boolean visible) Returns aBiConsumerwhose input is the configuredConfigureableFieldwith the value of the currently processed record.Methods inherited from class de.cxp.ocs.preprocessor.ConfigureableDataprocessor
initialize, isRecordVisible, processMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ConfigureableDataprocessorReturns theConfigureableFieldholding the parsed configuration for every configured key.- Specified by:
getPatternConfigurationin 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:ConfigureableDataprocessorReturns aBiConsumerwhose input is the configuredConfigureableFieldwith the value of the currently processed record. The consumer gets called in theDocumentPreProcessor.process(Document, boolean)method for each configured key.- Specified by:
getProcessConsumerin classConfigureableDataprocessor<PatternWithReplacementConfiguration>- Parameters:
doc- the record datavisible- the current visibility of the record- Returns:
- a
BiConsumerwhose accept method should handle everyPatternConfigurationwith the corresponding value.
-