org.resthub.web.support.XmlBodyReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resthub-web-client Show documentation
Show all versions of resthub-web-client Show documentation
RESThub webservice client for requesting REST webservices with JSON support bundled
The newest version!
package org.resthub.web.support;
import com.fasterxml.jackson.core.type.TypeReference;
import com.ning.http.client.Response;
import org.resthub.web.Http;
import org.resthub.web.XmlHelper;
import java.io.IOException;
public class XmlBodyReader implements BodyReader {
@Override
public boolean canRead(Response response) {
return (response.getContentType() != null && (response.getContentType().startsWith(Http.XML) || response
.getContentType().endsWith("+xml")));
}
@Override
public T readEntity(Response resp, Class entityClass) throws IOException {
return XmlHelper.deserialize(resp.getResponseBody(), entityClass);
}
@Override
public T readEntity(Response resp, Class entityClass, String charset) throws IOException {
return XmlHelper.deserialize(resp.getResponseBody(charset), entityClass);
}
@Override
public T readEntity(Response resp, TypeReference valueTypeRef) throws IOException {
return XmlHelper.deserialize(resp.getResponseBody(), valueTypeRef);
}
@Override
public T readEntity(Response resp, TypeReference valueTypeRef, String charset) throws IOException {
return XmlHelper.deserialize(resp.getResponseBody(charset), valueTypeRef);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy