Package javax.ws.rs.ext

Examples of javax.ws.rs.ext.MessageBodyWriter.writeTo()


        MultivaluedMap<String, Object> headers = new MetadataMap<String, Object>();
       
        String eWithAcute = "\u00E9";
        String helloStringUTF16 = "Hello, my name is F" + eWithAcute + "lix Agn" + eWithAcute + "s";
       
        p.writeTo(helloStringUTF16,
                  String.class, String.class, null, MediaType.valueOf("text/plain;charset=ISO-8859-1"),
                  headers, os);
       
        byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1");
        String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
View Full Code Here


    @SuppressWarnings("unchecked")
    @Test
    public void testWriteBoolean() throws Exception {
        MessageBodyWriter p = new PrimitiveTextProvider();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        p.writeTo(Boolean.TRUE, null, null, null, MediaType.TEXT_PLAIN_TYPE, null, os);
        assertTrue(Arrays.equals(new String("true").getBytes(), os.toByteArray()));
       
        os = new ByteArrayOutputStream();
       
        final boolean value = true;
View Full Code Here

        assertTrue(Arrays.equals(new String("true").getBytes(), os.toByteArray()));
       
        os = new ByteArrayOutputStream();
       
        final boolean value = true;
        p.writeTo(value, null, null, null, MediaType.TEXT_PLAIN_TYPE, null, os);
        assertTrue(Arrays.equals(new String("true").getBytes(), os.toByteArray()));
    }
   
   
    @SuppressWarnings("unchecked")
View Full Code Here

        MultivaluedMap<String, Object> headers = new MetadataMap<String, Object>();
       
        String eWithAcute = "\u00E9";
        String helloStringUTF16 = "Hello, my name is F" + eWithAcute + "lix Agn" + eWithAcute + "s";
       
        p.writeTo(helloStringUTF16,
                  String.class, String.class, null, MediaType.valueOf("text/plain;charset=ISO-8859-1"),
                  headers, os);
       
        byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1");
        String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
View Full Code Here

        if (isJavaScript) {
            entityStream.write(t.getCallbackName().getBytes());
            entityStream.write('(');
        }

        bw.writeTo(jsonEntity, entityType, entityGenericType, annotations, workerMediaType, httpHeaders, entityStream);

        if (isJavaScript) {
            entityStream.write(')');
        }
    }
View Full Code Here

                                "No MessageBodyWriter for body part of type '" +
                                        bodyEntity.getClass().getName() + "' and media type '" +
                                        bodyMediaType + "'"));
            }

            bodyWriter.writeTo(
                    bodyEntity,
                    bodyClass,
                    bodyClass,
                    EMPTY_ANNOTATIONS,
                    bodyMediaType,
View Full Code Here

                : bw.getSize(entity, entityClass, entityType, EMPTY_ANNOTATIONS, mediaType);
        listener.onRequestEntitySize(size);

        final OutputStream out = ro.getAdapter().adapt(ro, listener.onGetOutputStream());
        try {
            bw.writeTo(entity, entityClass, entityType,
                    EMPTY_ANNOTATIONS, mediaType, headers, out);
            out.flush();
        } catch (IOException ex) {
            try { out.close(); } catch (Exception e) { }
            throw ex;
View Full Code Here

                        ReflectionHelper.objectToString(p)));
            }

            if (out == null)
                out = new CommittingOutputStream(size);
            p.writeTo(entity, entity.getClass(), entityType,
                    annotations, contentType, getHttpHeaders(),
                    out);
            if (!isCommitted) {
                isCommitted = true;
                responseWriter.writeStatusAndHeaders(-1, this);
View Full Code Here

            final MediaType eventMediaType =
                    outboundEvent.getMediaType() == null ? MediaType.TEXT_PLAIN_TYPE : outboundEvent.getMediaType();
            final MessageBodyWriter messageBodyWriter = workersProvider.get().getMessageBodyWriter(outboundEvent.getType(),
                    outboundEvent.getGenericType(), annotations, eventMediaType);
            messageBodyWriter.writeTo(
                    outboundEvent.getData(),
                    outboundEvent.getType(),
                    outboundEvent.getGenericType(),
                    annotations,
                    eventMediaType,
View Full Code Here

            if (bodyWriter == null) {
                throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBW(bodyClass, mediaType));
            }

            bodyWriter.writeTo(
                    bodyEntity,
                    bodyClass,
                    bodyClass,
                    EMPTY_ANNOTATIONS,
                    bodyMediaType,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.