Class CharsetTransformerConfig
- All Implemented Interfaces:
Labelable
Transforms a document content (if needed) from a source character encoding (charset) to a target one. Both the source and target character encodings are optional. If no source character encoding is explicitly provided, it first tries to detect the encoding of the document content before converting it to the target encoding. If the source character encoding cannot be established, the content encoding will remain unchanged. When no target character encoding is specified, UTF-8 is assumed.
Should I use this transformer?
Before using this transformer, you need to know the parsing of documents by the importer using default document parser factory will try to convert and return content as UTF-8 (for most, if not all content-types). If UTF-8 is your desired target, it only make sense to use this transformer as a pre-parsing handler (for text content-types only) when it is important to work with a specific character encoding before parsing. If on the other hand you wish to convert to a character encoding to a target different than UTF-8, you can use this transformer as a post-parsing handler to do so.
Conversion is not flawless
Because character encoding detection is not always accurate and because documents sometime mix different encoding, there is no guarantee this class will handle ALL character encoding conversions properly.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanOptional matcher of fields to convert the character set of their values.inthashCode()voidsetFieldMatcher(TextMatcher fieldMatcher) Set field matcher.setSourceCharset(Charset sourceCharset) setTargetCharset(Charset targetCharset) toString()Methods inherited from class com.norconex.importer.handler.BaseLabelableConfig
getLabel, setLabel
-
Field Details
-
DEFAULT_TARGET_CHARSET
-
-
Constructor Details
-
CharsetTransformerConfig
public CharsetTransformerConfig()
-
-
Method Details
-
setFieldMatcher
Set field matcher.- Parameters:
fieldMatcher- field matcher
-
getTargetCharset
-
getSourceCharset
-
getFieldMatcher
Optional matcher of fields to convert the character set of their values. When not specified, transformation is on the document content.- Returns:
- field matcher
-
setTargetCharset
- Returns:
this.
-
setSourceCharset
- Returns:
this.
-
equals
- Overrides:
equalsin classBaseLabelableConfig
-
canEqual
- Overrides:
canEqualin classBaseLabelableConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseLabelableConfig
-
toString
- Overrides:
toStringin classBaseLabelableConfig
-