protected Object get(HttpContext context) {
// Return the field value for the field specified by the sourceName property.
final FormDataMultiPart formDataMultiPart = getEntity(context);
List<FormDataBodyPart> formDataBodyParts = formDataMultiPart.getFields(parameter.getSourceName());
FormDataBodyPart formDataBodyPart = (formDataBodyParts != null) ? formDataBodyParts.get(0) : null;
MediaType mediaType = (formDataBodyPart != null) ? formDataBodyPart.getMediaType() : MediaType.TEXT_PLAIN_TYPE;
MessageBodyWorkers messageBodyWorkers = context.getRequestContext().getWorkers();
MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(
parameter.getRawType(),
parameter.getType(),
parameter.getAnnotations(),
mediaType);
if (reader != null && !isPrimitiveType(parameter.getRawType())) {
InputStream in;
if (formDataBodyPart == null) {
if (parameter.getDefaultValue() != null) {
// Convert default value to bytes.
in = new ByteArrayInputStream(parameter.getDefaultValue().getBytes());
} else {
return null;
}
} else {
in = ((BodyPartEntity) formDataBodyPart.getEntity()).getInputStream();
}
try {
//noinspection unchecked