public void writeTo(T element, Class<?> clazz, Type type, Annotation[] a,
MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os)
throws IOException {
if (MediaType.APPLICATION_JSON_TYPE.isCompatible(mt)) {
Writer w = createWriter("json");
if (w == null) {
throw ExceptionUtils.toNotSupportedException(null, null);
}
element.writeTo(w, os);
} else if (formattedOutput) {
Writer w = createWriter("prettyxml");
if (w != null) {
element.writeTo(w, os);
} else {
element.writeTo(os);
}