public class RegexMetadataFilter extends AbstractOnMatchFilter implements IMetadataFilter, IDocumentFilter, IXMLConfigurable
Accepts or rejects a reference using regular expression to match a metadata field value.
<filter class="com.norconex.collector.core.filter.impl.RegexMetadataFilter" onMatch="[include|exclude]" caseSensitive="[false|true]" field="(metadata field to holding the value to match)"> (regular expression of value to match) </filter>
Used in a web context, the following example filters out Zip documents base on HTTP metadata "Content-Type".
<filter class="com.norconex.collector.core.filter.impl.RegexMetadataFilter" onMatch="exclude" field="Content-Type"> application/zip </filter>
Pattern
Constructor and Description |
---|
RegexMetadataFilter() |
RegexMetadataFilter(String header,
String regex) |
RegexMetadataFilter(String header,
String regex,
OnMatch onMatch) |
RegexMetadataFilter(String header,
String regex,
OnMatch onMatch,
boolean caseSensitive) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptDocument(ImporterDocument document)
Whether to accept a document.
|
boolean |
acceptMetadata(String reference,
Properties metadata)
Whether to accept the metadata.
|
boolean |
equals(Object obj) |
String |
getField() |
String |
getRegex() |
int |
hashCode() |
boolean |
isCaseSensitive() |
void |
loadFromXML(Reader in) |
void |
saveToXML(Writer out) |
void |
setCaseSensitive(boolean caseSensitive) |
void |
setField(String header) |
void |
setRegex(String regex) |
String |
toString() |
getOnMatch, loadFromXML, saveToXML, setOnMatch
public String getRegex()
public boolean isCaseSensitive()
public String getField()
public final void setCaseSensitive(boolean caseSensitive)
public final void setField(String header)
public final void setRegex(String regex)
public 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(ImporterDocument document)
IDocumentFilter
acceptDocument
in interface IDocumentFilter
document
- the document to accept/rejecttrue
if accepted, false
otherwisepublic void loadFromXML(Reader in)
loadFromXML
in interface IXMLConfigurable
public void saveToXML(Writer out) throws IOException
saveToXML
in interface IXMLConfigurable
IOException
public String toString()
toString
in class AbstractOnMatchFilter
public boolean equals(Object obj)
equals
in class AbstractOnMatchFilter
public int hashCode()
hashCode
in class AbstractOnMatchFilter
Copyright © 2014–2021 Norconex Inc.. All rights reserved.