类 MimeType
- 所有已实现的接口:
Serializable,Comparable<MimeType>
This class, however, does not contain support for the q-parameters used in
HTTP content negotiation. Those can be found in the subclass
MediaType in the today-web module.
Consists of a type and a subtype. Also has functionality to parse MIME Type values from a
String using valueOf(String). For more parsing options see
MimeTypeUtils.
- 从以下版本开始:
- 2.1.7 2019-12-08 19:08
- 作者:
- Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev, Sam Brannen, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明static classMimeType.SpecificityComparator<T extends MimeType>Comparator to sortMimeTypesin order of specificity. -
字段概要
字段 -
构造器概要
构造器限定符构造器说明protectedCopy-constructor that copies the type, subtype and parameters of the givenMimeType, skipping checks performed in other constructors.Copy-constructor that copies the type, subtype, parameters of the givenMimeType, and allows to set the specified character set.Copy-constructor that copies the type and subtype of the givenMimeType, and allows for different parameter.Create a newMimeTypefor the given primary type.Create a newMimeTypefor the given primary type and subtype.Create a newMimeTypefor the given type, subtype, and character set.Create a newMimeTypefor the given type, subtype, and parameters. -
方法概要
修饰符和类型方法说明addCharsetParameter(Charset charset, Map<String, String> parameters) protected voidappendTo(StringBuilder builder) private voidappendTo(Map<String, String> map, StringBuilder builder) protected voidcheckParameters(String attribute, String value) private static voidcheckToken(String token) Checks the given token string for illegal characters, as defined in RFC 2616, section 2.2.intCompares this MIME Type to another alphabetically.booleanbooleanequalsTypeAndSubtype(MimeType other) Similar toequals(Object)but based on the type and subtype only, i.e. ignoring parameters.Return the character set, as indicated by acharsetparameter, if any.getParameter(String name) Return a generic parameter value, given a parameter name.Return all generic parameter values.Return the subtype.Return the subtype suffix as defined in RFC 6839.getType()Return the primary type.inthashCode()booleanIndicate whether this MIME Type includes the given MIME Type.booleanisCompatibleWith(MimeType other) Indicate whether this MIME Type is compatible with the given MIME Type.booleanIndicates whether this MIME Type is concrete, i.e. whether neither the type nor the subtype is a wildcard character*.booleanisLessSpecific(MimeType other) Indicates whether thisMimeTypeis more less than the given type.booleanisMoreSpecific(MimeType other) Indicates whether thisMimeTypeis more specific than the given type.booleanisPresentIn(Collection<? extends MimeType> mimeTypes) UnlikeCollection.contains(Object)which relies onequals(Object), this method only checks the type and the subtype, but otherwise ignores parameters.private booleanbooleanIndicates whether the subtype is the wildcard character*or the wildcard character followed by a suffix (e.g.booleanIndicates whether the type is the wildcard character*or not.private booleanparametersAreEqual(MimeType other) Determine if the parameters in thisMimeTypeand the suppliedMimeTypeare equal, performing case-insensitive comparisons forCharsets.private voidtoString()protected Stringstatic MimeType
-
字段详细资料
-
构造器详细资料
-
MimeType
Create a newMimeTypefor the given primary type.The subtype is set to
"*", and the parameters are empty.- 参数:
type- the primary type- 抛出:
IllegalArgumentException- if any of the parameters contains illegal characters
-
MimeType
Create a newMimeTypefor the given primary type and subtype.The parameters are empty.
- 参数:
type- the primary typesubtype- the subtype- 抛出:
IllegalArgumentException- if any of the parameters contains illegal characters
-
MimeType
Create a newMimeTypefor the given type, subtype, and character set.- 参数:
type- the primary typesubtype- the subtypecharset- the character set- 抛出:
IllegalArgumentException- if any of the parameters contains illegal characters
-
MimeType
Copy-constructor that copies the type, subtype, parameters of the givenMimeType, and allows to set the specified character set.- 参数:
other- the other MimeTypecharset- the character set- 抛出:
IllegalArgumentException- if any of the parameters contains illegal characters
-
MimeType
Copy-constructor that copies the type and subtype of the givenMimeType, and allows for different parameter.- 参数:
other- the other MimeTypeparameters- the parameters (may benull)- 抛出:
IllegalArgumentException- if any of the parameters contains illegal characters
-
MimeType
Create a newMimeTypefor the given type, subtype, and parameters.- 参数:
type- the primary typesubtype- the subtypeparameters- the parameters (maybenull)- 抛出:
IllegalArgumentException- if any of the parameters contains illegal characters
-
MimeType
Copy-constructor that copies the type, subtype and parameters of the givenMimeType, skipping checks performed in other constructors.- 参数:
other- the other MimeType- 从以下版本开始:
- 3.0
-
-
方法详细资料
-
checkToken
Checks the given token string for illegal characters, as defined in RFC 2616, section 2.2.- 抛出:
IllegalArgumentException- in case of illegal characters- 另请参阅:
-
checkParameters
-
isQuotedString
-
unquote
-
isWildcardType
public boolean isWildcardType()Indicates whether the type is the wildcard character*or not. -
isWildcardSubtype
public boolean isWildcardSubtype()Indicates whether the subtype is the wildcard character*or the wildcard character followed by a suffix (e.g.*+xml).- 返回:
- whether the subtype is a wildcard
-
isConcrete
public boolean isConcrete()Indicates whether this MIME Type is concrete, i.e. whether neither the type nor the subtype is a wildcard character*.- 返回:
- whether this MIME Type is concrete
-
getType
Return the primary type. -
getSubtype
Return the subtype. -
getSubtypeSuffix
Return the subtype suffix as defined in RFC 6839.- 从以下版本开始:
- 4.0
-
getCharset
Return the character set, as indicated by acharsetparameter, if any.- 返回:
- the character set, or
nullif not available
-
getParameter
Return a generic parameter value, given a parameter name.- 参数:
name- the parameter name- 返回:
- the parameter value, or
nullif not present
-
getParameters
Return all generic parameter values.- 返回:
- a read-only map (possibly empty, never
null)
-
includes
Indicate whether this MIME Type includes the given MIME Type.For instance,
text/*includestext/plainandtext/html, andapplication/*+xmlincludesapplication/soap+xml, etc. This method is not symmetric.- 参数:
other- the reference MIME Type with which to compare- 返回:
trueif this MIME Type includes the given MIME Type;falseotherwise
-
isCompatibleWith
Indicate whether this MIME Type is compatible with the given MIME Type.For instance,
text/*is compatible withtext/plain,text/html, and vice versa. In effect, this method is similar toincludes(cn.taketoday.util.MimeType), except that it is symmetric.- 参数:
other- the reference MIME Type with which to compare- 返回:
trueif this MIME Type is compatible with the given MIME Type;falseotherwise
-
equalsTypeAndSubtype
Similar toequals(Object)but based on the type and subtype only, i.e. ignoring parameters.- 参数:
other- the other mime type to compare to- 返回:
- whether the two mime types have the same type and subtype
-
isPresentIn
UnlikeCollection.contains(Object)which relies onequals(Object), this method only checks the type and the subtype, but otherwise ignores parameters.- 参数:
mimeTypes- the list of mime types to perform the check against- 返回:
- whether the list contains the given mime type
-
equals
-
parametersAreEqual
Determine if the parameters in thisMimeTypeand the suppliedMimeTypeare equal, performing case-insensitive comparisons forCharsets. -
hashCode
public int hashCode() -
toString
-
appendTo
-
appendTo
-
compareTo
Compares this MIME Type to another alphabetically.- 指定者:
compareTo在接口中Comparable<MimeType>- 参数:
other- the MIME Type to compare to
-
isMoreSpecific
Indicates whether thisMimeTypeis more specific than the given type.- if this mime type has a wildcard type,
and the other does not, then this method returns
false. - if this mime type does not have a wildcard type,
and the other does, then this method returns
true. - if this mime type has a wildcard type,
and the other does not, then this method returns
false. - if this mime type does not have a wildcard type,
and the other does, then this method returns
true. - if the two mime types have identical type and subtype, then the mime type with the most parameters is more specific than the other.
- Otherwise, this method returns
false.
- 参数:
other- theMimeTypeto be compared- 返回:
- the result of the comparison
- 从以下版本开始:
- 4.0
- 另请参阅:
- if this mime type has a wildcard type,
and the other does not, then this method returns
-
isLessSpecific
Indicates whether thisMimeTypeis more less than the given type.- if this mime type has a wildcard type,
and the other does not, then this method returns
true. - if this mime type does not have a wildcard type,
and the other does, then this method returns
false. - if this mime type has a wildcard type,
and the other does not, then this method returns
true. - if this mime type does not have a wildcard type,
and the other does, then this method returns
false. - if the two mime types have identical type and subtype, then the mime type with the least parameters is less specific than the other.
- Otherwise, this method returns
false.
- 参数:
other- theMimeTypeto be compared- 返回:
- the result of the comparison
- 从以下版本开始:
- 4.0
- 另请参阅:
- if this mime type has a wildcard type,
and the other does not, then this method returns
-
readObject
-
valueOf
-
addCharsetParameter
-