ContentType implements Serializable { public static ContentType parse(final CharSequence s) throws UnsupportedCharsetException { return parse(s, true); } ContentType(
            final String mimeType,
            final Charset charset);   ContentType(
            final String mimeType,
            final Charset charset,
            final NameValuePair[] params); String getMimeType(); Charset getCharset(); String getParameter(final String name); @Override String toString(); static ContentType create(final String mimeType, final Charset charset); static ContentType create(final String mimeType); static ContentType create(
            final String mimeType, final String charset); static ContentType create(
            final String mimeType, final NameValuePair... params); static ContentType parse(final CharSequence s); static ContentType parseLenient(final CharSequence s); @Deprecated static ContentType getByMimeType(final String mimeType); ContentType withCharset(final Charset charset); ContentType withCharset(final String charset); ContentType withParameters(
            final NameValuePair... params); boolean isSameMimeType(final ContentType contentType); static final ContentType APPLICATION_ATOM_XML; static final ContentType APPLICATION_FORM_URLENCODED; static final ContentType APPLICATION_JSON; static final ContentType APPLICATION_OCTET_STREAM; static final ContentType APPLICATION_SOAP_XML; static final ContentType APPLICATION_SVG_XML; static final ContentType APPLICATION_XHTML_XML; static final ContentType APPLICATION_XML; static final ContentType IMAGE_BMP; static final ContentType IMAGE_GIF; static final ContentType IMAGE_JPEG; static final ContentType IMAGE_PNG; static final ContentType IMAGE_SVG; static final ContentType IMAGE_TIFF; static final ContentType IMAGE_WEBP; static final ContentType MULTIPART_FORM_DATA; static final ContentType TEXT_HTML; static final ContentType TEXT_PLAIN; static final ContentType TEXT_XML; static final ContentType WILDCARD; static final ContentType DEFAULT_TEXT; static final ContentType DEFAULT_BINARY; }
@Test public void testParse() throws Exception { final ContentType contentType = ContentType.parse("text/plain; charset=\"ascii\""); Assert.assertEquals("text/plain", contentType.getMimeType()); Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset()); Assert.assertEquals("text/plain; charset=ascii", contentType.toString()); }
@Test public void testParseEmptyValue() throws Exception { Assert.assertEquals(null, ContentType.parse(null)); Assert.assertEquals(null, ContentType.parse("")); Assert.assertEquals(null, ContentType.parse(" ")); Assert.assertEquals(null, ContentType.parse(";")); Assert.assertEquals(null, ContentType.parse("=")); }