Class 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 Detail

      • providers

        @Context
        protected javax.ws.rs.ext.Providers providers
    • Constructor Detail

      • PrettyPrinter

        public PrettyPrinter()
    • Method Detail

      • getSize

        public long getSize​(Object object,
                            Class<?> type,
                            Type genericType,
                            Annotation[] methodAnnotations,
                            javax.ws.rs.core.MediaType mediaType)
        Specified by:
        getSize in interface javax.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 interface javax.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 interface javax.ws.rs.ext.MessageBodyWriter<Object>
        Throws:
        IOException
        javax.ws.rs.WebApplicationException