Enum ImageType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ImageType>

    public enum ImageType
    extends java.lang.Enum<ImageType>
    The image selected by a user type enumeration. The APNG, JPEG2000 and HEIC/HEIF image file formats are not supported.
    Author:
    Christopher Mindus
    • Enum Constant Summary

      Enum Constants 
      Enum ConstantDescription
      ALL_IMAGES
      The ALL_IMAGES image type has the media type "image/*", and the file extension set to "*".
      BMP
      BMP: "image/bmp", extension ".bmp".
      GIF
      GIF: "image/gif", extension ".gif".
      JPEG
      JPEG: "image/jpeg", extensions ".jpg,.jpeg,.jpe,.jif,.jfif,.jfi".
      PNG
      PNG: "image/png", extension ".png" (no support for "Animated PNG" a.k.a.
      TIFF
      TIFF: "image/tiff", extensions ".tif,.tiff".
      UNKNOWN
      Unknown or currently unsupported image type, Strings for media type and extension are null.
      WBMP
      WBMP: "image/vnd.wap.wbmp", extension ".wbmp".
      WEBP
      WebP: "media/webp", extension ".webp".
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      java.lang.Stringextensions
      The common file extensions for this image media type, in lower case.
      java.util.Set<java.lang.String>extensionsNoDot
      The file extensions without leading "dot" as an unmodifiable collection.
      java.lang.StringfirstExtension
      The first and most common file extension starting with '.' if not ALL_IMAGES otherwise '*' for {link #ALL_IMAGES} or null for UNKNOWN.
      booleanisValidExtension
      Flag for defined image type, i.e.
      java.lang.StringmediaType
      The media type, or null for {@link #UNKNOWN}.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static ImageTypefromExtension​(java.lang.String extension)
      Finds the image type for a file extension.
      static ImageTypefromMediaType​(java.lang.String mediaType)
      Finds the image type from the "image/..." string.
      static ImageTypevalueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ImageType[]values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • UNKNOWN

        public static final ImageType UNKNOWN
        Unknown or currently unsupported image type, Strings for media type and extension are null.
      • ALL_IMAGES

        public static final ImageType ALL_IMAGES
        The ALL_IMAGES image type has the media type "image/*", and the file extension set to "*".
      • PNG

        public static final ImageType PNG
        PNG: "image/png", extension ".png" (no support for "Animated PNG" a.k.a. "APNG" with file extension ".apng").
      • JPEG

        public static final ImageType JPEG
        JPEG: "image/jpeg", extensions ".jpg,.jpeg,.jpe,.jif,.jfif,.jfi".
      • GIF

        public static final ImageType GIF
        GIF: "image/gif", extension ".gif".
      • WEBP

        public static final ImageType WEBP
        WebP: "media/webp", extension ".webp".
      • TIFF

        public static final ImageType TIFF
        TIFF: "image/tiff", extensions ".tif,.tiff".
      • BMP

        public static final ImageType BMP
        BMP: "image/bmp", extension ".bmp".
      • WBMP

        public static final ImageType WBMP
        WBMP: "image/vnd.wap.wbmp", extension ".wbmp".
    • Field Detail

      • isValidExtension

        public final boolean isValidExtension
        Flag for defined image type, i.e. not {@link #UNKNOWN} or {@link #ALL_IMAGES}.
      • mediaType

        public final java.lang.String mediaType
        The media type, or null for {@link #UNKNOWN}.
      • extensions

        public final java.lang.String extensions
        The common file extensions for this image media type, in lower case.

        It is a comma separated string of file extensions, including the "dot".

        It is "*" for {@link #ALL_IMAGES} image media type.

        It is null for {@link #UNKNOWN} image media type.

      • firstExtension

        public final java.lang.String firstExtension
        The first and most common file extension starting with '.' if not ALL_IMAGES otherwise '*' for {link #ALL_IMAGES} or null for UNKNOWN.
      • extensionsNoDot

        public final java.util.Set<java.lang.String> extensionsNoDot
        The file extensions without leading "dot" as an unmodifiable collection. Note: the ordering of the original extensions is kept.
    • Method Detail

      • values

        public static ImageType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ImageType c : ImageType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ImageType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • fromExtension

        public static ImageType fromExtension​(java.lang.String extension)
        Finds the image type for a file extension.
        Parameters:
        extension - File extension with or without a dot, case insensitive.
        Returns:
        The media type, or null if not found. Note that {@link #ALL_IMAGES} is returned if the extension is equal to "*" (asterisk) or ".*" (dot-asterisk).
      • fromMediaType

        public static ImageType fromMediaType​(java.lang.String mediaType)
        Finds the image type from the "image/..." string.
        Parameters:
        mediaType - The media type (case sensitive).
        Returns:
        The media type, or null if not found. Note that {@link #ALL_IMAGES} is returned if the mediaType is equal to "image/*".