Interface FessTransformer
- All Known Implementing Classes:
AbstractFessFileTransformer,FessFileTransformer,FessStandardTransformer,FessXpathTransformer
public interface FessTransformer
Interface for transforming and processing crawled documents in Fess.
Provides utility methods for URL processing, site extraction, data mapping,
and field configuration handling during the document transformation process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionSynchronized LRU cache for storing parent URL encodings. -
Method Summary
Modifier and TypeMethodDescriptiondefault StringabbreviateSite(String value) Abbreviates a site string to the maximum allowed length if configured.default StringdecodeUrlAsName(String url, boolean escapePlus) Decodes a URL as a name using appropriate character encoding.default ObjectEvaluates a template script using the specified script engine and parameters.org.codelibs.fess.mylasta.direction.FessConfigGets the Fess configuration instance.default StringgetFileName(String url, String encoding) Extracts the filename from a URL, handling various protocols and URL decoding.default StringExtracts the host name from a URL string.org.apache.logging.log4j.LoggerGets the logger instance for this transformer.default intGets the maximum allowed length for site strings from configuration.default StringgetParentEncoding(String parentUrl, String sessionId) Gets the character encoding for a parent URL from cache or data service.default StringExtracts and processes the site path from a URL with proper encoding handling.processFieldConfigs(Map<String, Object> dataMap, FieldConfigs fieldConfigs) Processes field configurations to handle field overwriting rules.default voidPuts data into the result data map, handling value appending if configured.default voidputResultDataWithTemplate(Map<String, Object> dataMap, String key, Object value, String template, String scriptType) Puts data into the result data map after processing it through a template script.
-
Field Details
-
parentEncodingMap
Synchronized LRU cache for storing parent URL encodings. Maps session+parent URL keys to their corresponding character encodings.
-
-
Method Details
-
getFessConfig
org.codelibs.fess.mylasta.direction.FessConfig getFessConfig()Gets the Fess configuration instance.- Returns:
- the Fess configuration object
-
getLogger
org.apache.logging.log4j.Logger getLogger()Gets the logger instance for this transformer.- Returns:
- the logger instance
-
getHost
Extracts the host name from a URL string. Removes protocol and path components to return just the hostname.- Parameters:
u- the URL string to extract host from- Returns:
- the host name, or empty string if URL is blank, or unknown hostname if parsing fails
-
getSite
Extracts and processes the site path from a URL with proper encoding handling. Removes protocol, query parameters, and applies URL decoding based on encoding settings.- Parameters:
u- the URL string to processencoding- the character encoding to use for URL decoding- Returns:
- the processed site path, abbreviated if necessary
-
putResultDataBody
Puts data into the result data map, handling value appending if configured. If data appending is enabled and the key already exists, values are combined into arrays.- Parameters:
dataMap- the data map to modifykey- the key to store the value undervalue- the value to store
-
putResultDataWithTemplate
default void putResultDataWithTemplate(Map<String, Object> dataMap, String key, Object value, String template, String scriptType) Puts data into the result data map after processing it through a template script. The template is evaluated using the specified script engine with the value and context.- Parameters:
dataMap- the data map to modifykey- the key to store the processed value undervalue- the original value to processtemplate- the template script to evaluatescriptType- the type of script engine to use
-
evaluateValue
Evaluates a template script using the specified script engine and parameters.- Parameters:
scriptType- the type of script engine to usetemplate- the template script to evaluateparamMap- the parameters to pass to the script- Returns:
- the result of script evaluation, or empty string if template is empty
-
getMaxSiteLength
default int getMaxSiteLength()Gets the maximum allowed length for site strings from configuration.- Returns:
- the maximum site length as configured
-
abbreviateSite
Abbreviates a site string to the maximum allowed length if configured.- Parameters:
value- the site string to abbreviate- Returns:
- the abbreviated string, or original if no length limit is set
-
getFileName
Extracts the filename from a URL, handling various protocols and URL decoding. Processes HTTP, HTTPS, file, SMB, and FTP URLs appropriately.- Parameters:
url- the URL to extract filename fromencoding- the character encoding (currently unused in this method)- Returns:
- the extracted filename, or empty string if none found
-
decodeUrlAsName
Decodes a URL as a name using appropriate character encoding. Handles encoding detection from parent URLs and configuration settings.- Parameters:
url- the URL to decodeescapePlus- whether to escape plus signs before decoding- Returns:
- the decoded URL name, or original URL if decoding fails
-
getParentEncoding
Gets the character encoding for a parent URL from cache or data service. Caches encoding information to improve performance on subsequent requests.- Parameters:
parentUrl- the parent URL to get encoding forsessionId- the session ID for the crawling session- Returns:
- the character encoding, or null if not found
-
processFieldConfigs
default Map<String,Object> processFieldConfigs(Map<String, Object> dataMap, FieldConfigs fieldConfigs) Processes field configurations to handle field overwriting rules. Creates a new data map with fields processed according to their configuration.- Parameters:
dataMap- the original data map to processfieldConfigs- the field configurations to apply- Returns:
- a new data map with configurations applied
-