Parse the given input source and return the media list.
@param source the input source
@return new media list
@throws IOException in case of errors
329967
public MediaQueryList parseMedia(final InputSource source) throws IOException {
        source_ = source;
        ReInit(getCharStream(source));
        final MediaQueryList ml = new MediaQueryList();
        try {
            mediaList(ml);
        }
        catch (final ParseException e) {
            getErrorHandler().error(toCSSParseException("invalidMediaList", e));
        }
        catch (final TokenMgrError e) {
            getErrorHandler().error(toCSSParseException(e));
        }
        catch (final CSSParseException e) {
            getErrorHandler().error(e);
        }
        return ml;
    }
259626
protected JSONObject toReponsiveImageSource(Media media, MediaFormat mediaFormat) {
    String url = buildDummyImageUrl(mediaFormat);
    try {
      JSONObject source = new JSONObject();
      source.put(MediaNameConstants.PROP_BREAKPOINT, mediaFormat.getProperties().get(MediaNameConstants.PROP_BREAKPOINT));
      source.put(ResponsiveImageMediaMarkupBuilder.PROP_SRC, url);
      return source;
    }
    catch (JSONException ex) {
      throw new RuntimeException("Error building JSON source.", ex);
    }
  }
1260155
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    private static SortedSet<MediaType> parse(final String text) {
        final SortedSet<MediaType> list = new TreeSet<>();
        for (final String name
            : new EnglishLowerCase(text).string().split(",")) {
            if (!name.isEmpty()) {
                list.add(new MediaType(name));
            }
        }
        return list;
    }
231913
public void parse(final CssSource source, final CssErrorHandler err, final CssContentHandler doc) throws
      IOException,
      CssException
  {
    parse(source.newReader(), source.getSystemID(), err, doc);
  }
1136626
public static List<String> readLines(InputStream input) throws IOException {
        final InputStreamReader reader = new InputStreamReader(input);
        return readLines(reader);
    }
568593
public synchronized Node parse(InputSource source) throws IOException, SAXException
    {
//        _dtd=null;
        Handler handler = new Handler();
        XMLReader reader = _parser.getXMLReader();
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.setEntityResolver(handler);
        if (logger.isDebugEnabled())
            logger.debug("parsing: sid=" + source.getSystemId() + ",pid=" + source.getPublicId());
        _parser.parse(source, handler);
        if (handler.error != null)
            throw handler.error;
        Node root = (Node)handler.root;
        handler.reset();
        return root;
    }
1020674
protected Document parseContent(final InputStream in) throws Throwable {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);

    DocumentBuilder builder = factory.newDocumentBuilder();

    return builder.parse(new InputSource(new InputStreamReader(in)));
  }
994978
public static List<String> parseStringToStringList(String source,
                                                       String token) {

        if (StringUtils.isBlank(source) || StringUtils.isEmpty(token)) {
            return null;
        }

        List<String> result = new ArrayList<String>();

        String[] units = source.split(token);
        for (String unit : units) {
            result.add(unit);
        }
        return result;
    }
1218540
public static <T> List<T> wrap(final List<T> source) {
        val list = new ArrayList<T>();
        if (source != null && !source.isEmpty()) {
            list.addAll(source);
        }
        return list;
    }
1284137
@Override
	public Object parse(String source) throws Exception {
		Source s = sources.poll();
		final char[] chars = source.toCharArray();
		if (s == null) {
			s = new Source(chars);
		} else {
			s.set(chars);
		}
		final Object result = parseNext(s);
		if (sources.size() > Config.POOL_SIZE) {
			return result;
		}
		sources.add(s);
		return result;
	}
266401
public List<MediaQuery> parseMediaQuery(String query) {
        try {
            // input from string
            CSSInputStream input = CSSInputStream.stringStream(query);
            input.setBase(new URL("file://media/query/url")); //this URL should not be used, just for safety
            // create parser
            CSSParser parser = createParserForInput(input);
            // visitor
            CSSParserVisitorImpl visitor = new CSSParserVisitorImpl();
            return visitor.visitMedia(parser.media());
        } catch (IOException e) {
            log.error("I/O error during media query parsing: {}", e.getMessage());
            return null;
        }/* catch (CSSException e) {
            log.warn("Malformed media query {}", query);
            return null;
        } */ catch (RecognitionException e) {
            log.warn("Malformed media query {}", query);
            return null;
        }
    }
106940
public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema)
            throws IOException
    {
        return parseListFrom(in, schema, DEFAULT_INPUT_FACTORY);
    }
529212
public String loadTextFile(File source) throws IOException
	{
		StringBuffer _result = new StringBuffer();
		append(source, _result);
		return _result.toString();
	}
838972
public List<T> parseList(String jsonString) throws IOException {
        JsonParser jsonParser = LoganSquare.JSON_FACTORY.createParser(jsonString);
        jsonParser.nextToken();
        return parseList(jsonParser);
    }
1358745
@SuppressWarnings("unchecked")
	public static <T> T readObjectFromXml(InputSource source) throws IOException {
		Object result = null;
		XMLDecoder xmldec = null;
		try {
			xmldec = new XMLDecoder(source);
			result = xmldec.readObject();
		} finally {
			IoUtil.close(xmldec);
		}
		return (T) result;
	}
1221257
public static Document readXML(InputSource source) {
		final DocumentBuilder builder = createDocumentBuilder();
		try {
			return builder.parse(source);
		} catch (Exception e) {
			throw new UtilException(e, "Parse XML from stream error!");
		}
	}
177013
public Object read(InputStream is, Class type, MediaType mediaType)
            throws IOException {
        XStream xstream = getXStreamInstance(mediaType);
        if (xstream != null) {
            return xstream.fromXML(is);
        } else {
            throw new IllegalArgumentException("Content-type: "
                    + mediaType.getType() + " is currently not supported for "
                    + type.getName());
        }
    }