Class UrlExtractorTransformer
- All Implemented Interfaces:
Configurable<UrlExtractorTransformerConfig>,ConfigurableDocHandler<UrlExtractorTransformerConfig>,DocHandler
Extracts unique URLs matching specific patterns in plain text content and store them in a given field.
URL-matching patterns used are relatively simple. It looks for strings
starting with http://, https://,
or www.. The later is prefixed with https://
when encountered (to make it absolute).
The matching is case-insensitive. If you need alternate ways to detect URLs,
you can use a combination of RegexTransformer,
ReplaceTransformer, or
create your own implementation.
Storing values in an existing field
If a target field with the same name already exists for a document,
values will be added to the end of the existing value list.
It is possible to change this default behavior by supplying a
PropertySetter.
If no URLs are found, the target field values (if any) are left intact.
Content source
It is possible to specify a fromField
as the source of the text to use instead of using the document content.
This class is typically e used as a post-parsing handler only (to ensure we are dealing with text).
- See Also:
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTYFields inherited from interface com.norconex.importer.handler.DocHandler
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanbooleanhandle(DocHandlerContext docCtx) Perform any operations on a document.inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norconex.importer.handler.DocHandler
close, init
-
Constructor Details
-
UrlExtractorTransformer
public UrlExtractorTransformer()
-
-
Method Details
-
handle
Description copied from interface:DocHandlerPerform any operations on a document.- Specified by:
handlein interfaceDocHandler- Parameters:
docCtx- the document handling context- Returns:
falseto stop processing and reject a document ortrueto proceed to the next configured handler.- Throws:
IOException- An I/O exception of some sort has occurred
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<UrlExtractorTransformerConfig>
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-