Enum MimeType

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

    public enum MimeType
    extends java.lang.Enum<MimeType>
    Definition and convenience methods for common MIME types according to RFC6838 and RFC4855

    Since the official list is rather and contains types we likely never encounter, we chose the specific sub-selection from: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

    Author:
    rstein
    • Method Detail

      • values

        public static MimeType[] 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 (MimeType c : MimeType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MimeType 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
      • getFileEndings

        public java.util.List<java.lang.String> getFileEndings()
        Returns:
        the commonly defined file-endings for the given MIME type
      • getSubType

        public java.lang.String getSubType()
        Returns:
        the specific media sub-type, such as "plain" or "png", "mpeg", "mp4" or "xml".
      • getType

        public MimeType.Type getType()
        Returns:
        the high-level media type, such as "text", "image", "audio", "video", or "application".
      • isImageData

        public boolean isImageData()
      • isNonDisplayableData

        public boolean isNonDisplayableData()
      • isTextData

        public boolean isTextData()
      • isVideoData

        public boolean isVideoData()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<MimeType>
      • getDescription

        public java.lang.String getDescription()
        Returns:
        human-readable description of the format
      • getEnum

        public static MimeType getEnum​(java.lang.String mimeType)
        Case-insensitive mapping between MIME-type string and enumumeration value.
        Parameters:
        mimeType - the string equivalent mime-type, e.g. "image/png"
        Returns:
        the enumeration equivalent mime-type, e.g. MimeType.PNG or MimeType.UNKNOWN as fall-back
      • getEnumByFileName

        public static MimeType getEnumByFileName​(java.lang.String fileName)
        Case-insensitive mapping between MIME-type string and enumeration value.
        Parameters:
        fileName - the string equivalent mime-type, e.g. "image/png"
        Returns:
        the enumeration equivalent mime-type, e.g. MimeType.PNG or MimeType.UNKNOWN as fall-back