Class MimeUtils
java.lang.Object
uno.anahata.asi.nb.mine.MimeUtils
Utility class for working with MIME types and file extensions in NetBeans.
This class provides methods to query the IDE's internal configuration to
discover supported file formats and their mappings.
- Author:
- anahata
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor for the utility class to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionScans the NetBeans System Filesystem's "Editors" folder to find all registered MIME types.Scans the NetBeans System Filesystem to find all registered MIME types and their file extensions, returning a map where the key is the extension and the value is the MIME type.
-
Constructor Details
-
MimeUtils
private MimeUtils()Private constructor for the utility class to prevent instantiation.
-
-
Method Details
-
getAllMimeTypes
Scans the NetBeans System Filesystem's "Editors" folder to find all registered MIME types. This is the most reliable method to get a complete list of MIME types the IDE is aware of.Implementation Logic:
- Retrieves the "Editors" configuration folder via
FileUtil.getConfigFile("Editors"). - Recursively iterates through all subfolders using an
Enumeration. - Calculates the MIME type string by deriving the relative path from the "Editors" root.
- Filters for folders that contain data files (settings), ensuring that only effectively active MIME types are returned, skipping intermediate hierarchy folders.
- Returns:
- A Set of all registered MIME type strings (e.g., "text/x-java", "text/xml").
- Retrieves the "Editors" configuration folder via
-
getExtensionToMimeTypeMap
Scans the NetBeans System Filesystem to find all registered MIME types and their file extensions, returning a map where the key is the extension and the value is the MIME type.Implementation Logic:
- Calls
getAllMimeTypes()to get the baseline of known types. - For each MIME type, uses
FileUtil.getMIMETypeExtensions(mimeType)to retrieve associated file extensions. - Maps each extension to its MIME type. In cases where an extension is associated with multiple types, the last one processed prevails.
- Returns:
- A Map of file extensions (e.g., "java", "xml") to their corresponding MIME types.
- Calls
-

