public static Object convertUrlEncodedToOctetStream(Object content) { return convertTextToOctetStream(urlDecode(content), TEXT_PLAIN); }
@Test public void testTextToOctetStreamConversion() { String source = "Like our owl?"; byte[] result = StandardConversions.convertTextToOctetStream(source, TEXT_PLAIN); assertArrayEquals(source.getBytes(UTF_8), result); }
private Object convertToByteArray(Object content, MediaType contentType) { try { if (contentType.match(APPLICATION_OCTET_STREAM)) { return StandardConversions.decodeOctetStream(content, contentType); } if (contentType.match(APPLICATION_WWW_FORM_URLENCODED)) { return StandardConversions.convertUrlEncodedToOctetStream(content); } if (contentType.match(TEXT_PLAIN)) { return StandardConversions.convertTextToOctetStream(content, contentType); } return StandardConversions.convertJavaToOctetStream(content, contentType, jbossMarshaller); } catch (EncodingException | InterruptedException | IOException e) { throw log.unsupportedContent(content); } }
public Object convertToOctetStream(Object content, MediaType contentType, MediaType destinationType) throws IOException, InterruptedException { if (contentType.match(APPLICATION_OCTET_STREAM) || contentType.match(APPLICATION_UNKNOWN)) { return StandardConversions.decodeOctetStream(content, contentType); } if (contentType.match(APPLICATION_OBJECT)) { return StandardConversions.convertJavaToOctetStream(content, contentType, javaMarshaller); } if (contentType.match(TEXT_PLAIN)) { return StandardConversions.convertTextToOctetStream(content, destinationType); } if (contentType.match(APPLICATION_WWW_FORM_URLENCODED)) { return StandardConversions.convertUrlEncodedToOctetStream(content); } throw log.unsupportedContent(content); }