/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
@Override public TokenResult readFrom(Class<TokenResult> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { Map<String, Object> map = new HashMap<>(); final String str = ReaderWriter.readFromAsString(entityStream, mediaType); final String[] splitArray = str.split("&"); for (String s : splitArray) { final String[] keyValue = s.split("="); map.put(keyValue[0], keyValue[1]); } return new TokenResult(map); } }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
public static XMLStreamReader createReader(final Reader reader, final JettisonConfig config) throws XMLStreamException { Reader nonEmptyReader = ensureNonEmptyReader(reader); switch (config.getNotation()) { case MAPPED_JETTISON: try { Configuration jmConfig; if (null == config.getXml2JsonNs()) { jmConfig = new Configuration(); } else { jmConfig = new Configuration(config.getXml2JsonNs()); } return new MappedXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader))), new MappedNamespaceConvention(jmConfig)); } catch (Exception ex) { throw new XMLStreamException(ex); } case BADGERFISH: try { return new BadgerFishXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader)))); } catch (Exception ex) { throw new XMLStreamException(ex); } } // This should not occur throw new IllegalArgumentException("Unknown JSON config"); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return ReaderWriter.readFromAsString(in, type); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
/** * Read the bytes of an input stream and convert to a string. * * @param in the input stream to read from. * @param type the media type that determines the character set defining * how to decode bytes to characters. * @return the string. * * @throws IOException if there is an error reading from the input stream. */ public static String readFromAsString(InputStream in, MediaType type) throws IOException { return readFromAsString(new InputStreamReader(in, getCharset(type))); }
@Override public TokenResult readFrom(Class<TokenResult> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { Map<String, Object> map = new HashMap<>(); final String str = ReaderWriter.readFromAsString(entityStream, mediaType); final String[] splitArray = str.split("&"); for (String s : splitArray) { final String[] keyValue = s.split("="); map.put(keyValue[0], keyValue[1]); } return new TokenResult(map); } }
@Override public TokenResult readFrom(Class<TokenResult> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { Map<String, Object> map = Maps.newHashMap(); final String str = ReaderWriter.readFromAsString(entityStream, mediaType); final String[] splitArray = str.split("&"); for (String s : splitArray) { final String[] keyValue = s.split("="); map.put(keyValue[0], keyValue[1]); } return new TokenResult(map); } }
@Override public TokenResult readFrom(Class<TokenResult> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { Map<String, Object> map = Maps.newHashMap(); final String str = ReaderWriter.readFromAsString(entityStream, mediaType); final String[] splitArray = str.split("&"); for (String s : splitArray) { final String[] keyValue = s.split("="); map.put(keyValue[0], keyValue[1]); } return new TokenResult(map); } }
public static XMLStreamReader createReader(final Reader reader, final JettisonConfig config) throws XMLStreamException { Reader nonEmptyReader = ensureNonEmptyReader(reader); switch (config.getNotation()) { case MAPPED_JETTISON: try { Configuration jmConfig; if (null == config.getXml2JsonNs()) { jmConfig = new Configuration(); } else { jmConfig = new Configuration(config.getXml2JsonNs()); } return new MappedXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader))), new MappedNamespaceConvention(jmConfig)); } catch (Exception ex) { throw new XMLStreamException(ex); } case BADGERFISH: try { return new BadgerFishXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader)))); } catch (Exception ex) { throw new XMLStreamException(ex); } } // This should not occur throw new IllegalArgumentException("Unknown JSON config"); }