Search in sources :

Example 1 with CssSelector

use of org.freud.analysed.css.rule.selector.CssSelector in project freud by LMAX-Exchange.

the class CssRuleJdom method parseSelectors.

@SuppressWarnings("unchecked")
private void parseSelectors() {
    cssSelectorList = new ArrayList<CssSelector>();
    final List<Element> children = ruleElement.getChildren();
    int index = 0;
    CssSelector.Combinator combinator = null;
    for (Element child : children) {
        if (CssTokenType.COMMA.name().equals(child.getName())) {
            index++;
        } else if (getCommaSeparatedSelectorListIndex() == index) {
            if (CssSelector.Type.isType(child.getName())) {
                final String selectorString = child.getAttributeValue(JdomTreeAdaptor.ID_ATTR);
                CssSelector.Type selectorType = CssSelector.Type.valueOf(child.getName());
                if (selectorString != null) {
                    Iterable<String> selectors = breakIdentToSelectors(selectorString);
                    for (String selector : selectors) {
                        cssSelectorList.add(new CssSelectorJdom(this, selector, selectorType, combinator));
                        combinator = CssSelector.Combinator.DESCENDANT;
                        selectorType = CssSelector.Type.CLASS;
                    }
                } else {
                    cssSelectorList.add(new CssSelectorJdom(this, null, selectorType, combinator));
                    combinator = CssSelector.Combinator.DESCENDANT;
                }
            } else if (CssSelector.Combinator.isCombinator(child.getName())) {
                combinator = CssSelector.Combinator.valueOf(child.getName());
            }
        }
    }
}
Also used : CssTokenType(org.freud.analysed.css.parser.CssTokenType) CssSelector(org.freud.analysed.css.rule.selector.CssSelector) Element(org.jdom.Element)

Aggregations

CssTokenType (org.freud.analysed.css.parser.CssTokenType)1 CssSelector (org.freud.analysed.css.rule.selector.CssSelector)1 Element (org.jdom.Element)1