Interface FileFormat

All Known Implementing Classes:
ImageFileFormat, NonImageFileFormat

public interface FileFormat
A file-format that is read or written to the filesystem.
Author:
Owen Feehan
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Builds a path which has an existing path but missing an extension.
    default String
    buildPath(String directory, String filenameWithoutExtension)
    Builds a path with a directory and filename component.
    default Path
    Builds a path which has an existing path but missing an extension.
    default Path
    buildPath(Path directory, String filenameWithoutExtension)
    Builds a path with a directory and filename component.
    An identifier that describes the format, that is meaningful to the end-user.
    The default extension to write associated with a particular format.
    boolean
    matches(String filePath)
    Does a file-path (or file-name) end with an extension expected by this format?
    default boolean
    matches(Path filePath)
    Does a filePath (or fileName) have an extension expected by this format?
    boolean
    Does an identifier equal the extension expected by this format?
  • Method Details

    • matches

      default boolean matches(Path filePath)
      Does a filePath (or fileName) have an extension expected by this format?

      The case of the extension is irrelevant i.e. a case insensitive match occurs.

      Parameters:
      filePath - the path
      Returns:
      true if the path ends with any of the expected extensions for this format.
    • matches

      boolean matches(String filePath)
      Does a file-path (or file-name) end with an extension expected by this format?

      The case of the extension is irrelevant i.e. a case insensitive match occurs.

      A leading period is also expected before the extension.

      Parameters:
      filePath - the path
      Returns:
      true if the path ends with any of the expected extensions for this format.
    • matchesIdentifier

      boolean matchesIdentifier(String identifier)
      Does an identifier equal the extension expected by this format?
      Parameters:
      identifier - an identifier that should be equal (ignoring case, and with or without a leading period) to any extension associated with the format
      Returns:
      true if identifier is equal to an extension associated with this format
    • descriptiveIdentifier

      String descriptiveIdentifier()
      An identifier that describes the format, that is meaningful to the end-user.
      Returns:
      a short string that identifies the format (usually the default extension without any leading period).
    • getDefaultExtension

      String getDefaultExtension()
      The default extension to write associated with a particular format.
      Returns:
      the extension
    • buildPath

      default String buildPath(String path)
      Builds a path which has an existing path but missing an extension.
      Parameters:
      path - the path
      Returns:
      the path with an extension appended.
    • buildPath

      default Path buildPath(Path path)
      Builds a path which has an existing path but missing an extension.
      Parameters:
      path - the path
      Returns:
      the path with an extension appended.
    • buildPath

      default Path buildPath(Path directory, String filenameWithoutExtension)
      Builds a path with a directory and filename component.
      Parameters:
      directory - the directory
      filenameWithoutExtension - a filename that resides in the directory (without any extension or the period preceding an extension)
      Returns:
      a path that combines the directory and filenameWithoutExtension and the extension.
    • buildPath

      default String buildPath(String directory, String filenameWithoutExtension)
      Builds a path with a directory and filename component.
      Parameters:
      directory - the directory
      filenameWithoutExtension - a filename that resides in the directory (without any extension or the period preceding an extension)
      Returns:
      a string representing a path that combines the directory and filenameWithoutExtension and the extension.