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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionall()Alias ofFormatRegistry.allFormats().intCompares by case-insensitive name.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theextensionsrecord component.static FormatAlias ofFormatRegistry.formatWithKey(String).final inthashCode()Returns a hash code value for this object.static FormatinferFormat(Identifier identifier) Attempts to infer a format from the given identifier.static FormatinferFormat(String pathname) Attempts to infer a format from the given pathname.booleanisRaster()Returns the value of theisRasterrecord component.booleanisVideo()Returns the value of theisVideorecord component.key()Returns the value of thekeyrecord component.Returns the value of themediaTypesrecord component.name()Returns the value of thenamerecord component.booleanReturns the value of thesupportsTransparencyrecord component.toString()Returns a string representation of this record class.static FormatwithExtension(String extension)
-
Field Details
-
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 aFormatrecord class.- Parameters:
key- the value for thekeyrecord componentname- the value for thenamerecord componentmediaTypes- the value for themediaTypesrecord componentextensions- the value for theextensionsrecord componentisRaster- the value for theisRasterrecord componentisVideo- the value for theisVideorecord componentsupportsTransparency- the value for thesupportsTransparencyrecord component
-
-
Method Details
-
all
Alias ofFormatRegistry.allFormats().- Returns:
- All registered formats.
-
get
Alias ofFormatRegistry.formatWithKey(String).- Parameters:
key- One of the keys in formats.yml.- Returns:
- Instance corresponding to the given argument, or
nullif no such format exists.
-
inferFormat
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,
UNKNOWNis returned.
-
inferFormat
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,
UNKNOWNis returned.
-
withExtension
-
compareTo
Compares by case-insensitive name.- Specified by:
compareToin interfaceComparable<Format>
-
getPreferredExtension
- Returns:
- The most appropriate extension for the format.
-
getPreferredMediaType
- Returns:
- The most appropriate media type for the format.
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
key
-
name
-
mediaTypes
Returns the value of themediaTypesrecord component.- Returns:
- the value of the
mediaTypesrecord component
-
extensions
Returns the value of theextensionsrecord component.- Returns:
- the value of the
extensionsrecord component
-
isRaster
-
isVideo
-
supportsTransparency
public boolean supportsTransparency()Returns the value of thesupportsTransparencyrecord component.- Returns:
- the value of the
supportsTransparencyrecord component
-