Package org.apache.tika.metadata.filter
Class CaptureGroupMetadataFilter
java.lang.Object
org.apache.tika.metadata.filter.MetadataFilter
org.apache.tika.metadata.filter.MetadataFilterBase
org.apache.tika.metadata.filter.CaptureGroupMetadataFilter
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,Initializable
This filter runs a regex against the first value in the "sourceField".
If the pattern matches, it extracts the first group of the first match and
set's the "targetField"'s value to that first group.
If there is a match, this will overwrite whatever value is in the
"targetField".
If there is not a match, this filter will be a no-op.
If there are multiple matches, this filter will capture only the first.
Open a ticket if you need different behavior.
If the source field has multiple values, this will run the regex
against only the first value.
If the source field does not exist, this filter will be a no-op.
If the target field is the same value as the source field, this filter
will overwrite the value in that field. Again, if there are multiple
values in that field, those will all be overwritten.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration class for JSON deserialization. -
Constructor Summary
ConstructorsConstructorDescriptionCaptureGroupMetadataFilter(JsonConfig jsonConfig) Constructor for JSON configuration.Constructor with explicit Config object. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgetRegex()voidCalled after all properties have been set to allow for validation and initialization that depends on multiple properties.voidvoidsetSourceField(String sourceField) voidsetTargetField(String targetField) Methods inherited from class org.apache.tika.metadata.filter.MetadataFilterBase
doFilterMethods inherited from class org.apache.tika.metadata.filter.MetadataFilter
close, filter, filter
-
Constructor Details
-
CaptureGroupMetadataFilter
public CaptureGroupMetadataFilter() -
CaptureGroupMetadataFilter
public CaptureGroupMetadataFilter(CaptureGroupMetadataFilter.Config config) throws TikaConfigException Constructor with explicit Config object.- Parameters:
config- the configuration- Throws:
TikaConfigException
-
CaptureGroupMetadataFilter
Constructor for JSON configuration. Requires Jackson on the classpath.- Parameters:
jsonConfig- JSON configuration- Throws:
TikaConfigException
-
-
Method Details
-
filter
- Specified by:
filterin classMetadataFilterBase
-
setRegex
-
setSourceField
-
setTargetField
-
getRegex
-
getSourceField
-
getTargetField
-
initialize
Description copied from interface:InitializableCalled after all properties have been set to allow for validation and initialization that depends on multiple properties.- Specified by:
initializein interfaceInitializable- Throws:
TikaConfigException- if there is a problem with the configuration
-