@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(MultivaluedMap.class, MultivaluedMap.class, EMPTY_ANNOTATIONS, MediaType.APPLICATION_FORM_URLENCODED_TYPE);
/** * Read event data as a given generic type. * * @param type generic type to be used for event data de-serialization. * @param mediaType {@link MediaType media type} to be used for event data de-serialization. * @return event data de-serialized as an instance of a given type. * @throws javax.ws.rs.ProcessingException when provided type can't be read. The thrown exception wraps the original cause. * @since 2.3 */ public <T> T readData(GenericType<T> type, MediaType mediaType) { final MediaType effectiveMediaType = mediaType == null ? this.mediaType : mediaType; final MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(type.getRawType(), type.getType(), annotations, mediaType); if (reader == null) { throw new MessageBodyProviderNotFoundException(LocalizationMessages.EVENT_DATA_READER_NOT_FOUND()); } return readAndCast(type, effectiveMediaType, reader); }
final MessageBodyReader bodyReader = workers.getMessageBodyReader( context.getType(), context.getGenericType(),
final MessageBodyReader bodyReader = workers.getMessageBodyReader( context.getType(), context.getGenericType(),
MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader( parameter.getRawType(), parameter.getType(), if (part != null) { for (final FormDataBodyPart p : parts) { reader = messageBodyWorkers.getMessageBodyReader( String.class, String.class,
@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
@Override public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return workers.get().getMessageBodyReader(type, genericType, annotations, mediaType); }
@SuppressWarnings("unchecked") @Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { final Type actualTypeArgument = actual(genericType); final Class entityType = entityType(actualTypeArgument); final MessageBodyReader reader = workers.get().getMessageBodyReader(entityType, actualTypeArgument, annotations, mediaType); return reader.readFrom(entityType, actualTypeArgument, annotations, mediaType, httpHeaders, entityStream); }
/** * Read event data as a given generic type. * * @param type generic type to be used for event data de-serialization. * @param mediaType {@link MediaType media type} to be used for event data de-serialization. * @return event data de-serialized as an instance of a given type. * @throws javax.ws.rs.ProcessingException when provided type can't be read. The thrown exception wraps the original cause. * @since 2.3 */ public <T> T readData(GenericType<T> type, MediaType mediaType) { final MediaType effectiveMediaType = mediaType == null ? this.mediaType : mediaType; final MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(type.getRawType(), type.getType(), annotations, mediaType); if (reader == null) { throw new IllegalStateException(LocalizationMessages.EVENT_DATA_READER_NOT_FOUND()); } return readAndCast(type, effectiveMediaType, reader); }
/** * Read event data as a given generic type. * * @param type generic type to be used for event data de-serialization. * @param mediaType {@link MediaType media type} to be used for event data de-serialization. * @return event data de-serialized as an instance of a given type. * @throws javax.ws.rs.ProcessingException when provided type can't be read. The thrown exception wraps the original cause. * @since 2.3 */ public <T> T readData(GenericType<T> type, MediaType mediaType) { final MediaType effectiveMediaType = mediaType == null ? this.mediaType : mediaType; final MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(type.getRawType(), type.getType(), annotations, mediaType); if (reader == null) { throw new IllegalStateException(LocalizationMessages.EVENT_DATA_READER_NOT_FOUND()); } return readAndCast(type, effectiveMediaType, reader); }
/** * Read event data as a given generic type. * * @param type generic type to be used for event data de-serialization. * @param mediaType {@link MediaType media type} to be used for event data de-serialization. * @return event data de-serialized as an instance of a given type. * @throws javax.ws.rs.ProcessingException when provided type can't be read. The thrown exception wraps the original cause. * @since 2.3 */ public <T> T readData(GenericType<T> type, MediaType mediaType) { final MediaType effectiveMediaType = mediaType == null ? this.mediaType : mediaType; final MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(type.getRawType(), type.getType(), annotations, mediaType); if (reader == null) { throw new IllegalStateException(LocalizationMessages.EVENT_DATA_READER_NOT_FOUND()); } return readAndCast(type, effectiveMediaType, reader); }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }
/** * Returns the entity after appropriate conversion to the requested type. This is useful only when the containing * {@link MultiPart} instance has been received, which causes the {@code providers} property to have been set. * * @param clazz desired class into which the entity should be converted. * @return entity after appropriate conversion to the requested type. * * @throws ProcessingException if an IO error arises during reading an entity. * @throws IllegalArgumentException if no {@link MessageBodyReader} can be found to perform the requested conversion. * @throws IllegalStateException if this method is called when the {@code providers} property has not been set or when the * entity instance is not the unconverted content of the body part entity. */ public <T> T getEntityAs(final Class<T> clazz) { if (entity == null || !(entity instanceof BodyPartEntity)) { throw new IllegalStateException(LocalizationMessages.ENTITY_HAS_WRONG_TYPE()); } if (clazz == BodyPartEntity.class) { return clazz.cast(entity); } final Annotation[] annotations = new Annotation[0]; final MessageBodyReader<T> reader = messageBodyWorkers.getMessageBodyReader(clazz, clazz, annotations, mediaType); if (reader == null) { throw new IllegalArgumentException(LocalizationMessages.NO_AVAILABLE_MBR(clazz, mediaType)); } try { return reader.readFrom(clazz, clazz, annotations, mediaType, headers, ((BodyPartEntity) entity).getInputStream()); } catch (final IOException ioe) { throw new ProcessingException(LocalizationMessages.ERROR_READING_ENTITY(String.class), ioe); } }