public <V> V apply(final InputStream stream, final Class<V> type) throws IOException { try { return xml.fromXML(Strings2.toStringAndClose(stream), type); } finally { if (stream != null) { stream.close(); } } }
@Override public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { try { String xml = xmlParser.toXML(checkNotNull(input, "input")); request.setPayload(xml); MutableContentMetadata metadata = request.getPayload().getContentMetadata(); if (contentTypeMustBeAdded(metadata)) { metadata.setContentType("application/xml"); } return request; } catch (IOException ex) { throw new BindException(request, ex); } }
public <V> V apply(final InputStream stream, final Class<V> type) throws IOException { try { return xml.fromXML(Strings2.toStringAndClose(stream), type); } finally { if (stream != null) { stream.close(); } } }
@Override public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { try { String xml = xmlParser.toXML(checkNotNull(input, "input")); request.setPayload(xml); MutableContentMetadata metadata = request.getPayload().getContentMetadata(); if (contentTypeMustBeAdded(metadata)) { metadata.setContentType("application/xml"); } return request; } catch (IOException ex) { throw new BindException(request, ex); } }
public <V> V apply(final InputStream stream, final Class<V> type) throws IOException { try { return xml.fromXML(Strings2.toStringAndClose(stream), type); } finally { if (stream != null) { stream.close(); } } }
@Override public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { try { String xml = xmlParser.toXML(checkNotNull(input, "input")); request.setPayload(xml); MutableContentMetadata metadata = request.getPayload().getContentMetadata(); if (contentTypeMustBeAdded(metadata)) { metadata.setContentType("application/xml"); } return request; } catch (IOException ex) { throw new BindException(request, ex); } }
public <V> V apply(final InputStream stream, final Class<V> type) throws IOException { try { return xml.fromXML(Strings2.toStringAndClose(stream), type); } finally { if (stream != null) { stream.close(); } } }
@Override public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { try { String xml = xmlParser.toXML(checkNotNull(input, "input")); request.setPayload(xml); MutableContentMetadata metadata = request.getPayload().getContentMetadata(); if (contentTypeMustBeAdded(metadata)) { metadata.setContentType("application/xml"); } return request; } catch (IOException ex) { throw new BindException(request, ex); } }
public <V> V apply(final InputStream stream, final Class<V> type) throws IOException { try { return xml.fromXML(Strings2.toStringAndClose(stream), type); } finally { if (stream != null) { stream.close(); } } }
@Override public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { try { String xml = xmlParser.toXML(checkNotNull(input, "input")); request.setPayload(xml); MutableContentMetadata metadata = request.getPayload().getContentMetadata(); if (contentTypeMustBeAdded(metadata)) { metadata.setContentType("application/xml"); } return request; } catch (IOException ex) { throw new BindException(request, ex); } }
public <V> V apply(final InputStream stream, final Class<V> type) throws IOException { try { String str = Strings2.toStringAndClose(stream); return xml.fromXML(str, type); } finally { if (stream != null) { stream.close(); } } }
@Override public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { try { String xml = xmlParser.toXML(checkNotNull(input, "input")); request.setPayload(xml); MutableContentMetadata metadata = request.getPayload().getContentMetadata(); if (contentTypeMustBeAdded(metadata)) { metadata.setContentType("application/xml"); } return request; } catch (IOException ex) { throw new BindException(request, ex); } }
@Test public void testJAXBParserBOM() throws Exception { String input = "\uFEFF<test><elem>foo</elem></test>"; TestJAXBDomain obj = xml.fromXML(input, TestJAXBDomain.class); assertThat(obj.getElem()).isEqualTo("foo"); }