Package jodd.csselly.selector

Examples of jodd.csselly.selector.PseudoFunctionSelector


  public void addPseudoClassSelector(String pseudoClass) {
    selectors.add(new PseudoClassSelector(pseudoClass));
  }

  public void addPseudoFunctionSelector(String pseudoFunction, String expression) {
    selectors.add(new PseudoFunctionSelector(pseudoFunction, expression));
  }
View Full Code Here


        case PSEUDO_CLASS:
          PseudoClassSelector psc = (PseudoClassSelector) selector;
          out.append(':').append(psc.getPseudoClass().getPseudoClassName());
          break;
        case PSEUDO_FUNCTION:
          PseudoFunctionSelector pfns = (PseudoFunctionSelector) selector;
          out.append(':').append(pfns.getPseudoFunction().getPseudoFunctionName()).append('(');
          out.append(pfns.getExpression()).append(')');
          break;
      }
    }

    if (nextCssSelector != null) {
View Full Code Here

    assertEquals(1, selectors.size());
    assertEquals("div:nth-child(2n+1)", CSSelly.toString(selectors));

    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

    selectors = lexer.parse();

    assertEquals(1, selectors.size());
    cssSelector = selectors.get(0);

    PseudoFunctionSelector pseudoFunctionSelector = (PseudoFunctionSelector) cssSelector.getSelector(0);

    assertEquals("contains", pseudoFunctionSelector.getPseudoFunction().getPseudoFunctionName());

  }
View Full Code Here

TOP

Related Classes of jodd.csselly.selector.PseudoFunctionSelector

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.