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;
        }
    }
public List < MediaQuery > parseMediaQuery ( String query ) { try { CSSInputStream input = CSSInputStream . stringStream ( query ) ; input . setBase ( new URL ( "file://media/query/url" ) ) ; CSSParser parser = createParserForInput ( input ) ; 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 ( RecognitionException e ) { log . warn ( "Malformed media query {}" , query ) ; return null ; } }
Parses a media query from a string (e.g. the 'media' HTML attribute).

@param query The query string
@return List of media queries found.