Package org.scijava.ui.dnd
Class MIMEType
- java.lang.Object
-
- org.scijava.ui.dnd.MIMEType
-
public class MIMEType extends Object
A Multipurpose Internet Mail Extension (MIME) type, as defined in RFC 2045 and 2046.This class is similar to e.g.
java.awt.datatransfer.MimeTypeandorg.apache.pivot.util.MIMEType. We reinvent the wheel here since there is no public MIME type class in core Java excluding AWT, which we could use cross-environment in e.g. Android.- Author:
- Curtis Rueden
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)StringgetBase()Gets the MIME type with no parameter list.StringgetParameter(String name)Gets the value of the parameter with the given name, or null if none.List<String>getParameters()Gets the parameter names associated with this MIME type.inthashCode()booleanisCompatible(Class<?> javaType)Gets whether this MIME type represents objects of the given Java class.booleanisCompatible(MIMEType mimeType)Gets whether this MIME type is compatible with the given one.StringtoString()
-
-
-
Constructor Detail
-
MIMEType
public MIMEType(String mimeType)
Constructs a new MIME type object from the given MIME type string.- Parameters:
mimeType- The MIME type string, which may optionally include a list of semicolon-separated parameters.
-
MIMEType
public MIMEType(String mimeType, Class<?> javaType)
Constructs a new MIME type object from the given MIME type string.- Parameters:
mimeType- The MIME type string, which may optionally include a list of semicolon-separated parameters.javaType- The associated Java class of the MIME type. If non-null, a "class" parameter is guaranteed to exist with the MIME type indicating compatibility with the given Java class.- Throws:
IllegalArgumentException- if themimeTypeincludes a different Java class parameter than thejavaType.
-
-
Method Detail
-
getBase
public String getBase()
Gets the MIME type with no parameter list.
-
getParameter
public String getParameter(String name)
Gets the value of the parameter with the given name, or null if none.
-
getParameters
public List<String> getParameters()
Gets the parameter names associated with this MIME type.
-
isCompatible
public boolean isCompatible(MIMEType mimeType)
Gets whether this MIME type is compatible with the given one. Being "compatible" means that the base types match, and that the given MIME type has the same parameters with the same values as this one does (although the given MIME type may also have additional parameters not present in this one).
-
isCompatible
public boolean isCompatible(Class<?> javaType)
Gets whether this MIME type represents objects of the given Java class.
-
-