Class ScriptConditionConfig

All Implemented Interfaces:
Labelable

public class ScriptConditionConfig extends BaseConditionConfig

A condition formulated using a scripting language.

Refer to ScriptRunner for more information on using a scripting language with Norconex Importer.

How to create a condition 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 maxReadSize length).
  • metadata: Document metadata as a Properties object.
  • parsed: Whether the document was already parsed, as a boolean.
  • sectionIndex: Content section index (integer) if it had to be split because it was too large (as per maxReadSize).

The expected return value from your script is a boolean indicating whether the document was matched or not.

See Also:
  • Constructor Details

    • ScriptConditionConfig

      public ScriptConditionConfig()
  • Method Details

    • getFieldMatcher

      public TextMatcher getFieldMatcher()
      Gets this filter field matcher.
      Returns:
      field matcher
    • setFieldMatcher

      public ScriptConditionConfig setFieldMatcher(TextMatcher fieldMatcher)
      Sets this condition field matcher.
      Parameters:
      fieldMatcher - field matcher
    • getEngineName

      public String getEngineName()
    • getScript

      public String getScript()
    • getSourceCharset

      public Charset getSourceCharset()
      The presumed source character encoding. Usually ignored and presumed to be UTF-8 if the document has been parsed already.
      Returns:
      character encoding of the source to be transformed
    • getMaxReadSize

      public int getMaxReadSize()
      The maximum number of characters to read at once, used for filtering. Default is TextReader.DEFAULT_MAX_READ_SIZE.
      Returns:
      maximum read size
    • setEngineName

      public ScriptConditionConfig setEngineName(String engineName)
      Returns:
      this.
    • setScript

      public ScriptConditionConfig setScript(String script)
      Returns:
      this.
    • setSourceCharset

      public ScriptConditionConfig setSourceCharset(Charset sourceCharset)
      The presumed source character encoding. Usually ignored and presumed to be UTF-8 if the document has been parsed already.
      Parameters:
      sourceCharset - character encoding of the source to be transformed
      Returns:
      this.
    • setMaxReadSize

      public ScriptConditionConfig setMaxReadSize(int maxReadSize)
      The maximum number of characters to read at once, used for filtering. Default is TextReader.DEFAULT_MAX_READ_SIZE.
      Parameters:
      maxReadSize - maximum read size
      Returns:
      this.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BaseLabelableConfig
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class BaseLabelableConfig
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseLabelableConfig
    • toString

      public String toString()
      Overrides:
      toString in class BaseLabelableConfig