Class RegexReplacingJsonPathMetadataProcessor
java.lang.Object
org.dspace.importer.external.metadatamapping.contributor.AbstractJsonPathMetadataProcessor
org.dspace.importer.external.metadatamapping.contributor.RegexReplacingJsonPathMetadataProcessor
- All Implemented Interfaces:
JsonPathMetadataProcessor
A generic JSON metadata processor that extracts a string value from a JSON node
using a specified JSONPath and applies a regex-based replacement.
This class extends
AbstractJsonPathMetadataProcessor and provides functionality
to replace a matching regex pattern in the extracted text with a given replacement value.- Author:
- Adamo Fapohunda (adamo.fapohunda at 4science.com)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.logging.log4j.LoggerProvides the logger instance for error handling.protected StringgetPath()Returns the JSONPath expression used to locate the value in the JSON structure.protected StringgetStringValue(com.fasterxml.jackson.databind.JsonNode node) Extracts the string value from the given JSON node and applies regex-based replacement.voidSets the JSONPath expression used for extraction.voidsetRegexPattern(String regexPattern) Sets the regex pattern to be replaced in the extracted string.voidsetReplacement(String replacement) Sets the replacement string that will replace occurrences of the regex pattern.Methods inherited from class org.dspace.importer.external.metadatamapping.contributor.AbstractJsonPathMetadataProcessor
processMetadata
-
Constructor Details
-
RegexReplacingJsonPathMetadataProcessor
public RegexReplacingJsonPathMetadataProcessor()
-
-
Method Details
-
getStringValue
Extracts the string value from the given JSON node and applies regex-based replacement.- Specified by:
getStringValuein classAbstractJsonPathMetadataProcessor- Parameters:
node- The JSON node from which to extract the value.- Returns:
- The transformed string after applying the regex replacement.
- Throws:
IllegalArgumentException- if the node is null or does not contain a text value.
-
getLogger
protected org.apache.logging.log4j.Logger getLogger()Provides the logger instance for error handling.- Specified by:
getLoggerin classAbstractJsonPathMetadataProcessor- Returns:
- A
Loggerinstance.
-
getPath
Returns the JSONPath expression used to locate the value in the JSON structure.- Specified by:
getPathin classAbstractJsonPathMetadataProcessor- Returns:
- The JSONPath string.
-
setPath
Sets the JSONPath expression used for extraction.- Parameters:
path- The JSONPath string.
-
setRegexPattern
Sets the regex pattern to be replaced in the extracted string.- Parameters:
regexPattern- The regular expression pattern.
-
setReplacement
Sets the replacement string that will replace occurrences of the regex pattern.- Parameters:
replacement- The replacement string.
-