@Test public void testGetCharset() { Assert.assertEquals("UTF-8", new TestProvider().getCharset(MediaType.APPLICATION_JSON_TYPE)); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("charset", "ASCII"); MediaType customMediaType = new MediaType("application", "json", parameters); Assert.assertEquals("ASCII", new TestProvider().getCharset(customMediaType)); }
protected String getCharset(MediaType mediaType) { Map<String, String> parameters = mediaType.getParameters(); return parameters.containsKey("charset") ? parameters.get("charset") : "UTF-8"; }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected String getCharset(MediaType mediaType) { Map<String, String> parameters = mediaType.getParameters(); return parameters.containsKey("charset") ? parameters.get("charset") : "UTF-8"; } }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected String getCharset(MediaType mediaType) { Map<String, String> parameters = mediaType.getParameters(); return parameters.containsKey("charset") ? parameters.get("charset") : "UTF-8"; } AbstractJsonXMLProvider(Providers providers); }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected String getCharset(MediaType mediaType) { Map<String, String> parameters = mediaType.getParameters(); return parameters.containsKey("charset") ? parameters.get("charset") : "UTF-8"; } AbstractJsonXMLProvider(Providers providers); @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); abstract Object read(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			Reader entityStream); @Override final Object readFrom(
			Class<Object> type, // <-- how sad...
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			InputStream entityStream); abstract void write(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			Writer entityStream,
			Object entry); @Override final void writeTo(
			Object entry,
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			OutputStream entityStream); }
AbstractJsonXMLProvider extends JsonXMLBinder implements MessageBodyReader<Object>, MessageBodyWriter<Object> { protected String getCharset(MediaType mediaType) { Map<String, String> parameters = mediaType.getParameters(); return parameters.containsKey("charset") ? parameters.get("charset") : "UTF-8"; } AbstractJsonXMLProvider(Providers providers); @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); abstract Object read(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			Reader entityStream); @Override final Object readFrom(
			Class<Object> type, // <-- how sad...
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			InputStream entityStream); abstract void write(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			Writer entityStream,
			Object entry); @Override final void writeTo(
			Object entry,
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			OutputStream entityStream);  }