Class FileExtensionFilter


  • public final class FileExtensionFilter
    extends Object

    A class representing an extension filter that can be used together with the file chooser service.

    When defining the options to show a file chooser dialog an arbitrary number of objects of this class can be specified. Each filter represents a specific file type and can be configured with the corresponding file extensions, such as "Image files"; "gif", "jpeg", "jpg", "png". The user is displayed a list with all pre-configured extension filters; when selecting a specific one, only the files matched by the filter are visible. (When providing a file extension do not prepend a separator character or a wildcard, such as *.txt; just use the plain extension txt).

    The description of the filter is displayed to the user. It can be defined as a TextResource object, i.e. either as plain text or via a resource ID.

    Instances of this class are immutable.

    Since:
    1.4
    • Field Detail

      • EXT_ALL_FILES

        public static final String EXT_ALL_FILES
        Constant for a special extension with the meaning that all files should be matched. This extension should be specified for an "All files" filter.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FileExtensionFilter

        public FileExtensionFilter​(TextResource descResource,
                                   List<String> extList)
        Creates a new instance of FileExtensionFilter and sets the resource for a description and a collection with the file extensions to be matched by this filter.
        Parameters:
        descResource - the resource for the filter description
        extList - a list with file extensions
      • FileExtensionFilter

        public FileExtensionFilter​(TextResource descResource,
                                   String... extensions)
        Creates a new instance of FileExtensionFilter and sets the resource for a description and the single file extensions to be matched by this filter.
        Parameters:
        descResource - the resource for the filter description
        extensions - the file extensions
    • Method Detail

      • getDescription

        public TextResource getDescription()
        Returns the TextResource for the filter description.
        Returns:
        the resource for the filter description
      • getExtensions

        public List<String> getExtensions()
        Returns a (unmodifiable) list with the file extensions assigned to this filter.
        Returns:
        a collection with file extensions
      • equals

        public boolean equals​(Object o)
        Two instances of this class are considered equals if all of their properties are equal.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object