Package javax.ws.rs.ext

Examples of javax.ws.rs.ext.MessageBodyReader.readFrom()


                                         type,
                                         m);
            if (provider != null) {
                try {
                    HttpHeaders headers = new HttpHeadersImpl(m);
                    return provider.readFrom(
                              targetTypeClass, parameterType, parameterAnnotations, contentType,
                              headers.getRequestHeaders(), is);
                } catch (IOException e) {
                    String errorMessage = "Error deserializing input stream into target class "
                                          + targetTypeClass.getSimpleName()
View Full Code Here


            ProviderFactory.getInstance().createMessageBodyReader(
                cls, type, anns, contentType, outMessage);
        }
        if (mbr != null) {
            try {
                return mbr.readFrom(cls, type, anns, contentType,
                       new MetadataMap<String, Object>(r.getMetadata(), true, true), inputStream);
            } catch (Exception ex) {
                throw new WebApplicationException(ex);
            }
            
View Full Code Here

                                         type,
                                         m);
            if (provider != null) {
                try {
                    HttpHeaders headers = new HttpHeadersImpl(m);
                    return provider.readFrom(
                              targetTypeClass, parameterType, parameterAnnotations, contentType,
                              headers.getRequestHeaders(), is);
                } catch (IOException e) {
                    String errorMessage = "Error deserializing input stream into target class "
                                          + targetTypeClass.getSimpleName()
View Full Code Here

                                                   mediaType);

                if (mbr != null) {
                    Object read;
                    try {
                        read = mbr.readFrom(paramType,
                                     getGenericType(),
                                     getAnnotations(),
                                     mediaType,
                                     runtimeContext.getHttpHeaders().getRequestHeaders(),
                                     runtimeContext.getInputStream());
View Full Code Here

       
        MessageBodyReader mbr = ProviderFactory.getInstance(inMessage).createMessageBodyReader(
            cls, type, anns, contentType, inMessage);
        if (mbr != null) {
            try {
                return mbr.readFrom(cls, type, anns, contentType,
                       new MetadataMap<String, Object>(r.getMetadata(), true, true), inputStream);
            } catch (Exception ex) {
                reportMessageHandlerProblem("MSG_READER_PROBLEM", cls, contentType, ex, r);
            }
        } else if (cls == Response.class) {
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testReadByte() throws Exception {
        MessageBodyReader p = new PrimitiveTextProvider();
       
        Byte valueRead = (Byte)p.readFrom(byte.class,
                                          null,
                                          null,
                                          null,
                                          null,
                                          new ByteArrayInputStream("1".getBytes()));
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testReadBoolean() throws Exception {
        MessageBodyReader p = new PrimitiveTextProvider();
       
        boolean valueRead = (Boolean)p.readFrom(boolean.class,
                                          null,
                                          null,
                                          null,
                                          null,
                                          new ByteArrayInputStream("true".getBytes()));
View Full Code Here

                                         type,
                                         m);
            if (provider != null) {
                try {
                    HttpHeaders headers = new HttpHeadersImpl(m);
                    return provider.readFrom(
                              targetTypeClass, parameterType, parameterAnnotations, contentType,
                              headers.getRequestHeaders(), is);
                } catch (IOException e) {
                    String errorMessage = "Error deserializing input stream into target class "
                                          + targetTypeClass.getSimpleName()
View Full Code Here

    public void testReadChineeseChars() throws Exception {
        String s = "中文";
       
        MessageBodyReader p = new PrimitiveTextProvider();
       
        String value = (String)p.readFrom((Class)String.class, null,
                new Annotation[]{},
                MediaType.valueOf(MediaType.APPLICATION_XML + ";charset=UTF-8"), null,
                new ByteArrayInputStream(s.getBytes("UTF-8")));
        assertEquals(value, value);
    }   
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testReadByte() throws Exception {
        MessageBodyReader p = new PrimitiveTextProvider();
       
        Byte valueRead = (Byte)p.readFrom(byte.class,
                                          null,
                                          null,
                                          null,
                                          null,
                                          new ByteArrayInputStream("1".getBytes()));
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.