Search in sources :

Example 6 with Element

use of com.smartandroid.sa.tag.nodes.Element in project SmartAndroidSource by jaychou2012.

the class Elements method clone.

/**
	 * Creates a deep copy of these elements.
	 * 
	 * @return a deep copy
	 */
@Override
public Elements clone() {
    Elements clone;
    try {
        clone = (Elements) super.clone();
    } catch (CloneNotSupportedException e) {
        throw new RuntimeException(e);
    }
    List<Element> elements = new ArrayList<Element>();
    clone.contents = elements;
    for (Element e : contents) elements.add(e.clone());
    return clone;
}
Also used : FormElement(com.smartandroid.sa.tag.nodes.FormElement) Element(com.smartandroid.sa.tag.nodes.Element) ArrayList(java.util.ArrayList)

Example 7 with Element

use of com.smartandroid.sa.tag.nodes.Element in project SmartAndroidSource by jaychou2012.

the class Elements method traverse.

/**
	 * Perform a depth-first traversal on each of the selected elements.
	 * 
	 * @param nodeVisitor
	 *            the visitor callbacks to perform on each node
	 * @return this, for chaining
	 */
public Elements traverse(NodeVisitor nodeVisitor) {
    Validate.notNull(nodeVisitor);
    NodeTraversor traversor = new NodeTraversor(nodeVisitor);
    for (Element el : contents) {
        traversor.traverse(el);
    }
    return this;
}
Also used : FormElement(com.smartandroid.sa.tag.nodes.FormElement) Element(com.smartandroid.sa.tag.nodes.Element)

Example 8 with Element

use of com.smartandroid.sa.tag.nodes.Element in project SmartAndroidSource by jaychou2012.

the class HtmlTreeBuilder method inSelectScope.

boolean inSelectScope(String targetName) {
    Iterator<Element> it = stack.descendingIterator();
    while (it.hasNext()) {
        Element el = it.next();
        String elName = el.nodeName();
        if (elName.equals(targetName))
            return true;
        if (// all elements
        !StringUtil.in(elName, TagSearchSelectScope))
            // except
            return false;
    }
    Validate.fail("Should not be reachable");
    return false;
}
Also used : FormElement(com.smartandroid.sa.tag.nodes.FormElement) Element(com.smartandroid.sa.tag.nodes.Element)

Example 9 with Element

use of com.smartandroid.sa.tag.nodes.Element in project SmartAndroidSource by jaychou2012.

the class HtmlTreeBuilder method pushActiveFormattingElements.

// active formatting elements
void pushActiveFormattingElements(Element in) {
    int numSeen = 0;
    Iterator<Element> iter = formattingElements.descendingIterator();
    while (iter.hasNext()) {
        Element el = iter.next();
        if (// marker
        el == null)
            break;
        if (isSameFormattingElement(in, el))
            numSeen++;
        if (numSeen == 3) {
            iter.remove();
            break;
        }
    }
    formattingElements.add(in);
}
Also used : FormElement(com.smartandroid.sa.tag.nodes.FormElement) Element(com.smartandroid.sa.tag.nodes.Element)

Example 10 with Element

use of com.smartandroid.sa.tag.nodes.Element in project SmartAndroidSource by jaychou2012.

the class HtmlTreeBuilder method insertInFosterParent.

void insertInFosterParent(Node in) {
    Element fosterParent = null;
    Element lastTable = getFromStack("table");
    boolean isLastTableParent = false;
    if (lastTable != null) {
        if (lastTable.parent() != null) {
            fosterParent = lastTable.parent();
            isLastTableParent = true;
        } else
            fosterParent = aboveOnStack(lastTable);
    } else {
        // no table == frag
        fosterParent = stack.get(0);
    }
    if (isLastTableParent) {
        // last table cannot be null by this
        Validate.notNull(lastTable);
        // point.
        lastTable.before(in);
    } else
        fosterParent.appendChild(in);
}
Also used : FormElement(com.smartandroid.sa.tag.nodes.FormElement) Element(com.smartandroid.sa.tag.nodes.Element)

Aggregations

Element (com.smartandroid.sa.tag.nodes.Element)21 FormElement (com.smartandroid.sa.tag.nodes.FormElement)13 Document (com.smartandroid.sa.tag.nodes.Document)4 Elements (com.smartandroid.sa.tag.select.Elements)2 Attribute (com.smartandroid.sa.tag.nodes.Attribute)1 Attributes (com.smartandroid.sa.tag.nodes.Attributes)1 Node (com.smartandroid.sa.tag.nodes.Node)1 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1