Class XMLItemCollectionWriter

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

    @Provider
    @Produces("text/html")
    public class XMLItemCollectionWriter
    extends Object
    implements jakarta.ws.rs.ext.MessageBodyWriter<XMLDocument>
    This class translates a XMLDocument into a HTML representation.
    Version:
    1.1
    Author:
    rsoika
    • Constructor Detail

      • XMLItemCollectionWriter

        public XMLItemCollectionWriter()
    • 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<XMLDocument>
      • writeTo

        public void writeTo​(XMLDocument xmlItemCollection,
                            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<XMLDocument>
        Throws:
        IOException
        jakarta.ws.rs.WebApplicationException
      • getSize

        public long getSize​(XMLDocument arg0,
                            Class<?> arg1,
                            Type arg2,
                            Annotation[] arg3,
                            jakarta.ws.rs.core.MediaType arg4)
        Specified by:
        getSize in interface jakarta.ws.rs.ext.MessageBodyWriter<XMLDocument>
      • printXMLItemCollectionHTML

        public static void printXMLItemCollectionHTML​(BufferedWriter bw,
                                                      XMLDocument xmlworkItem)
                                               throws IOException
        This Method prints a single XMLItemCollection in html format. The items are sorted by name
        Parameters:
        out -
        workItem -
        Throws:
        IOException
      • convertValuesToString

        public static String convertValuesToString​(List values)
        This method converts the Values of a vector into a string representation. Multivalues will be separated with '~' characters. Date Objects will be converted into a short String representation taking the server locale
        Parameters:
        values -
        Returns:
      • printHead

        public static void printHead​(BufferedWriter bw,
                                     String contentType,
                                     String encoding)
                              throws IOException
        This method prints the generic HTML Header for HTML output, including a default CSS definition for table layout. The meta tag Content-Type is generated in case a contentType and encoding is provided.
        Parameters:
        bw -
        Throws:
        IOException