Search in sources :

Example 1 with CssRule

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

the class CssJdomParser method parseCssRules.

@SuppressWarnings("unchecked")
static Iterable<CssRule> parseCssRules(final Reader reader) throws RecognitionException, IOException {
    List<CssRule> cssRuleList = new ArrayList<CssRule>();
    Document root = parseCssToDocument(reader);
    JXPathContext context = JXPathContext.newContext(root.getRootElement());
    List<Element> cssRuleElementList = (List<Element>) context.selectNodes("/RULE");
    for (Element element : cssRuleElementList) {
        final CssRuleJdom cssRuleJdom = new CssRuleJdom(element, 0);
        cssRuleList.add(cssRuleJdom);
        for (int i = 1; i < cssRuleJdom.getNumberOfCommaSeparatedSelectorLists(); i++) {
            cssRuleList.add(new CssRuleJdom(element, i));
        }
    }
    return cssRuleList;
}
Also used : JXPathContext(org.apache.commons.jxpath.JXPathContext) CssRule(org.freud.analysed.css.rule.CssRule) Element(org.jdom.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Document(org.jdom.Document)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 JXPathContext (org.apache.commons.jxpath.JXPathContext)1 CssRule (org.freud.analysed.css.rule.CssRule)1 Document (org.jdom.Document)1 Element (org.jdom.Element)1