Search in sources :

Example 11 with CSSParseException

use of com.gargoylesoftware.css.parser.CSSParseException in project LoboEvolution by LoboEvolution.

the class MediaListImpl method setMediaText.

/**
 * Parses the given media text.
 *
 * @param mediaText text to be parsed
 * @throws org.w3c.dom.DOMException in case of error
 */
public void setMediaText(final String mediaText) throws DOMException {
    try {
        final CSSOMParser parser = new CSSOMParser();
        parser.setErrorHandler(ThrowCssExceptionErrorHandler.INSTANCE);
        final MediaQueryList sml = parser.parseMedia(mediaText);
        setMediaList(sml);
    } catch (final CSSParseException e) {
        throw new DOMException(DOMException.SYNTAX_ERR, e.getLocalizedMessage());
    } catch (final IOException e) {
        throw new DOMException(DOMException.NOT_FOUND_ERR, e.getLocalizedMessage());
    }
}
Also used : DOMException(org.w3c.dom.DOMException) CSSParseException(com.gargoylesoftware.css.parser.CSSParseException) CSSOMParser(com.gargoylesoftware.css.parser.CSSOMParser) MediaQueryList(com.gargoylesoftware.css.parser.media.MediaQueryList) IOException(java.io.IOException)

Aggregations

CSSParseException (com.gargoylesoftware.css.parser.CSSParseException)11 CSSErrorHandler (com.gargoylesoftware.css.parser.CSSErrorHandler)4 Locator (com.gargoylesoftware.css.parser.Locator)4 IOException (java.io.IOException)4 CSSException (com.gargoylesoftware.css.parser.CSSException)3 CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)3 MediaQueryList (com.gargoylesoftware.css.parser.media.MediaQueryList)3 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)2 SelectorList (com.gargoylesoftware.css.parser.selector.SelectorList)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 LexicalUnit (com.gargoylesoftware.css.parser.LexicalUnit)1 IncorrectnessListener (com.gargoylesoftware.htmlunit.IncorrectnessListener)1 ScriptException (com.gargoylesoftware.htmlunit.ScriptException)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 WebClientOptions (com.gargoylesoftware.htmlunit.WebClientOptions)1 DisabledElement (com.gargoylesoftware.htmlunit.html.DisabledElement)1 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)1 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1 HtmlCheckBoxInput (com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput)1