public class RegexMetadataFilter extends AbstractDocumentFilter
Accepts or rejects a document based on its field values using regular expression.
<filter class="com.norconex.importer.handler.filter.impl.RegexMetadataFilter" onMatch="[include|exclude]" caseSensitive="[false|true]" field="(name of metadata name to match)" > <restrictTo caseSensitive="[false|true]" field="(name of header/metadata field name to match)"> (regular expression of value to match) </restrictTo> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <regex>(regular expression of value to match)</regex> </filter>
This example will accept only documents containing word "potato" in the title.
<filter class="com.norconex.importer.handler.filter.impl.RegexMetadataFilter" onMatch="include" field="title" > <regex>.*potato.*</regex> </filter>
Constructor and Description |
---|
RegexMetadataFilter() |
RegexMetadataFilter(String field,
String regex) |
RegexMetadataFilter(String field,
String regex,
OnMatch onMatch) |
RegexMetadataFilter(String property,
String regex,
OnMatch onMatch,
boolean caseSensitive) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getField() |
String |
getRegex() |
int |
hashCode() |
boolean |
isCaseSensitive() |
protected boolean |
isDocumentMatched(String reference,
InputStream input,
ImporterMetadata metadata,
boolean parsed) |
protected void |
loadFilterFromXML(org.apache.commons.configuration.XMLConfiguration xml) |
protected void |
saveFilterToXML(EnhancedXMLStreamWriter writer) |
void |
setCaseSensitive(boolean caseSensitive) |
void |
setField(String property) |
void |
setRegex(String regex) |
String |
toString() |
acceptDocument, getOnMatch, loadHandlerFromXML, saveHandlerToXML, setOnMatch
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
public String getRegex()
public final void setRegex(String regex)
public boolean isCaseSensitive()
public String getField()
public void setCaseSensitive(boolean caseSensitive)
public void setField(String property)
protected boolean isDocumentMatched(String reference, InputStream input, ImporterMetadata metadata, boolean parsed) throws ImporterHandlerException
isDocumentMatched
in class AbstractDocumentFilter
ImporterHandlerException
protected void loadFilterFromXML(org.apache.commons.configuration.XMLConfiguration xml) throws IOException
loadFilterFromXML
in class AbstractDocumentFilter
IOException
protected void saveFilterToXML(EnhancedXMLStreamWriter writer) throws XMLStreamException
saveFilterToXML
in class AbstractDocumentFilter
XMLStreamException
public String toString()
toString
in class AbstractDocumentFilter
public int hashCode()
hashCode
in class AbstractDocumentFilter
public boolean equals(Object obj)
equals
in class AbstractDocumentFilter
Copyright © 2009–2021 Norconex Inc.. All rights reserved.