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.Providersproviders
-
Constructor Summary
Constructors Constructor Description PrettyPrinter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetSize(Object object, Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType)booleanisWriteable(Class<?> type, Type genericType, Annotation[] methodAnnotations, javax.ws.rs.core.MediaType mediaType)Return true for any JAXB classvoidwriteTo(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:
getSizein 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:
isWriteablein 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:
writeToin interfacejavax.ws.rs.ext.MessageBodyWriter<Object>- Throws:
IOExceptionjavax.ws.rs.WebApplicationException
-
-