Class PrettyPrinter
- java.lang.Object
-
- ejava.examples.ejbwar.inventory.rs.PrettyPrinter
-
- All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyWriter<Object>
@Provider @Produces("application/xml") public class PrettyPrinter extends Object implements javax.ws.rs.ext.MessageBodyWriter<Object>
Put this class in your JAX-RS application to have XML output formatted so that it is easier to read.
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.ws.rs.ext.Providers
providers
-
Constructor Summary
Constructors Constructor Description PrettyPrinter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getSize(Object object, Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType)
boolean
isWriteable(Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType)
Return true for any JAXB classvoid
writeTo(Object object, Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream os)
Write the provided JAXB object using formatted output.
-
-
-
Method Detail
-
getSize
public long getSize(Object object, Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType)
- Specified by:
getSize
in interfacejavax.ws.rs.ext.MessageBodyWriter<Object>
-
isWriteable
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType)
Return true for any JAXB class- Specified by:
isWriteable
in interfacejavax.ws.rs.ext.MessageBodyWriter<Object>
-
writeTo
public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream os) throws IOException, javax.ws.rs.WebApplicationException
Write the provided JAXB object using formatted output.- Specified by:
writeTo
in interfacejavax.ws.rs.ext.MessageBodyWriter<Object>
- Throws:
IOException
javax.ws.rs.WebApplicationException
-
-