Package org.apache.tika.metadata.filter
Class CaptureGroupMetadataFilter
- java.lang.Object
-
- org.apache.tika.config.ConfigBase
-
- org.apache.tika.metadata.filter.MetadataFilter
-
- org.apache.tika.metadata.filter.CaptureGroupMetadataFilter
-
- All Implemented Interfaces:
Serializable
,Initializable
public class CaptureGroupMetadataFilter extends MetadataFilter implements 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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CaptureGroupMetadataFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkInitialization(InitializableProblemHandler problemHandler)
void
filter(Metadata metadata)
void
initialize(Map<String,Param> params)
void
setRegex(String regex)
void
setSourceField(String sourceField)
void
setTargetField(String targetField)
-
Methods inherited from class org.apache.tika.metadata.filter.MetadataFilter
load
-
Methods inherited from class org.apache.tika.config.ConfigBase
buildComposite, buildComposite, buildSingle, buildSingle, configure, handleSettings
-
-
-
-
Method Detail
-
filter
public void filter(Metadata metadata) throws TikaException
- Specified by:
filter
in classMetadataFilter
- Throws:
TikaException
-
initialize
public void initialize(Map<String,Param> params) throws TikaConfigException
- Specified by:
initialize
in interfaceInitializable
- Parameters:
params
- params to use for initialization- Throws:
TikaConfigException
-
checkInitialization
public void checkInitialization(InitializableProblemHandler problemHandler) throws TikaConfigException
- Specified by:
checkInitialization
in interfaceInitializable
- Parameters:
problemHandler
- if there is a problem and no custom initializableProblemHandler has been configured via Initializable parameters, this is called to respond.- Throws:
TikaConfigException
-
-