Interface IFileContentManager


public interface IFileContentManager
This is the API to define mappings between file names, file extensions and content types, typically used by repository providers in order to determine whether a given file can be treated as text or must be considered binary. Mappings for names and extensions can either be contributed via an extension point or via this interface. For methods that determine the content type for a given file, the following rules apply:
  • Mappings for the entire file name take precedence over mappings for the file extension only.
  • User-defined mappings take precedence over plugin-contributed mappings
If a mapping is added for a name or an extension that already has a mapping which has been contributed by a plugin, it overrides the one contributed by the plugin. If the user-defined mapping is deleted, the plugin-contributed mapping is valid again. This interface is not intended to be implemented by clients.
Since:
3.1
See Also:
Restriction:
This interface is not intended to be implemented by clients.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addExtensionMappings(String[] extensions, int[] types)
    Map a set of file extensions to a set of content types and save the mapping in the preferences.
    void
    addNameMappings(String[] names, int[] types)
    Map a set of file names to a set of content types and save the mappings in the preferences.
    Get all the plugin-contributed mappings from file extensions to content types.
    Get all the plugin-contributed mappings from file names to content types.
    Get all the currently defined mappings from file names to content types.
    Get all the currently defined mappings from file names to content types.
    int
    getType(IStorage storage)
    Get the content type for a given instance of IStorage.
    int
    Get the content type for a given file extension.
    int
    Get the content type for a given file name.
    boolean
    Check whether the given file extension is assigned to a specific type in the content type registry.
    boolean
    Check whether the given file name is assigned to a specific type in the content type registry.
    void
    setExtensionMappings(String[] extensions, int[] types)
    Map a set of file extensions to a set of content types and save the mapping in the preferences.
    void
    setNameMappings(String[] names, int[] types)
    Map a set of file names to a set of content types and save the mappings in the preferences.
  • Method Details

    • getType

      int getType(IStorage storage)
      Get the content type for a given instance of IStorage. User-defined mappings take precedence over plugin-contributed mappings; further, mappings for the entire file name take precedence over mappings for the file extension only.
      Parameters:
      storage - the instance of IStorage.
      Returns:
      one of Team.UNKNOWN, Team.TEXT or Team.BINARY.
      Since:
      3.1
    • isKnownFilename

      boolean isKnownFilename(String filename)
      Check whether the given file name is assigned to a specific type in the content type registry.
      Parameters:
      filename - the file name to check for
      Returns:
      True if the file name is registered in the system and assigned to a content type, false if the file name is unknown.
      Since:
      3.1
    • isKnownExtension

      boolean isKnownExtension(String extension)
      Check whether the given file extension is assigned to a specific type in the content type registry.
      Parameters:
      extension - the extension to check for
      Returns:
      True if the extension is registered in the system and assigned to a content type, false if the extension is unknown.
      Since:
      3.1
    • getTypeForName

      int getTypeForName(String filename)
      Get the content type for a given file name.
      Parameters:
      filename - The file name
      Returns:
      one of Team.UNKNOWN, Team.TEXT or Team.BINARY.
      Since:
      3.1
    • getTypeForExtension

      int getTypeForExtension(String extension)
      Get the content type for a given file extension.
      Parameters:
      extension - The extension
      Returns:
      one of Team.UNKNOWN, Team.TEXT or Team.BINARY.
      Since:
      3.1
    • addNameMappings

      void addNameMappings(String[] names, int[] types)
      Map a set of file names to a set of content types and save the mappings in the preferences. Already existing mappings for these file names are updated with the new ones, other mappings will be preserved.
      Parameters:
      names - The file names
      types - The corresponding types, each one being one of Team.UNKNOWN,Team.TEXT or Team.BINARY.
      Since:
      3.1
    • addExtensionMappings

      void addExtensionMappings(String[] extensions, int[] types)
      Map a set of file extensions to a set of content types and save the mapping in the preferences. Already existing mappings for these extensions are updated with the new ones, other mappings will be preserved.
      Parameters:
      extensions - The extensions
      types - The corresponding types, each one being one of Team.UNKNOWN,Team.TEXT or Team.BINARY.
      Since:
      3.1
    • setNameMappings

      void setNameMappings(String[] names, int[] types)
      Map a set of file names to a set of content types and save the mappings in the preferences. All existing user-defined mappings for any file names are deleted and replaced by the new ones.
      Parameters:
      names - The file names
      types - The corresponding types, each one being one of Team.UNKNOWN,Team.TEXT or Team.BINARY.
      Since:
      3.1
    • setExtensionMappings

      void setExtensionMappings(String[] extensions, int[] types)
      Map a set of file extensions to a set of content types and save the mapping in the preferences. All existing user-defined mappings for any file extensions are deleted and replaced by the new ones.
      Parameters:
      extensions - The extensions
      types - The corresponding types, each one being one of Team.UNKNOWN,Team.TEXT or Team.BINARY.
      Since:
      3.1
    • getNameMappings

      IStringMapping[] getNameMappings()
      Get all the currently defined mappings from file names to content types.
      Returns:
      the mappings
      Since:
      3.1
    • getExtensionMappings

      IStringMapping[] getExtensionMappings()
      Get all the currently defined mappings from file names to content types.
      Returns:
      the mappings
      Since:
      3.1
    • getDefaultNameMappings

      IStringMapping[] getDefaultNameMappings()
      Get all the plugin-contributed mappings from file names to content types.
      Returns:
      the mappings
      Since:
      3.1
    • getDefaultExtensionMappings

      IStringMapping[] getDefaultExtensionMappings()
      Get all the plugin-contributed mappings from file extensions to content types.
      Returns:
      the mappings
      Since:
      3.1