Class MetadataFilter
- java.lang.Object
-
- com.norconex.collector.core.filter.impl.MetadataFilter
-
- All Implemented Interfaces:
IDocumentFilter
,IMetadataFilter
,IXMLConfigurable
,IOnMatchFilter
public class MetadataFilter extends Object implements IOnMatchFilter, IMetadataFilter, IDocumentFilter, IXMLConfigurable
Accepts or rejects a reference based on whether one or more metadata field values are matching.
XML configuration usage:
<filter class="com.norconex.collector.core.filter.impl.MetadataFilter" onMatch="[include|exclude]"> <fieldMatcher> (Expression matching one or more fields to evaluate.) </fieldMatcher> <valueMatcher> (Expression matching one or more values from matching fields.) </valueMatcher> </filter>
XML usage example:
<filter class="MetadataFilter" onMatch="exclude"> <fieldMatcher>Content-Type</fieldMatcher> <valueMatcher>application/zip</valueMatcher> </filter>
Used in a web context, the above example filters out Zip documents base on a "Content-Type" metadata field.
- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description MetadataFilter()
MetadataFilter(TextMatcher fieldMatcher, TextMatcher valueMatcher)
MetadataFilter(TextMatcher fieldMatcher, TextMatcher valueMatcher, OnMatch onMatch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptDocument(Doc document)
Whether to accept a document.boolean
acceptMetadata(String reference, Properties metadata)
Whether to accept the metadata.boolean
equals(Object other)
TextMatcher
getFieldMatcher()
Gets the field matcher.OnMatch
getOnMatch()
TextMatcher
getValueMatcher()
Gets the value matcher.int
hashCode()
void
loadFromXML(XML xml)
void
saveToXML(XML xml)
void
setFieldMatcher(TextMatcher fieldMatcher)
Sets the field matcher.void
setOnMatch(OnMatch onMatch)
void
setValueMatcher(TextMatcher valueMatcher)
Sets the value matcher.String
toString()
-
-
-
Constructor Detail
-
MetadataFilter
public MetadataFilter()
-
MetadataFilter
public MetadataFilter(TextMatcher fieldMatcher, TextMatcher valueMatcher)
-
MetadataFilter
public MetadataFilter(TextMatcher fieldMatcher, TextMatcher valueMatcher, OnMatch onMatch)
-
-
Method Detail
-
getOnMatch
public OnMatch getOnMatch()
- Specified by:
getOnMatch
in interfaceIOnMatchFilter
-
setOnMatch
public void setOnMatch(OnMatch onMatch)
-
getFieldMatcher
public TextMatcher getFieldMatcher()
Gets the field matcher.- Returns:
- field matcher
-
setFieldMatcher
public void setFieldMatcher(TextMatcher fieldMatcher)
Sets the field matcher.- Parameters:
fieldMatcher
- field matcher
-
getValueMatcher
public TextMatcher getValueMatcher()
Gets the value matcher.- Returns:
- value matcher
-
setValueMatcher
public void setValueMatcher(TextMatcher valueMatcher)
Sets the value matcher.- Parameters:
valueMatcher
- value matcher
-
acceptMetadata
public boolean acceptMetadata(String reference, Properties metadata)
Description copied from interface:IMetadataFilter
Whether to accept the metadata.- Specified by:
acceptMetadata
in interfaceIMetadataFilter
- Parameters:
reference
- the reference associated with the metadatametadata
- metadata associated with the reference- Returns:
true
if accepted,false
otherwise
-
acceptDocument
public boolean acceptDocument(Doc document)
Description copied from interface:IDocumentFilter
Whether to accept a document.- Specified by:
acceptDocument
in interfaceIDocumentFilter
- Parameters:
document
- the document to accept/reject- Returns:
true
if accepted,false
otherwise
-
loadFromXML
public void loadFromXML(XML xml)
- Specified by:
loadFromXML
in interfaceIXMLConfigurable
-
saveToXML
public void saveToXML(XML xml)
- Specified by:
saveToXML
in interfaceIXMLConfigurable
-
-