Record Class Format

java.lang.Object
java.lang.Record
is.galia.image.Format
Record Components:
key - Unique format key, used internally to identify formats but not relevant outside of the application.
name - Human-readable name.
mediaTypes - All media types associated with this format, in descending preference order.
extensions - All extensions associated with this format, in descending preference order.
isRaster - Whether the format is raster (pixel-based still image).
isVideo - Whether the format is video (moving image).
supportsTransparency - Whether the format supports transparency.
All Implemented Interfaces:
Comparable<Format>

public record Format(String key, String name, List<MediaType> mediaTypes, List<String> extensions, boolean isRaster, boolean isVideo, boolean supportsTransparency) extends Record implements Comparable<Format>
File format.
  • Field Details

    • UNKNOWN

      public static final Format UNKNOWN
      Represents an unknown format.
  • Constructor Details

    • Format

      public Format(String key, String name, List<MediaType> mediaTypes, List<String> extensions, boolean isRaster, boolean isVideo, boolean supportsTransparency)
      Creates an instance of a Format record class.
      Parameters:
      key - the value for the key record component
      name - the value for the name record component
      mediaTypes - the value for the mediaTypes record component
      extensions - the value for the extensions record component
      isRaster - the value for the isRaster record component
      isVideo - the value for the isVideo record component
      supportsTransparency - the value for the supportsTransparency record component
  • Method Details

    • all

      public static Set<Format> all()
      Returns:
      All registered formats.
    • get

      public static Format get(String key)
      Parameters:
      key - One of the keys in formats.yml.
      Returns:
      Instance corresponding to the given argument, or null if no such format exists.
    • inferFormat

      public static Format inferFormat(Identifier identifier)

      Attempts to infer a format from the given identifier.

      It is usually more reliable (but also maybe more expensive) to obtain this information from Source.getFormatIterator().

      Parameters:
      identifier -
      Returns:
      The source format corresponding to the given identifier, assuming that its value will have a recognizable filename extension. If not, UNKNOWN is returned.
    • inferFormat

      public static Format inferFormat(String pathname)

      Attempts to infer a format from the given pathname.

      It is usually more reliable (but also maybe more expensive) to obtain this information from Source.getFormatIterator().

      Parameters:
      pathname - Full pathname of an image file.
      Returns:
      The source format corresponding to the given identifier, assuming that its value will have a recognizable filename extension. If not, UNKNOWN is returned.
    • withExtension

      public static Format withExtension(String extension)
      Returns:
      Format in the registry with the given extension.
    • compareTo

      public int compareTo(Format o)
      Compares by case-insensitive name.
      Specified by:
      compareTo in interface Comparable<Format>
    • getPreferredExtension

      public String getPreferredExtension()
      Returns:
      The most appropriate extension for the format.
    • getPreferredMediaType

      public MediaType getPreferredMediaType()
      Returns:
      The most appropriate media type for the format.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • mediaTypes

      public List<MediaType> mediaTypes()
      Returns the value of the mediaTypes record component.
      Returns:
      the value of the mediaTypes record component
    • extensions

      public List<String> extensions()
      Returns the value of the extensions record component.
      Returns:
      the value of the extensions record component
    • isRaster

      public boolean isRaster()
      Returns the value of the isRaster record component.
      Returns:
      the value of the isRaster record component
    • isVideo

      public boolean isVideo()
      Returns the value of the isVideo record component.
      Returns:
      the value of the isVideo record component
    • supportsTransparency

      public boolean supportsTransparency()
      Returns the value of the supportsTransparency record component.
      Returns:
      the value of the supportsTransparency record component