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 MimeType
MIME_APPLICATION_JSON
static MimeType
MIME_APPLICATION_OCTET_STREAM
static MimeType
MIME_APPLICATION_XML
static MimeType
MIME_IMAGE
static MimeType
MIME_IMAGE_JPEG
static MimeType
MIME_IMAGE_PNG
static MimeType
MIME_IMAGE_TIF
static MimeType
MIME_TYPE_MARKDOWN
static MimeType
MIME_WILDCARD
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
static MimeType
fromExtension(String ext)
Determine MIME type for the given file extensionstatic MimeType
fromFilename(String filename)
Determine MIME type from filename string.static MimeType
fromTypename(String typeName)
Given an existing MIME type name, look up the corresponding instance.static MimeType
fromURI(URI uri)
Determine MIME type from URI.List<String>
getExtensions()
Get the known file extensions for the MIME typeString
getPrimaryType()
String
getSubType()
String
getSuffix()
String
getTypeName()
Get the MIME type's name (e.g."application/json")int
hashCode()
boolean
matches(Object other)
Check if the MIME type "matches" another MIME type.String
toString()
-
-
-
Field Detail
-
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
public static final MimeType MIME_IMAGE
-
MIME_IMAGE_JPEG
public static final MimeType MIME_IMAGE_JPEG
-
MIME_IMAGE_PNG
public static final MimeType MIME_IMAGE_PNG
-
MIME_IMAGE_TIF
public static final MimeType MIME_IMAGE_TIF
-
MIME_TYPE_MARKDOWN
public static final MimeType MIME_TYPE_MARKDOWN
-
MIME_WILDCARD
public static final MimeType MIME_WILDCARD
-
-
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
-
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
-
fromURI
public static MimeType fromURI(URI uri)
Determine MIME type from URI.- Parameters:
uri
- uri including filename with extension- Returns:
- corresponding MimeType
-
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()
-
getTypeName
public String getTypeName()
Get the MIME type's name (e.g."application/json")- Returns:
- the MimeType's type name as String
-
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
-
-