Class ScriptTransformerConfig
java.lang.Object
com.norconex.importer.handler.BaseLabelableConfig
com.norconex.importer.handler.BaseDocHandlerConfig
com.norconex.importer.handler.transformer.impl.ScriptTransformerConfig
- All Implemented Interfaces:
Labelable,ChunkedTextSupport
Transform incoming documents using a scripting language.
Refer to ScriptRunner for more information on using a scripting
language with Norconex Importer.
How to transform documents with scripting:
The following are variables made available to your script for each document:
- reference: Document unique reference as a string.
- content: Document content, as a string
(of
maxReadSizelength). - metadata: Document metadata as an
Propertiesobject. - parsed: Whether the document was already parsed, as a boolean.
- sectionIndex: Content section index if it had to be split
(as per
maxReadSize), as an integer.
The expected return value from your script is a string holding the modified content.
Usage examples:
The following examples replace all occurrences of "Alice" with "Roger" in a document content.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanGets source field matcher for fields on which to execute a script.intinthashCode()setEngineName(String engineName) setFieldMatcher(TextMatcher fieldMatcher) Sets source field matcher for fields on which to execute a script.setMaxReadSize(int maxReadSize) setSourceCharset(Charset sourceCharset) toString()Methods inherited from class com.norconex.importer.handler.BaseLabelableConfig
getLabel, setLabel
-
Constructor Details
-
ScriptTransformerConfig
public ScriptTransformerConfig()
-
-
Method Details
-
getFieldMatcher
Gets source field matcher for fields on which to execute a script.- Specified by:
getFieldMatcherin interfaceChunkedTextSupport- Returns:
- field matcher
-
setFieldMatcher
Sets source field matcher for fields on which to execute a script.- Parameters:
fieldMatcher- field matcher
-
getMaxReadSize
public int getMaxReadSize()- Specified by:
getMaxReadSizein interfaceChunkedTextSupport
-
getSourceCharset
- Specified by:
getSourceCharsetin interfaceChunkedTextSupport
-
getEngineName
-
getScript
-
setMaxReadSize
- Returns:
this.
-
setSourceCharset
- Returns:
this.
-
setEngineName
- Returns:
this.
-
setScript
- Returns:
this.
-
equals
- Overrides:
equalsin classBaseLabelableConfig
-
canEqual
- Overrides:
canEqualin classBaseLabelableConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseLabelableConfig
-
toString
- Overrides:
toStringin classBaseLabelableConfig
-