public class MimeType extends java.lang.Object implements java.lang.Comparable<MimeType>, java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
MimeType.SpecificityComparator<T extends MimeType> |
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
WILDCARD_TYPE |
| Constructor and Description |
|---|
MimeType(MimeType other,
java.nio.charset.Charset charset)
Copy-constructor that copies the type, subtype, parameters of the given
Mime, and allows to set the
specified character set. |
MimeType(MimeType other,
java.util.Map<java.lang.String,java.lang.String> parameters)
Copy-constructor that copies the type and subtype of the given
Mime, and allows for different parameter. |
MimeType(java.lang.String type)
Create a new
Mime for the given primary type. |
MimeType(java.lang.String type,
java.lang.String subtype)
Create a new
Mime for the given primary type and subtype. |
MimeType(java.lang.String type,
java.lang.String subtype,
java.nio.charset.Charset charset)
Create a new
Mime for the given type, subtype, and character set. |
MimeType(java.lang.String type,
java.lang.String subtype,
java.util.Map<java.lang.String,java.lang.String> parameters)
Create a new
Mime for the given type, subtype, and parameters. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
appendTo(java.lang.StringBuilder builder) |
protected void |
checkParameters(java.lang.String attribute,
java.lang.String value) |
int |
compareTo(MimeType other)
Compares this
MediaType to another alphabetically. |
boolean |
equals(java.lang.Object other) |
boolean |
equalsExcludeParameter(java.lang.Object other) |
java.nio.charset.Charset |
getCharset()
Return the character set, as indicated by a charset parameter, if any.
|
java.lang.String |
getParameter(java.lang.String name)
Return a generic parameter value, given a parameter name.
|
java.util.Map<java.lang.String,java.lang.String> |
getParameters()
Return all generic parameter values.
|
java.lang.String |
getSubtype()
Return the subtype.
|
java.lang.String |
getType()
Return the primary type.
|
int |
hashCode() |
boolean |
includes(MimeType other)
Indicate whether this
MediaType includes the given media type. |
boolean |
isCompatibleWith(MimeType other)
Indicate whether this
MediaType is compatible with the given media type. |
boolean |
isConcrete()
Indicates whether this media type is concrete, i.e.
|
boolean |
isWildcardSubtype()
Indicates whether the subtype is the wildcard character
* or the
wildcard character followed by a suffix (e.g. |
boolean |
isWildcardType()
Indicates whether the type is the wildcard character
* or not. |
java.lang.String |
toString() |
static java.lang.String |
toString(java.util.Collection<? extends MimeType> mimeTypes)
Return a string representation of the given list of
Mime objects. |
protected java.lang.String |
unquote(java.lang.String s) |
static MimeType |
valueOf(java.lang.String mimeType)
Parse the given string value into a
Mime object. |
protected static final java.lang.String WILDCARD_TYPE
public MimeType(java.lang.String type)
Mime for the given primary type.
The subtype is set to "*", and the parameters are empty.
type - the primary type.java.lang.IllegalArgumentException - if any of the parameters contains illegal characters.public MimeType(java.lang.String type,
java.lang.String subtype)
Mime for the given primary type and subtype.
The parameters are empty.
type - the primary type.subtype - the subtype.java.lang.IllegalArgumentException - if any of the parameters contains illegal characterspublic MimeType(java.lang.String type,
java.lang.String subtype,
java.nio.charset.Charset charset)
Mime for the given type, subtype, and character set.type - the primary type.subtype - the subtype.charset - the character set.java.lang.IllegalArgumentException - if any of the parameters contains illegal characters.public MimeType(MimeType other, java.nio.charset.Charset charset)
Mime, and allows to set the
specified character set.other - the other media type.charset - the character set.java.lang.IllegalArgumentException - if any of the parameters contains illegal characters.public MimeType(MimeType other, java.util.Map<java.lang.String,java.lang.String> parameters)
Mime, and allows for different parameter.other - the other media type.parameters - the parameters, may be null.java.lang.IllegalArgumentException - if any of the parameters contains illegal characters.public MimeType(java.lang.String type,
java.lang.String subtype,
java.util.Map<java.lang.String,java.lang.String> parameters)
Mime for the given type, subtype, and parameters.type - the primary type.subtype - the subtype.parameters - the parameters, may be null.java.lang.IllegalArgumentException - if any of the parameters contains illegal characters.protected void checkParameters(java.lang.String attribute,
java.lang.String value)
protected java.lang.String unquote(java.lang.String s)
public boolean isWildcardType()
* or not.public boolean isWildcardSubtype()
* or the
wildcard character followed by a suffix (e.g. *+xml).public boolean isConcrete()
*.public java.lang.String getType()
public java.lang.String getSubtype()
public java.nio.charset.Charset getCharset()
public java.lang.String getParameter(java.lang.String name)
name - the parameter name.null if not present.public java.util.Map<java.lang.String,java.lang.String> getParameters()
public boolean includes(MimeType other)
MediaType includes the given media type.
For instance, text/* includes text/plain and text/html, and application/*+xml
includes application/soap+xml, etc. This method is not symmetric.
other - the reference media type with which to compare.public boolean isCompatibleWith(MimeType other)
MediaType is compatible with the given media type.
For instance, text/* is compatible with text/plain, text/html, and vice versa. In
effect, this method is similar to includes(com.yanzhenjie.andserver.util.MimeType), except that it is symmetric.
other - the reference media type with which to compare.public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic boolean equalsExcludeParameter(java.lang.Object other)
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectprotected void appendTo(java.lang.StringBuilder builder)
public int compareTo(MimeType other)
MediaType to another alphabetically.compareTo in interface java.lang.Comparable<MimeType>other - media type to compare to.public static MimeType valueOf(java.lang.String mimeType)
Mime object.public static java.lang.String toString(java.util.Collection<? extends MimeType> mimeTypes)
Mime objects.mimeTypes - the string to parse.java.lang.IllegalArgumentException - if the String cannot be parsed.