Class ReferenceFilter
- java.lang.Object
-
- com.norconex.importer.handler.AbstractImporterHandler
-
- com.norconex.importer.handler.filter.AbstractDocumentFilter
-
- com.norconex.importer.handler.filter.impl.ReferenceFilter
-
- All Implemented Interfaces:
IXMLConfigurable
,IDocumentFilter
,IOnMatchFilter
,IImporterHandler
public class ReferenceFilter extends AbstractDocumentFilter
Accepts or rejects a document based on its reference (e.g. URL).
Can be used both as a pre-parse or post-parse handler.
XML configuration usage:
<handler class="com.norconex.importer.handler.filter.impl.ReferenceFilter" onMatch="[include|exclude]"> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <restrictTo> <fieldMatcher>(field-matching expression)</fieldMatcher> <valueMatcher>(value-matching expression)</valueMatcher> </restrictTo> <valueMatcher>(expression of reference value to match)</valueMatcher> </handler>
XML usage example:
<handler class="ReferenceFilter" onMatch="exclude"> <valueMatcher method="regex"> .*/login/.* </valueMatcher> </handler>
The above eample reject documents having "/login/" in their reference.
- Since:
- 3.0.0
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description ReferenceFilter()
ReferenceFilter(TextMatcher textMatcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
TextMatcher
getValueMatcher()
Gets the text matcher for field values.int
hashCode()
protected boolean
isDocumentMatched(HandlerDoc doc, InputStream input, ParseState parseState)
protected void
loadFilterFromXML(XML xml)
protected void
saveFilterToXML(XML xml)
void
setValueMatcher(TextMatcher valueMatcher)
Sets the text matcher for field values.String
toString()
-
Methods inherited from class com.norconex.importer.handler.filter.AbstractDocumentFilter
acceptDocument, getOnMatch, loadHandlerFromXML, saveHandlerToXML, setOnMatch
-
Methods inherited from class com.norconex.importer.handler.AbstractImporterHandler
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
-
-
-
-
Constructor Detail
-
ReferenceFilter
public ReferenceFilter()
-
ReferenceFilter
public ReferenceFilter(TextMatcher textMatcher)
-
-
Method Detail
-
getValueMatcher
public TextMatcher getValueMatcher()
Gets the text matcher for field values.- Returns:
- text matcher
-
setValueMatcher
public void setValueMatcher(TextMatcher valueMatcher)
Sets the text matcher for field values. Copies it.- Parameters:
valueMatcher
- text matcher
-
isDocumentMatched
protected boolean isDocumentMatched(HandlerDoc doc, InputStream input, ParseState parseState) throws ImporterHandlerException
- Specified by:
isDocumentMatched
in classAbstractDocumentFilter
- Throws:
ImporterHandlerException
-
loadFilterFromXML
protected void loadFilterFromXML(XML xml)
- Specified by:
loadFilterFromXML
in classAbstractDocumentFilter
-
saveFilterToXML
protected void saveFilterToXML(XML xml)
- Specified by:
saveFilterToXML
in classAbstractDocumentFilter
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classAbstractDocumentFilter
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractDocumentFilter
-
toString
public String toString()
- Overrides:
toString
in classAbstractDocumentFilter
-
-