public interface ContentType
charset
parameter is one of many parameters that
can be associated with a MIME type. This however this exposes this
parameter with a typed method.
The getCharset
will return the character encoding the
content type is encoded within. This allows the user of the content
to decode it correctly. Other parameters can be acquired from this
by simply providing the name of the parameter.
Modifier and Type | Method and Description |
---|---|
String |
getCharset()
This is used to retrieve the
charset of this MIME
type. |
String |
getParameter(String name)
This is used to retrieve an arbitrary parameter from the MIME
type header.
|
String |
getPrimary()
This is used to retrieve the primary type of this MIME type.
|
String |
getSecondary()
This is used to retrieve the secondary type of this MIME type.
|
String |
getType()
This method is used to get the primary and secondary parts
joined together with a "/".
|
void |
setCharset(String charset)
This will set the
charset to whatever value the
string contains. |
void |
setParameter(String name,
String value)
This will add a named parameter to the content type header.
|
void |
setPrimary(String type)
This sets the primary type to whatever value is in the string
provided is.
|
void |
setSecondary(String type)
This sets the secondary type to whatever value is in the string
provided is.
|
String |
toString()
This will return the value of the MIME type as a string.
|
String getType()
void setPrimary(String type)
type
- the type to set for the primary type of thisString getPrimary()
text/plain; charset=UTF-8
. This will
return the text value. If there is no primary type then this
will return null
otherwise the string value.void setSecondary(String type)
type
- the type to set for the primary type of thisString getSecondary()
text/html; charset=UTF-8
. This
will return the HTML value. If there is no secondary type then
this will return null
otherwise the string value.void setCharset(String charset)
charset
to whatever value the
string contains. If the string is null then this will not set
the parameter to any value and the toString
method
will not contain any details of the parameter.charset
- parameter value to add to the MIME typeString getCharset()
charset
of this MIME
type. This is a special parameter associated with the type, if
the parameter is not contained within the type then this will
return null, which typically means the default of ISO-8859-1.String getParameter(String name)
boundary
or other such parameters are not lost when the header is parsed.
This will return the value, unquoted if required, as a string.name
- this is the name of the parameter to be retrievedvoid setParameter(String name, String value)
boundary
as well as other
common parameters can be set with this method.name
- this is the name of the parameter to be addedvalue
- this is the value to associate with the nameString toString()
charset
parameter to the type which will
recreate the content type.Copyright © 2018. All rights reserved.