public class AssetFormatter extends Object implements Body.Formatter
Constructor and Description |
---|
AssetFormatter() |
Modifier and Type | Method and Description |
---|---|
boolean |
canFormat(Class<?> type)
Test if the given type can be write it to the HTTP response body.
|
void |
format(Object body,
Body.Writer writer)
Attempt to write a message into the HTTP response body.
|
List<MediaType> |
types()
The
Accept header is tested against this type in order to decided if this
formatter accept or not a type. |
public boolean canFormat(Class<?> type)
Body.Formatter
canFormat
in interface Body.Formatter
type
- The candidate type.public List<MediaType> types()
Body.Formatter
Accept
header is tested against this type in order to decided if this
formatter accept or not a type.types
in interface Body.Formatter
public void format(Object body, Body.Writer writer) throws Exception
Body.Formatter
For text format (json, yaml, xml, etc.) a converter usually call to
Body.Writer.text(Body.Writer.Text)
in order to set charset and close resources.
For binary format a converter usually call to
Body.Writer.bytes(Body.Writer.Bytes)
in order to close resources.
format
in interface Body.Formatter
body
- A body message.writer
- A write context.Exception
- If write operation fail.Copyright © 2015. All rights reserved.