Class TruncateTransformer
- All Implemented Interfaces:
Configurable<TruncateTransformerConfig>,ConfigurableDocHandler<TruncateTransformerConfig>,DocHandler
Truncates a fromField value(s) and optionally replace truncated
portion by a hash value to help ensure uniqueness (not 100% guaranteed to
be collision-free). If the field to truncate has multiple values, all
values will be subject to truncation. You can store the value(s), truncated
or not, in another target field.
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.
The maxLength is guaranteed to be respected. This means any
appended hash code and suffix will fit within the maxLength.
Truncating (or clearing) the document content
When no fieldMatcher is specified, this handler truncates the
document content (body) instead of a field. Setting maxLength
to 0 with no fieldMatcher effectively clears the
document content entirely, while leaving its metadata untouched. Pair it
with toField to first copy the content elsewhere (subject to
the same maxLength) before it is cleared - use a large
maxLength if the copy should not be truncated.
Can be used both as a pre-parse or post-parse handler.
Assuming this "myField" value...
Please truncate me before you start thinking I am too long.
...the above example will truncate it to...
Please truncate me before you start thi!0996700004
- 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 booleanvoiddoBody(DocHandlerContext docCtx) voiddoFields(DocHandlerContext docCtx) booleanbooleanhandle(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
-
TruncateTransformer
public TruncateTransformer()
-
-
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
-
doBody
- Throws:
IOException
-
doFields
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<TruncateTransformerConfig>
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-