Class TruncateTransformerConfig
- All Implemented Interfaces:
Labelable
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanGets the field matcher for fields to truncate.intgetOnSet()The property setter to use when a value is set.inthashCode()booleanWhether to apply the original string hash code at the end of the truncation to help ensure uniqueness (no guarantee).setAppendHash(boolean appendHash) Whether to apply the original string hash code at the end of the truncation to help ensure uniqueness (no guarantee).setFieldMatcher(TextMatcher fieldMatcher) Sets the field matcher for fields to truncate.setMaxLength(int maxLength) setOnSet(PropertySetter onSet) The property setter to use when a value is set.setToField(String toField) toString()Methods inherited from class com.norconex.importer.handler.BaseLabelableConfig
getLabel, setLabel
-
Constructor Details
-
TruncateTransformerConfig
public TruncateTransformerConfig()
-
-
Method Details
-
getFieldMatcher
Gets the field matcher for fields to truncate. When unset (the default), the document content (body) is truncated instead.- Returns:
- field matcher
-
setFieldMatcher
Sets the field matcher for fields to truncate. When unset (the default), the document content (body) is truncated instead.- Parameters:
fieldMatcher- field matcher
-
getMaxLength
public int getMaxLength() -
getToField
-
getOnSet
The property setter to use when a value is set.- Returns:
- property setter
-
isAppendHash
public boolean isAppendHash()Whether to apply the original string hash code at the end of the truncation to help ensure uniqueness (no guarantee). -
getSuffix
-
setMaxLength
- Returns:
this.
-
setToField
- Returns:
this.
-
setOnSet
The property setter to use when a value is set.- Parameters:
onSet- property setter- Returns:
this.
-
setAppendHash
Whether to apply the original string hash code at the end of the truncation to help ensure uniqueness (no guarantee).- Returns:
this.
-
setSuffix
- Returns:
this.
-
equals
- Overrides:
equalsin classBaseLabelableConfig
-
canEqual
- Overrides:
canEqualin classBaseLabelableConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseLabelableConfig
-
toString
- Overrides:
toStringin classBaseLabelableConfig
-