Class MimeType
java.lang.Object
de.digitalcollections.model.api.identifiable.resource.MimeType
public class MimeType
extends java.lang.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
Modifier and Type Method Description booleanequals(java.lang.Object obj)static MimeTypefromExtension(java.lang.String ext)Determine MIME type for the given file extensionstatic MimeTypefromFilename(java.lang.String filename)Determine MIME type from filename string.static MimeTypefromTypename(java.lang.String typeName)Given an existing MIME type name, look up the corresponding instance.static MimeTypefromURI(java.net.URI uri)Determine MIME type from URI.java.util.List<java.lang.String>getExtensions()Get the known file extensions for the MIME typejava.lang.StringgetPrimaryType()java.lang.StringgetSubType()java.lang.StringgetSuffix()java.lang.StringgetTypeName()Get the MIME type's name (e.g."inthashCode()booleanmatches(java.lang.Object other)Check if the MIME type "matches" another MIME type.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
MIME_WILDCARD
Convenience definitions for commonly used MIME types -
MIME_IMAGE
-
MIME_APPLICATION_JSON
-
MIME_APPLICATION_OCTET_STREAM
-
MIME_APPLICATION_XML
-
MIME_IMAGE_JPEG
-
MIME_IMAGE_TIF
-
MIME_IMAGE_PNG
-
MIME_TYPE_MARKDOWN
-
-
Method Details
-
fromExtension
Determine MIME type for the given file extension- Parameters:
ext- file extension- Returns:
- corresponding MimeType
-
fromFilename
Determine MIME type from filename string. Returns null if no matching MIME type was found.- Parameters:
filename- filename including extension- Returns:
- corresponding MimeType
-
fromURI
Determine MIME type from URI.- Parameters:
uri- uri including filename with extension- Returns:
- corresponding MimeType
-
fromTypename
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 java.lang.String getTypeName()Get the MIME type's name (e.g."application/json")- Returns:
- the MimeType's type name as String
-
getExtensions
public java.util.List<java.lang.String> getExtensions()Get the known file extensions for the MIME type- Returns:
- List of known file extensions for given MiemType
-
getPrimaryType
public java.lang.String getPrimaryType() -
getSubType
public java.lang.String getSubType() -
getSuffix
public java.lang.String getSuffix() -
matches
public boolean matches(java.lang.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
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-