Package org.jclouds.http.functions
Class ParseXMLWithJAXB<T>
- java.lang.Object
-
- org.jclouds.http.functions.ParseXMLWithJAXB<T>
-
- All Implemented Interfaces:
com.google.common.base.Function<HttpResponse,T>
,Function<HttpResponse,T>
@Singleton public class ParseXMLWithJAXB<T> extends Object implements com.google.common.base.Function<HttpResponse,T>
This object will parse the body of an HttpResponse and return the result of typeback to the caller. JAXBContext
works withClass
objects instead ofType
. This could be a limitation if we are trying to parse typed collections of objects. However, when using JAXB we expect to have well formed XML documents with one single root element, so the objects to parse should not be collections but objects that wrap collections of elements, and that should work fine.
-
-
Constructor Summary
Constructors Constructor Description ParseXMLWithJAXB(XMLParser xml, com.google.inject.TypeLiteral<T> type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
apply(InputStream stream)
<V> V
apply(InputStream stream, Class<V> type)
T
apply(HttpResponse from)
-
-
-
Method Detail
-
apply
public T apply(HttpResponse from)
- Specified by:
apply
in interfacecom.google.common.base.Function<HttpResponse,T>
- Specified by:
apply
in interfaceFunction<HttpResponse,T>
-
apply
public T apply(InputStream stream) throws IOException
- Throws:
IOException
-
apply
public <V> V apply(InputStream stream, Class<V> type) throws IOException
- Throws:
IOException
-
-