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.
<filter
class="com.norconex.collector.core.filter.impl.MetadataFilter"
onMatch="[include|exclude]">
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(Expression matching one or more fields to evaluate.)
</fieldMatcher>
<valueMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(Expression matching one or more values from matching fields.)
</valueMatcher>
</filter>
<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.
Constructor and Description |
---|
MetadataFilter() |
MetadataFilter(TextMatcher fieldMatcher,
TextMatcher valueMatcher) |
MetadataFilter(TextMatcher fieldMatcher,
TextMatcher valueMatcher,
OnMatch onMatch) |
Modifier and Type | Method and 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() |
public MetadataFilter()
public MetadataFilter(TextMatcher fieldMatcher, TextMatcher valueMatcher)
public MetadataFilter(TextMatcher fieldMatcher, TextMatcher valueMatcher, OnMatch onMatch)
public OnMatch getOnMatch()
getOnMatch
in interface IOnMatchFilter
public void setOnMatch(OnMatch onMatch)
public TextMatcher getFieldMatcher()
public void setFieldMatcher(TextMatcher fieldMatcher)
fieldMatcher
- field matcherpublic TextMatcher getValueMatcher()
public void setValueMatcher(TextMatcher valueMatcher)
valueMatcher
- value matcherpublic boolean acceptMetadata(String reference, Properties metadata)
IMetadataFilter
acceptMetadata
in interface IMetadataFilter
reference
- the reference associated with the metadatametadata
- metadata associated with the referencetrue
if accepted, false
otherwisepublic boolean acceptDocument(Doc document)
IDocumentFilter
acceptDocument
in interface IDocumentFilter
document
- the document to accept/rejecttrue
if accepted, false
otherwisepublic void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
public void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
Copyright © 2014–2023 Norconex Inc.. All rights reserved.