Extracts the message body and interprets it as
the XML representation of an object of the given
type.

@param type The type (class) of the object
@return The message body as an object of the specified type
17075
@SuppressWarnings("unchecked")
    public <T> T readBodyAsObject(Class<T> type) {
        Charset charset = readCharset();
        InputStream inputStream = new ByteArrayInputStream(message.getBodyContent());
        InputStreamReader inputReader = new InputStreamReader(inputStream, charset);
        StreamSource streamSource = new StreamSource(inputReader);
        try {
            Unmarshaller unmarshaller = JAXBContext.newInstance(type).createUnmarshaller();
            if (type.isAnnotationPresent(XmlRootElement.class)) {
                return (T)unmarshaller.unmarshal(streamSource);
            } else {
                JAXBElement<T> element = unmarshaller.unmarshal(streamSource, type);
                return element.getValue();
            }
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
792685
public Object parseAs(Type dataType) throws IOException {
    if (!hasMessageBody()) {
      return null;
    }
    return request.getParser().parseAndClose(getContent(), getContentCharset(), dataType);
  }
180770
public String getBody() {
        JsonObject wrapper = new JsonObject();
        wrapper.add(Ref.getTypeFromRef(ref), obj);
        return gsonBuilder.create().toJson(wrapper);
    }
17837
public static <T> T readEntity(Class<T> rawType, Type type) {
        return getRequest().readEntity(rawType, type);
    }
954757
@Override
  public <X> void body(Class<X> type, Result<X> result)
  {
    delegate().body(type, result);
  }
802540
public static String getElementAsString(JDeclaration type) {
		StringBuilder builder = new StringBuilder();
		JFormatter jFormatter = new JFormatter(new StringBuilderWriter(builder));
		type.declare(jFormatter);
		return builder.toString();
	}
1107509
public Object getObject(Type type) throws FMSException {
		Object obj = null;
		if (type instanceof ParameterizedType) {
			ParameterizedType pt = (ParameterizedType) type;
			String typeString = pt.getActualTypeArguments()[0].toString().split(" ")[1];
			try {
				obj = Class.forName(typeString).newInstance();
			} catch (Exception e) {
				throw new FMSException(e);
			}
		}
		return obj;
	}
505861
public PactDslRequestWithoutPath body(String body, ContentType mimeType) {
        return body(body, mimeType.toString());
    }
938747
@SuppressWarnings("unchecked")
    public <T> T readBodyAs(Class<T> type) {
        if (String.class.isAssignableFrom(type)) {
            return (T)readBodyAsString();
        } else if (Number.class.isAssignableFrom(type)) {
            return (T)readBodyAsNumber((Class<Number>)type);
        } else if (Boolean.class.isAssignableFrom(type)) {
            return (T)readBodyAsBoolean();
        } else if (Character.class.isAssignableFrom(type)) {
            return (T)readBodyAsChar();
        }
        return readBodyAsObject(type);
    }
137170
public static Type typeFromString(String type) {
        final PrimitiveType primitive = PrimitiveType.fromName(type);
        if (primitive != null) {
            return primitive.getKeyClass();
        }
        try {
            return loadClassByName(type);
        } catch (Exception e) {
            //LOGGER.error(String.format("Failed to resolve '%s' into class", type), e);
        }
        return null;
    }
54690
public String getTitle(int type)
	{
		if (allow(type&ID3V1))
		{
			return id3v1.getTitle();
		}
		if (allow(type&ID3V2))
		{
			return id3v2.getFrameDataString(ID3v2Frames.TITLE);
		}
		return null;
	}
1328852
public static Class<?> getTypeByDescriptor(TypeDescriptor type) {
		if (type == null)
			throw new NullPointerException("Type descriptor cannot be null");

		return getType(type.getName(), type.getLibrary());
	}
909739
@SuppressWarnings("unchecked")
    public <T> T get(final Class<T> type) {
        T bean = (T) components.get(type);
        if (bean != null) {
            return bean;
        }
        return (T) get(type.getName());
    }
773203
public static String toReadableType(final String type) {
        final SignatureReader reader = new SignatureReader(type);
        final TraceSignatureVisitor visitor = new TraceSignatureVisitor(0);
        reader.acceptType(visitor);
        return visitor.getDeclaration();
    }
668678
protected static String getTypeDescriptor(Object type) {
        if (type instanceof Class) {
            return Type.getDescriptor((Class) type);
        } else if (type instanceof Type) {
            return ((Type) type).getDescriptor();
        } else {
            String className = type.toString();
            return getTypeDescriptor(className, new String[0]);
        }
    }
1365317
public <T> T parseBody(Class<T> clazz) throws ParsableException, MediaTypeException {
        String contentType = request.getContentType();
        
        // if the content type header was not provided, we throw
        if (contentType == null || contentType.isEmpty()) {
            throw new MediaTypeException("Missing media type header");
        }
        
        // extract the actual content type in case charset is also a part of the string
        contentType = HttpHeaderUtil.getContentTypeFromContentTypeAndCharacterSetting(contentType);
        
        ParserEngine engine = parserEngineManager.getParserEngineForContentType(contentType);
        
        if (engine == null) {
            throw new MediaTypeException("An engine for media type ("+contentType+") was not found");
        }
        
        try {
            return engine.invoke(request.getInputStream(), clazz);
        } catch (IOException e) {
            throw new ParsableException(e);
        }
    }
374171
String getBody(Object object, ContentType contentType) {
        if (contentType == ContentType.APPLICATION_FORM_URLENCODED) {
            return jsonToUrlEncodedString((JsonObject) new JsonParser().parse(gson.toJson(object)));
        }

        return gson.toJson(object);
    }