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 = ATOM_ENGINE.getWriterFactory().getWriter("json");
element.writeTo(w, os);
} else if (formattedOutput) {
Writer w = ATOM_ENGINE.getWriterFactory().getWriter("prettyxml");
element.writeTo(w, os);
} else {
element.writeTo(os);
}
}