Package jodd.csselly.selector

Examples of jodd.csselly.selector.PseudoFunctionExpression


    CssSelector cssSelector = selectors.get(0);
    assertEquals(1, cssSelector.selectorsCount());
    PseudoFunctionSelector pfns = (PseudoFunctionSelector) cssSelector.getSelector(0);
    assertEquals("nth-child", pfns.getPseudoFunction().getPseudoFunctionName());
    PseudoFunctionExpression pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(2, pfe.getValueA());
    assertEquals(1, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(odd)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    assertEquals("nth-child", pfns.getPseudoFunction().getPseudoFunctionName());
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(2, pfe.getValueA());
    assertEquals(1, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(even)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    assertEquals("nth-child", pfns.getPseudoFunction().getPseudoFunctionName());
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(2, pfe.getValueA());
    assertEquals(0, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(10n-1)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(10, pfe.getValueA());
    assertEquals(-1, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(10n+9)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(10, pfe.getValueA());
    assertEquals(9, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(0n+5)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(0, pfe.getValueA());
    assertEquals(5, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(5)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(0, pfe.getValueA());
    assertEquals(5, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(1n + 0)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(1, pfe.getValueA());
    assertEquals(0, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(n + 0)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(1, pfe.getValueA());
    assertEquals(0, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(n)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(1, pfe.getValueA());
    assertEquals(0, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(2n+0)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(2, pfe.getValueA());
    assertEquals(0, pfe.getValueB());

    lexer = new CSSelly("div:nth-child(2n)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(2, pfe.getValueA());
    assertEquals(0, pfe.getValueB());

    lexer = new CSSelly("div:nth-child( 3n + 1 )");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(3, pfe.getValueA());
    assertEquals(1, pfe.getValueB());

    lexer = new CSSelly("div:nth-child( +3n - 2 )");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(3, pfe.getValueA());
    assertEquals(-2, pfe.getValueB());

    lexer = new CSSelly("div:nth-child( -n+ 6)");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(-1, pfe.getValueA());
    assertEquals(6, pfe.getValueB());

    lexer = new CSSelly("div:nth-child( +6 )");
    pfns = (PseudoFunctionSelector) lexer.parse().get(0).getSelector(0);
    pfe = (PseudoFunctionExpression) pfns.getParsedExpression();
    assertEquals(0, pfe.getValueA());
    assertEquals(6, pfe.getValueB());
  }
View Full Code Here

TOP

Related Classes of jodd.csselly.selector.PseudoFunctionExpression

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.