Package org.codelibs.fess.helper
Class FileTypeHelper
java.lang.Object
org.codelibs.fess.helper.FileTypeHelper
Helper class for managing file type mappings based on MIME types.
This class provides functionality to map MIME types to file types and
retrieve appropriate file type classifications for documents during indexing.
The mappings are loaded from configuration and can be dynamically modified
at runtime. When a MIME type is not found in the mapping, a default value
is returned.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringDefault file type value returned when MIME type is not found in mappingsMap storing MIME type to file type mappings -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds or updates a MIME type to file type mapping.Retrieves the file type for a given MIME type.Gets the default file type value used when MIME type is not found.String[]getTypes()Gets all distinct file types currently configured in the mappings.voidinit()Initializes the file type mappings by loading configuration from Fess settings.voidsetDefaultValue(String defaultValue) Sets the default file type value to use when MIME type is not found.
-
Field Details
-
defaultValue
Default file type value returned when MIME type is not found in mappings -
mimetypeMap
Map storing MIME type to file type mappings
-
-
Constructor Details
-
FileTypeHelper
public FileTypeHelper()Default constructor for file type helper. Creates a new instance with default values.
-
-
Method Details
-
init
@PostConstruct public void init()Initializes the file type mappings by loading configuration from Fess settings. This method is called automatically after dependency injection is complete. The mappings are loaded from the index filetype configuration property, where each line contains a MIME type to file type mapping in the format "mimetype=filetype". -
add
Adds or updates a MIME type to file type mapping.- Parameters:
mimetype- the MIME type to map (e.g., "application/pdf")filetype- the file type classification (e.g., "pdf")
-
get
Retrieves the file type for a given MIME type.- Parameters:
mimetype- the MIME type to look up- Returns:
- the corresponding file type, or the default value if not found
-
getDefaultValue
Gets the default file type value used when MIME type is not found.- Returns:
- the default file type value
-
setDefaultValue
Sets the default file type value to use when MIME type is not found.- Parameters:
defaultValue- the new default file type value
-
getTypes
Gets all distinct file types currently configured in the mappings.- Returns:
- an array of all unique file type values
-