Class TextMessageBodyWriter

  • All Implemented Interfaces:
    jakarta.ws.rs.ext.MessageBodyWriter<Metadata>

    @Provider
    @Produces("text/plain")
    public class TextMessageBodyWriter
    extends Object
    implements jakarta.ws.rs.ext.MessageBodyWriter<Metadata>
    Returns simple text string for a particular metadata value. This assumes that the metadata object only has one key; if there is more than one key or no keys, this will throw a webapp exception.

    This will choose the first value returned for the one key.

    • Constructor Detail

      • TextMessageBodyWriter

        public TextMessageBodyWriter()
    • Method Detail

      • isWriteable

        public boolean isWriteable​(Class<?> type,
                                   Type genericType,
                                   Annotation[] annotations,
                                   jakarta.ws.rs.core.MediaType mediaType)
        Specified by:
        isWriteable in interface jakarta.ws.rs.ext.MessageBodyWriter<Metadata>
      • getSize

        public long getSize​(Metadata data,
                            Class<?> type,
                            Type genericType,
                            Annotation[] annotations,
                            jakarta.ws.rs.core.MediaType mediaType)
        Specified by:
        getSize in interface jakarta.ws.rs.ext.MessageBodyWriter<Metadata>
      • writeTo

        public void writeTo​(Metadata metadata,
                            Class<?> type,
                            Type genericType,
                            Annotation[] annotations,
                            jakarta.ws.rs.core.MediaType mediaType,
                            jakarta.ws.rs.core.MultivaluedMap<String,​Object> httpHeaders,
                            OutputStream entityStream)
                     throws IOException,
                            jakarta.ws.rs.WebApplicationException
        Specified by:
        writeTo in interface jakarta.ws.rs.ext.MessageBodyWriter<Metadata>
        Throws:
        IOException
        jakarta.ws.rs.WebApplicationException