Package org.w3c.css.sac

Examples of org.w3c.css.sac.InputSource


        oldProperties = new PropertyMap(properties);
  properties = new PropertyMap();
  try {
      Reader r = new StringReader(cssText);
      parser.setDocumentHandler(handler);
      parser.parseStyleDeclaration(new InputSource(r));
  } catch (DOMException e) {
      properties = pm;
      oldProperties = null;
      fireCSSStyleDeclarationChangeCancel();
      throw e;
View Full Code Here


    public void setProperty(String propertyName, String value, String prio)
  throws DOMException {
  try {
      ValueFactory f;
            f = factories.get(propertyName.toLowerCase().intern());
      InputSource is = new InputSource(new StringReader(value));
      LexicalUnit lu = parser.parsePropertyValue(is);
      f.createCSSValue(lu, this, prio);
  } catch (Exception e) {
            e.printStackTrace();
      throw CSSDOMExceptionFactory.createDOMException
View Full Code Here

      fireCSSStyleRuleChangeStart();
      style = new CSSOMStyleDeclaration(this, parser);
      style.addCSSStyleDeclarationChangeListener(this);
      style.fireCSSStyleDeclarationChangeStart();

      InputSource is = new InputSource(new StringReader(cssText));
      parser.setSelectorFactory(SELECTOR_FACTORY);
      parser.setConditionFactory(CONDITION_FACTORY);
      parser.setDocumentHandler(ruleHandler);
      parser.parseRule(is);
  } catch (DOMException e) {
View Full Code Here

     * <b>DOM</b>: Implements
     * {@link org.w3c.dom.css.CSSStyleRule#setSelectorText(String)}.
     */
    public void setSelectorText(String selectorText) throws DOMException {
  try {
      InputSource is = new InputSource(new StringReader(selectorText));
      parser.setSelectorFactory(SELECTOR_FACTORY);
      parser.setConditionFactory(CONDITION_FACTORY);
      SelectorList sl = selectors;
      selectors = parser.parseSelectors(is);
      if (styleRuleChangeSupport != null) {
View Full Code Here

    }

    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.setErrorHandler(errors);

      final List<Value> values = new ArrayList<Value>();
      parser.setDocumentHandler(new PropertyExtractor(values));

      try {
        String dummy = "* { prop : " + value + "}";
        parser.parseStyleSheet(new InputSource(new StringReader(dummy)));
      } catch (IOException e) {
        assert false : "Should never happen";
      }

      if (values.size() < 2) {
View Full Code Here

      // 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 {
View Full Code Here

    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 {
View Full Code Here

        file = file.getCanonicalFile();

        SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl();
        ScssStylesheet stylesheet = handler.getStyleSheet();

        InputSource source = stylesheet.resolveStylesheet(identifier);
        if (source == null) {
            return null;
        }
        source.setEncoding(encoding);

        Parser parser = new Parser();
        parser.setErrorHandler(new SCSSErrorHandler());
        parser.setDocumentHandler(handler);
View Full Code Here

        if (resolvers == null) {
            setStylesheetResolvers(new VaadinResolver());
        }

        for (ScssStylesheetResolver resolver : resolvers) {
            InputSource source = resolver.resolve(identifier);
            if (source != null) {
                File f = new File(source.getURI());
                setFileName(f.getParent());
                return source;
            }
        }
View Full Code Here

   * @param css CSS
   */
  private void processStylesheet(String css) {
    try {
      CSSOMParser parser = new CSSOMParser();
      InputSource is = new InputSource(new StringReader(css));
      CSSStyleSheet stylesheet = parser.parseStyleSheet(is);
      CSSRuleList list = stylesheet.getCssRules();
      //      ArrayList assists = new ArrayList();
      for (int i = 0; i < list.getLength(); i++) {
        CSSRule rule = list.item(i);
        if (rule instanceof CSSStyleRule) {
          CSSStyleRule styleRule = (CSSStyleRule) rule;
          String selector = styleRule.getSelectorText();
          SelectorList selectors = parser.parseSelectors(new InputSource(new StringReader(selector)));
          for (int j = 0; j < selectors.getLength(); j++) {
            Selector sel = selectors.item(j);
            if (sel instanceof ConditionalSelector) {
              Condition cond = ((ConditionalSelector) sel).getCondition();
              SimpleSelector simple = ((ConditionalSelector) sel).getSimpleSelector();
View Full Code Here

TOP

Related Classes of org.w3c.css.sac.InputSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.