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 booleanequals(Object other)TextMatchergetValueMatcher()Gets the text matcher for field values.inthashCode()protected booleanisDocumentMatched(HandlerDoc doc, InputStream input, ParseState parseState)protected voidloadFilterFromXML(XML xml)protected voidsaveFilterToXML(XML xml)voidsetValueMatcher(TextMatcher valueMatcher)Sets the text matcher for field values.StringtoString()-
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:
isDocumentMatchedin classAbstractDocumentFilter- Throws:
ImporterHandlerException
-
loadFilterFromXML
protected void loadFilterFromXML(XML xml)
- Specified by:
loadFilterFromXMLin classAbstractDocumentFilter
-
saveFilterToXML
protected void saveFilterToXML(XML xml)
- Specified by:
saveFilterToXMLin classAbstractDocumentFilter
-
equals
public boolean equals(Object other)
- Overrides:
equalsin classAbstractDocumentFilter
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractDocumentFilter
-
toString
public String toString()
- Overrides:
toStringin classAbstractDocumentFilter
-
-