Send feedback
Class HttpMediaType (1.41.8)
Stay organized with collections
Save and categorize content based on your preferences.
Version 1.41.8 keyboard_arrow_down
public final class HttpMediaType
HTTP Media-type as specified in the HTTP RFC .
Implementation is not thread-safe.
Inheritance
Object >
HttpMediaType
Static Methods
public static boolean equalsIgnoreParameters ( String mediaTypeA , String mediaTypeB )
Returns true
if the two specified media types have the same type and subtype, or if
both types are null
.
Parameters
Returns
Constructors
public HttpMediaType ( String mediaType )
Creates a HttpMediaType by parsing the specified media type string.
Parameter
Name Description mediaType String
full media type string, for example "text/plain; charset=utf-8"
public HttpMediaType ( String type , String subType )
Initializes the HttpMediaType by setting the specified media type.
Parameters
Name Description type String
main media type, for example "text"
subType String
sub media type, for example "plain"
Methods
Builds the full media type string which can be passed in the Content-Type header.
Returns
public void clearParameters ()
Removes all set parameters from this media type.
public boolean equals ( Object obj )
Parameter
Returns
Overrides
public boolean equalsIgnoreParameters ( HttpMediaType mediaType )
Returns true
if the specified media type has both the same type and subtype, or
false
if they don't match or the media type is null
.
Parameter
Returns
public Charset getCharsetParameter ()
Returns the specified charset or null
if unset.
Returns
public String getParameter ( String name )
Returns the value of the specified parameter or null
if not found.
Parameter
Name Description name String
name of the parameter
Returns
public Map<String , String > getParameters ()
Returns an unmodifiable map of all specified parameters. Parameter names will be stored in
lower-case in this map.
Returns
public String getSubType ()
Returns the sub media type, for example "plain"
when using "text"
.
Returns
Returns the main media type, for example "text"
, or null
for '*'.
Returns
Returns
Overrides
public HttpMediaType removeParameter ( String name )
Removes the specified media parameter.
Parameter
Name Description name String
parameter to remove
Returns
public HttpMediaType setCharsetParameter ( Charset charset )
Sets the charset parameter of the media type.
Parameter
Name Description charset Charset
new value for the charset parameter or null
to remove
Returns
public HttpMediaType setParameter ( String name , String value )
Sets the media parameter to the specified value.
Parameters
Name Description name String
case-insensitive name of the parameter
value String
value of the parameter or null
to remove
Returns
public HttpMediaType setSubType ( String subType )
Sets the sub media type, for example "plain"
when using "text"
.
Parameter
Name Description subType String
sub media type
Returns
public HttpMediaType setType ( String type )
Sets the (main) media type, for example "text"
.
Parameter
Name Description type String
main/major media type
Returns
Returns
Overrides
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-06 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-06 UTC."],[],[]]