Package jodd.csselly.selector

Examples of jodd.csselly.selector.AttributeSelector


    assertEquals("div", cssSelector.getElement());
    assertEquals(1, cssSelector.selectorsCount());

    Selector selector = cssSelector.getSelector(0);
    assertEquals(Selector.Type.ATTRIBUTE, selector.getType());
    AttributeSelector attributeSelector = (AttributeSelector) selector;
    assertEquals("a1", attributeSelector.getName());
    assertEquals("=", attributeSelector.getMatch().getSign());
    assertEquals("123", attributeSelector.getValue());

    lexer = new CSSelly("div[ a1 = \"123\" ]");
    selectors = lexer.parse();
    assertEquals("div[a1=\"123\"]", CSSelly.toString(selectors));
  }
View Full Code Here


    cssSelector = selectors.get(0);

    assertEquals("itunes:image", cssSelector.getElement());
    Selector selector = cssSelector.getSelector(0);

    AttributeSelector attributeSelector = (AttributeSelector)selector;

    assertEquals("foo:bar", attributeSelector.getValue());

  }
View Full Code Here

  // ---------------------------------------------------------------- attributes

  public void addIdSelector(String id) {
    id = unescape(id);
    selectors.add(new AttributeSelector(ID, EQUALS, id));
  }
View Full Code Here

    selectors.add(new AttributeSelector(ID, EQUALS, id));
  }

  public void addClassSelector(String clazz) {
    clazz = unescape(clazz);
    selectors.add(new AttributeSelector(CLASS, INCLUDES, clazz));
  }
View Full Code Here

    selectors.add(new AttributeSelector(CLASS, INCLUDES, clazz));
  }

  public void addAttributeSelector(String attribute) {
    attribute = unescape(attribute);
    selectors.add(new AttributeSelector(attribute));
  }
View Full Code Here

    out.append(element);

    for (Selector selector : selectors) {
      switch (selector.getType()) {
        case ATTRIBUTE:
          AttributeSelector attrSelector = (AttributeSelector) selector;
          String attrName = attrSelector.getName();
          if (attrName.equals(ID)) {
            out.append('#').append(attrSelector.getValue());
          } else if (attrName.equals(CLASS)) {
            out.append('.').append(attrSelector.getValue());
          } else {
            out.append('[').append(attrSelector.getName());
            String value = attrSelector.getValue();
            if (value != null) {
              out.append(attrSelector.getMatch().getSign());
              char quote = attrSelector.getQuoteChar();
              if (quote != 0) {
                out.append(quote);
              }
              out.append(value);
              if (quote != 0) {
View Full Code Here

TOP

Related Classes of jodd.csselly.selector.AttributeSelector

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.