Package org.apache.tika.metadata.filter
Class MetadataFilter
java.lang.Object
org.apache.tika.metadata.filter.MetadataFilter
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable
- Direct Known Subclasses:
AbstractEmbeddingFilter,CompositeMetadataFilter,MetadataFilterBase,NoOpFilter,RemoveByMimeMetadataFilter
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases any resources held by this filter (e.g.protected abstract voiddoFilter(List<Metadata> metadataList, ParseContext parseContext) Applies the filter in place.voidConvenience overload for callers that have no per-request context.final voidfilter(List<Metadata> metadataList, ParseContext parseContext) Filters the metadata list in place using per-request context.
-
Constructor Details
-
MetadataFilter
public MetadataFilter()
-
-
Method Details
-
filter
public final void filter(List<Metadata> metadataList, ParseContext parseContext) throws TikaException Filters the metadata list in place using per-request context. The list and the metadata objects within it may be modified. Callers must pass a mutable list and should make a defensive copy before calling if the original data must be preserved.- Parameters:
metadataList- the list to filter (must be mutable)parseContext- per-request context (e.g. skip flags, runtime config)- Throws:
TikaException- if filtering fails
-
doFilter
protected abstract void doFilter(List<Metadata> metadataList, ParseContext parseContext) throws TikaException Applies the filter in place. A filter that needs to write a reserved Tika-native (tk:) key by name (rather than via itsProperty) should callMetadata.addTrusted(java.lang.String, java.lang.String)/Metadata.setTrusted(java.lang.String, java.lang.String)explicitly at that write.- Parameters:
metadataList- the list to filter (must be mutable)parseContext- per-request context- Throws:
TikaException- if filtering fails
-
filter
Convenience overload for callers that have no per-request context. Delegates tofilter(List, ParseContext)with an empty context.- Throws:
TikaException
-
close
Releases any resources held by this filter (e.g. HTTP connection pools, thread pools). The default implementation is a no-op; filters that hold long-lived resources should override this.Callers that control the filter lifecycle (e.g.
PipesServer, try-with-resources blocks) should call this when the filter is no longer needed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-