public class LayoutJSONWriter implements MessageBodyWriter<Layout> {
private String jsonRep = null;
public long getSize(Layout layout, Class<?> type,
Type genericType, Annotation[] annotations, MediaType mediaType) {
LayoutJSONSerializer serializer = new LayoutJSONSerializer();
try {
if (jsonRep == null)
jsonRep = serializer.convertToString(layout);
return jsonRep.getBytes("utf-8").length;
} catch(Exception ex) {
return -1;
}
}