public interface PathFilter
The PathFilter interface is used by FileChooserModel to provide filter predicates matching specific file types. Each PathFilter also provides a name to populate e.g. text fields in MenuItem or plain Label fields.
  • Method Details

    • getName

      String getName()
      Returns:
      A name to be used in user interface dialogs.
    • getPredicate

      Predicate<String> getPredicate()
      Returns:
      The Predicate to match a specific file type or a group of file types.
    • matches

      default boolean matches(String pathName)
      Parameters:
      pathName - Path to test
      Returns:
      true in case the given Path matches with the Predicate.
    • matches

      default boolean matches(File file)
      Parameters:
      file - File
      Returns:
      true in case the given File matches with the Predicate.
    • combine

      default PathFilter combine(PathFilter other)
      Creates a new PathFilter as a combination of the this one and any other.
      Parameters:
      other - PathFilter to be combined with this one
      Returns:
      PathFilter where this ones Predicate and the others PathFilter Predicate are combined using a logical OR.
    • acceptAllFiles

      static PathFilter acceptAllFiles()
      Creates a new PathFilter which generally matches with all files and is named *.*. This filter is intended to be used as graceful default for cases where no path filters are provided.
      Returns:
      PathFilter
    • acceptAllFiles

      static PathFilter acceptAllFiles(String name)
      Creates a new PathFilter which generally matches with all files.
      Parameters:
      name - String value intended to be used as GUI text.
      Returns:
      PathFilter
    • create

      static PathFilter create(Predicate<String> p)
    • create

      static PathFilter create(String label, Predicate<String> p)
    • forFileExtension

      static PathFilter forFileExtension(String extension)
      Creates a new PathFilter for file name extensions such as (.html, .xls, .xml or .pdf). The label text will be automatically the extension with a "*." prefix so for extension txt the label will be *.txt.
      Parameters:
      extension - String the file name extension
      Returns:
      new PathFilter
    • forFileExtension

      static PathFilter forFileExtension(String label, String extension)
      Creates a new PathFilter for file name extensions such as (.html, .xls, .xml or .pdf).
      Parameters:
      label - GUI label text
      extension - String the file name extension
      Returns:
      new PathFilter