void parseDef(String atRule) { String value = atRule.substring(4, atRule.length()).trim(); InputSource s = new InputSource(); s.setCharacterStream(new StringReader(value)); Parser parser = new Parser(); parser.parseStyleSheet(new InputSource(new StringReader(dummy))); } catch (IOException e) { assert false : "Should never happen";
private <T extends CssNode & HasNodes> void parseInnerStylesheet( String tagName, T parent, String blockContents) { pushParent(parent); // parse the inner text InputSource s = new InputSource(); s.setCharacterStream(new StringReader(blockContents)); Parser parser = new Parser(); parser.setDocumentHandler(this); parser.setErrorHandler(errors); try { parser.parseStyleSheet(s); } catch (IOException e) { throw new CSSException(CSSException.SAC_SYNTAX_ERR, "Unable to parse " + tagName, e); } if (currentParent.pop() != parent) { // This is a coding error throw new RuntimeException("Incorrect element popped"); } }
void parseSprite(String atRule) throws CSSException { CssSprite sprite = new CssSprite(); currentRule = sprite; addNode(sprite); // Flag to tell startSelector() to use the CssSprite instead of creating // its own CssRule. nextSelectorCreatesRule = false; // parse the inner text InputSource s = new InputSource(); s.setCharacterStream(new StringReader(atRule.substring(7))); Parser parser = new Parser(); parser.setDocumentHandler(this); parser.setErrorHandler(errors); try { parser.parseRule(s); } catch (IOException e) { throw new CSSException(CSSException.SAC_SYNTAX_ERR, "Unable to parse @sprite", e); } }
/** * <b>SAC</b>: Implements {@link * org.w3c.css.sac.Parser#parseStyleSheet(String)}. */ public void parseStyleSheet(String uri) throws CSSException, IOException { parseStyleSheet(new InputSource(uri)); }
/** * Parse a CSS rule. * * @exception CSSException Any CSS exception, possibly * wrapping another exception. * @exception java.io.IOException An IO exception from the parser, * possibly from a byte stream or character stream * supplied by the application. */ public void parseRule(String source) throws CSSException, IOException { parser.parseRule(new InputSource(new StringReader(source))); }
/** * Convenient method for URIs. * * @param systemId the fully resolved URI of the style sheet. * @throws IOException the source can't be parsed. * @throws CSSException the source is not CSS valid. */ public void parseStyleSheet( String systemId ) throws CSSException, IOException { parseStyleSheet( new InputSource( systemId ) ); }
/** * <b>SAC</b>: Implements {@link * _org.w3c.css.sac.Parser#parseStyleSheet(String)}. */ public void parseStyleSheet(String uri) throws CSSException, IOException { parseStyleSheet(new InputSource(uri)); }
/** * Convenient method for URIs. * * @param systemId the fully resolved URI of the style sheet. * @exception IOException the source can't be parsed. * @exception CSSException the source is not CSS valid. */ public void parseStyleSheet(String systemId) throws CSSException, IOException { parseStyleSheet(new InputSource(systemId)); }
public StyleSheet parseStyleSheet(InputStream stream) throws IOException { InputSource source = new InputSource(); source.setByteStream(stream); return parseStyleSheet(source); }
public CSSStyleDeclaration parseStyleDeclaration(InputStream stream) throws IOException { InputSource source = new InputSource(); source.setByteStream(stream); return parseStyleDeclaration(source); }
public SelectorList parseSelectors(InputStream stream) throws IOException { InputSource source = new InputSource(); source.setByteStream(stream); return parseSelectors(source); }
public void setMediaText(final String mediaText) { final InputSource source = new InputSource(new StringReader(mediaText)); try { final CSSOMParser parser = new CSSOMParser(); final SACMediaList sml = parser.parseMedia(source); media_ = new MediaListImpl(sml); } catch (final IOException e) { // TODO handle exception } }
public CSSValue parsePropertyValue(InputStream stream) throws IOException { InputSource source = new InputSource(); source.setByteStream(stream); return parsePropertyValue(source); }
public CSSStyleDeclaration parseStyleDeclaration(Reader reader) throws IOException { InputSource source = new InputSource(); source.setCharacterStream(reader); return parseStyleDeclaration(source); }
public ResourceData[] getStyleResourcesForRules(String rules, Document doc, URL docUrl, URL base, int[] indexesToMatch) { // URL docUrl = InSyncService.getProvider().getUrl(doc); createCssEngineForDocument(doc, docUrl); InputSource is = new InputSource(new StringReader(rules)); StyleSheet ss = parseStyleSheetForDocument(doc, is, base, "all", base); // NOI18N return getStyleResourcesFromStyleSheet(doc, ss, indexesToMatch); }
public StyleSheet parseStyleSheet(Reader reader) throws IOException { InputSource source = new InputSource(); source.setCharacterStream(reader); return parseStyleSheet(source); }
public SelectorList parseSelectors(Reader reader) throws IOException { InputSource source = new InputSource(); source.setCharacterStream(reader); return parseSelectors(source); }
public CSSValue parsePropertyValue(Reader reader) throws IOException { InputSource source = new InputSource(); source.setCharacterStream(reader); return parsePropertyValue(source); }
public ResourceData[] getStyleResourcesForUrl(URL url, Document doc, URL docUrl, int[] indexesToMatch) { // URL docUrl = InSyncService.getProvider().getUrl(doc); createCssEngineForDocument(doc, docUrl); InputSource is = new InputSource(url.toString()); StyleSheet ss = parseStyleSheetForDocument(doc, is, url, "all", url); // NOI18N return getStyleResourcesFromStyleSheet(doc, ss, indexesToMatch); }
private String parse() throws IOException { InputStreamReader reader2 = new InputStreamReader(_cssUrl.openStream()); InputSource source2 = new InputSource(reader2); Parser p = new SACParserCSS2(); CssDocumentHandlerImpl handler = new CssDocumentHandlerImpl(_context, _parentBundle); p.setDocumentHandler(handler); p.parseStyleSheet(source2); reader2.close(); return handler.getResults(); }