/** * Returns the type of the rule. * @return the type of the rule. */ public short jsxGet_type() { return rule_.getType(); }
/** * Returns the type of the rule. * @return the type of the rule. */ public short jsxGet_type() { return rule_.getType(); }
/** * Returns the type of the rule. * @return the type of the rule. */ public short jsxGet_type() { return rule_.getType(); }
/** * Returns the type of the rule. * @return the type of the rule. */ @JsxGetter public short getType() { return rule_.getType(); }
/** * Creates a CSSRule according to the specified rule type. * @param stylesheet the Stylesheet of this rule * @param rule the wrapped rule * @return a CSSRule subclass according to the rule type */ public static CSSRule create(final Stylesheet stylesheet, final org.w3c.dom.css.CSSRule rule) { switch (rule.getType()) { case STYLE_RULE: return new CSSStyleRule(stylesheet, rule); case IMPORT_RULE: return new CSSImportRule(stylesheet, rule); default: throw new UnsupportedOperationException("CSSRule " + rule.getClass().getName() + " is not yet supported."); } }
/** * Creates a CSSRule according to the specified rule type. * @param stylesheet the Stylesheet of this rule * @param rule the wrapped rule * @return a CSSRule subclass according to the rule type */ public static CSSRule create(final Stylesheet stylesheet, final org.w3c.dom.css.CSSRule rule) { switch (rule.getType()) { case STYLE_RULE: return new CSSStyleRule(stylesheet, rule); case IMPORT_RULE: return new CSSImportRule(stylesheet, rule); default: throw new UnsupportedOperationException("CSSRule " + rule.getClass().getName() + " is not yet supported."); } }
/** * Creates a CSSRule according to the specified rule type. * @param stylesheet the Stylesheet of this rule * @param rule the wrapped rule * @return a CSSRule subclass according to the rule type */ public static CSSRule create(final Stylesheet stylesheet, final org.w3c.dom.css.CSSRule rule) { switch (rule.getType()) { case STYLE_RULE: return new CSSStyleRule(stylesheet, rule); case IMPORT_RULE: return new CSSImportRule(stylesheet, rule); default: throw new UnsupportedOperationException("CSSRule " + rule.getClass().getName() + " is not yet supported."); } }
public Map<String, CSSStyleRule> parseCSS() throws IOException { Map<String, CSSStyleRule> rules = new HashMap<String, CSSStyleRule>(); InputSource inputSource = new InputSource(new FileReader("bootstrap.css")); CSSStyleSheet styleSheet = new CSSOMParser().parseStyleSheet(inputSource, null, null); CSSRuleList ruleList = styleSheet.getCssRules(); for (int i = 0; i < ruleList.getLength(); i++) { CSSRule rule = ruleList.item(i); if (rule.getType() == CSSRule.STYLE_RULE) { CSSStyleRule styleRule = (CSSStyleRule) rule; rules.put(styleRule.getSelectorText(), styleRule); } } return rules; }
switch (rule.getType()) { case STYLE_RULE: return new CSSStyleRule(stylesheet, (org.w3c.dom.css.CSSStyleRule) rule);
private static StyleDefinition parseElementStyleDefinition(final String styleRaw) throws TranslatorException { final CSSStyleSheetImpl sheet = parseElementStyleSheet(styleRaw); final CSSRuleList cssRules = sheet.getCssRules(); for (int i = 0; i < cssRules.getLength(); i++) { final CSSRule item = cssRules.item(i); if (CSSRule.STYLE_RULE == item.getType()) { final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item; final CSSStyleDeclaration declaration = rule.getStyle(); return parseStyleDefinition(declaration); } } return null; }
public static StyleSheetDefinition parseStyleSheetDefinition(final String cssPath, final InputStream cssStream) throws TranslatorException { final CSSStyleSheetImpl sheet = parseStyleSheet(new InputSource(new InputStreamReader(cssStream))); final CSSRuleList cssRules = sheet.getCssRules(); final StyleSheetDefinition result = new StyleSheetDefinition(cssPath); for (int i = 0; i < cssRules.getLength(); i++) { final CSSRule item = cssRules.item(i); if (CSSRule.STYLE_RULE == item.getType()) { final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item; final String selectorText = rule.getSelectorText(); final CSSStyleDeclaration declaration = rule.getStyle(); final StyleDefinition styleDefinition = parseStyleDefinition(declaration); result.addStyle(selectorText, styleDefinition); } } return result; }
if (r.getType() == CSSRule.CHARSET_RULE) { encoding_ = ((CSSCharsetRuleImpl) r).encoding_;
if (r.getType() == CSSRule.MEDIA_RULE) { media_ = ((CSSMediaRuleImpl) r).media_; cssRules_ = ((CSSMediaRuleImpl) r).cssRules_;
if (r.getType() == CSSRule.UNKNOWN_RULE) { text_ = ((CSSUnknownRuleImpl) r).text_;
if (r.getType() == CSSRule.FONT_FACE_RULE) { style_ = ((CSSFontFaceRuleImpl) r).style_;
if (r.getType() == CSSRule.IMPORT_RULE) { href_ = ((CSSImportRuleImpl) r).href_; media_ = ((CSSImportRuleImpl) r).media_;
if (r.getType() == CSSRule.IMPORT_RULE) { href_ = ((CSSImportRuleImpl) r).href_; media_ = ((CSSImportRuleImpl) r).media_;
if (r.getType() == CSSRule.PAGE_RULE) { pseudoPage_ = ((CSSPageRuleImpl) r).pseudoPage_; style_ = ((CSSPageRuleImpl) r).style_;
if (r.getType() == CSSRule.STYLE_RULE) { selectors_ = ((CSSStyleRuleImpl) r).selectors_; style_ = ((CSSStyleRuleImpl) r).style_;
public void visitRule(CSSRule rule) { switch (rule.getType()) { case CSSRule.UNKNOWN_RULE: visitUnknownRule((CSSUnknownRule) rule); break; case CSSRule.STYLE_RULE: visitStyleRule((CSSStyleRule) rule); break; case CSSRule.CHARSET_RULE: visitCharsetRule((CSSCharsetRule) rule); break; case CSSRule.IMPORT_RULE: visitImportRule((CSSImportRule) rule); break; case CSSRule.MEDIA_RULE: visitMediaRule((CSSMediaRule) rule); break; case CSSRule.FONT_FACE_RULE: visitFontFaceRule((CSSFontFaceRule) rule); break; case CSSRule.PAGE_RULE: visitPageRule((CSSPageRule) rule); break; default: throw new IllegalArgumentException(); } }