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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations