public final class MimeMap extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MimeMap.Builder
A builder for mapping of MIME types to extensions and back.
|
| Modifier and Type | Method and Description |
|---|---|
static MimeMap.Builder |
builder()
Creates a MIME type map builder.
|
MimeMap.Builder |
buildUpon()
Creates a MIME type map builder with values based on
this instance. |
boolean |
equals(Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
Set<String> |
extensions()
Returns the set of extensions that this
MimeMap
maps to some MIME type. |
static MimeMap |
getDefault()
Gets system's current default
MimeMap |
String |
guessExtensionFromMimeType(String mimeType)
Returns the registered extension for the given case insensitive MIME type.
|
String |
guessMimeTypeFromExtension(String extension)
Returns the MIME type for the given case insensitive file extension, or null
if the extension isn't mapped to any.
|
boolean |
hasExtension(String extension)
Returns whether the given case insensitive extension has a registered MIME type.
|
int |
hashCode()
Returns an integer hash code for this object.
|
boolean |
hasMimeType(String mimeType)
Returns whether given case insensetive MIME type is mapped to a file extension.
|
Set<String> |
mimeTypes()
Returns the set of MIME types that this
MimeMap
maps to some extension. |
static void |
setDefaultSupplier(Supplier<MimeMap> mimeMapSupplier)
Sets the
Supplier of the default MimeMap
instance to be used from now on. |
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
@NonNull public static MimeMap.Builder builder()
MimeMap.Builder@NonNull public MimeMap.Builder buildUpon()
this instance.
This builder will contain all previously added MIMEs and extensions.MimeMap.Builder@NonNull public static MimeMap getDefault()
MimeMapMimeMap.public static void setDefaultSupplier(@NonNull Supplier<MimeMap> mimeMapSupplier)
Supplier of the default MimeMap
instance to be used from now on.
mimeMapSupplier.get() will be invoked only the first time that
getDefault() is called after this method call; that
MimeMap instance is memoized such that subsequent calls to
getDefault() without an intervening call to
setDefaultSupplier(Supplier) will return that same instance
without consulting mimeMapSupplier a second time.public final boolean hasExtension(@Nullable String extension)
extension - A file extension without the leading '.'@Nullable public final String guessMimeTypeFromExtension(@Nullable String extension)
extension - A file extension without the leading '.'public final boolean hasMimeType(@Nullable String mimeType)
mimeType - A MIME type (i.e. {@code "text/plain")mapped to a file extension.@Nullable public final String guessExtensionFromMimeType(@Nullable String mimeType)
mimeType - A MIME type (i.e. text/plain)@NonNull public Set<String> mimeTypes()
MimeMap
maps to some extension. Note that the
reverse mapping might not exist.Set of MIME types mapped to some extension@NonNull public Set<String> extensions()
MimeMap
maps to some MIME type. Note that the
reverse mapping might not exist.public int hashCode()
ObjectObject.equals(java.lang.Object) returns true must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode method
if you intend implementing your own hashCode method.
hashCode in class ObjectObject.equals(java.lang.Object)public boolean equals(Object obj)
Objecto must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true only if this ==
o. See Writing a correct
equals method
if you intend implementing your own equals method.
The general contract for the equals and Object.hashCode() methods is that if equals returns true for
any two objects, then hashCode() must return the same value for
these objects. This means that subclasses of Object usually
override either both methods or neither of them.
equals in class Objectobj - the object to compare this instance with.true if the specified object is equal to this Object; false otherwise.Object.hashCode()public String toString()
ObjectgetClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString method
if you intend implementing your own toString method.