public class RegexReferenceFilter extends AbstractOnMatchFilter implements IReferenceFilter, IDocumentFilter, IMetadataFilter, IXMLConfigurable
Filters URL based on a regular expression.
<filter class="com.norconex.collector.core.filter.impl.RegexReferenceFilter" onMatch="[include|exclude]" caseSensitive="[false|true]" > (regular expression) </filter>
The following will reject documents having "/login/" in their reference.
<filter class="com.norconex.collector.core.filter.impl.RegexReferenceFilter" onMatch="exclude"> .*/login/.* </filter>
Pattern
Constructor and Description |
---|
RegexReferenceFilter() |
RegexReferenceFilter(String regex) |
RegexReferenceFilter(String regex,
OnMatch onMatch) |
RegexReferenceFilter(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 |
acceptReference(String url)
Whether to accept this reference.
|
boolean |
equals(Object obj) |
String |
getRegex() |
int |
hashCode() |
boolean |
isCaseSensitive() |
void |
loadFromXML(Reader in) |
void |
saveToXML(Writer out) |
void |
setCaseSensitive(boolean caseSensitive) |
void |
setRegex(String regex) |
String |
toString() |
getOnMatch, loadFromXML, saveToXML, setOnMatch
public RegexReferenceFilter()
public RegexReferenceFilter(String regex)
public String getRegex()
public boolean isCaseSensitive()
public final void setCaseSensitive(boolean caseSensitive)
public final void setRegex(String regex)
public boolean acceptReference(String url)
IReferenceFilter
acceptReference
in interface IReferenceFilter
url
- the reference 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 boolean acceptDocument(ImporterDocument document)
IDocumentFilter
acceptDocument
in interface IDocumentFilter
document
- the document to accept/rejecttrue
if accepted, false
otherwisepublic 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 String toString()
toString
in class AbstractOnMatchFilter
public int hashCode()
hashCode
in class AbstractOnMatchFilter
public boolean equals(Object obj)
equals
in class AbstractOnMatchFilter
Copyright © 2014–2021 Norconex Inc.. All rights reserved.