Package de.digitalcollections.model.file
Class MimeType
- java.lang.Object
-
- de.digitalcollections.model.file.MimeType
-
public class MimeType extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static MimeTypeMIME_APPLICATION_JSONstatic MimeTypeMIME_APPLICATION_OCTET_STREAMstatic MimeTypeMIME_APPLICATION_XMLstatic MimeTypeMIME_IMAGEstatic MimeTypeMIME_IMAGE_JPEGstatic MimeTypeMIME_IMAGE_PNGstatic MimeTypeMIME_IMAGE_TIFstatic MimeTypeMIME_TYPE_MARKDOWNstatic MimeTypeMIME_WILDCARDConvenience definitions for commonly used MIME types
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static MimeTypefromExtension(String ext)Determine MIME type for the given file extensionstatic MimeTypefromFilename(String filename)Determine MIME type from filename string.static MimeTypefromTypename(String typeName)Given an existing MIME type name, look up the corresponding instance.static MimeTypefromURI(URI uri)Determine MIME type from URI.List<String>getExtensions()Get the known file extensions for the MIME typeStringgetPrimaryType()StringgetSubType()StringgetSuffix()StringgetTypeName()Get the MIME type's name (e.g."inthashCode()booleanmatches(Object other)Check if the MIME type "matches" another MIME type.StringtoString()
-
-
-
Field Detail
-
MIME_WILDCARD
public static final MimeType MIME_WILDCARD
Convenience definitions for commonly used MIME types
-
MIME_IMAGE
public static final MimeType MIME_IMAGE
-
MIME_APPLICATION_JSON
public static final MimeType MIME_APPLICATION_JSON
-
MIME_APPLICATION_OCTET_STREAM
public static final MimeType MIME_APPLICATION_OCTET_STREAM
-
MIME_APPLICATION_XML
public static final MimeType MIME_APPLICATION_XML
-
MIME_IMAGE_JPEG
public static final MimeType MIME_IMAGE_JPEG
-
MIME_IMAGE_TIF
public static final MimeType MIME_IMAGE_TIF
-
MIME_IMAGE_PNG
public static final MimeType MIME_IMAGE_PNG
-
MIME_TYPE_MARKDOWN
public static final MimeType MIME_TYPE_MARKDOWN
-
-
Method Detail
-
fromExtension
public static MimeType fromExtension(String ext)
Determine MIME type for the given file extension- Parameters:
ext- file extension- Returns:
- corresponding MimeType
-
fromFilename
public static MimeType fromFilename(String filename)
Determine MIME type from filename string. Returns null if no matching MIME type was found.- Parameters:
filename- filename including extension- Returns:
- corresponding MimeType
-
fromURI
public static MimeType fromURI(URI uri)
Determine MIME type from URI.- Parameters:
uri- uri including filename with extension- Returns:
- corresponding MimeType
-
fromTypename
public static MimeType fromTypename(String typeName)
Given an existing MIME type name, look up the corresponding instance. An exception is made for vendor-specific types or non-standard types.- Parameters:
typeName- mimetype name as String, e.g. "image/jpeg"- Returns:
- corresponding MimeType
-
getTypeName
public String getTypeName()
Get the MIME type's name (e.g."application/json")- Returns:
- the MimeType's type name as String
-
getExtensions
public List<String> getExtensions()
Get the known file extensions for the MIME type- Returns:
- List of known file extensions for given MiemType
-
getPrimaryType
public String getPrimaryType()
-
getSubType
public String getSubType()
-
getSuffix
public String getSuffix()
-
matches
public boolean matches(Object other)
Check if the MIME type "matches" another MIME type.- Parameters:
other- Other MIME type to compare against- Returns:
- Whether the other type matches this type
-
-