us.codecraft.xsoup.CombiningXElements Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xsoup Show documentation
Show all versions of xsoup Show documentation
HTML XPath selector based on Jsoup.
package us.codecraft.xsoup;
import org.jsoup.select.Elements;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author [email protected]
*/
public class CombiningXElements implements XElements {
private List elementsList;
public CombiningXElements(List elementsList) {
this.elementsList = elementsList;
}
public CombiningXElements(XElements... elementsList) {
this.elementsList = Arrays.asList(elementsList);
}
@Override
public String get() {
for (XElements xElements : elementsList) {
String result = xElements.get();
if (result != null) {
return result;
}
}
return null;
}
@Override
public List list() {
List results = new ArrayList();
for (XElements xElements : elementsList) {
results.addAll(xElements.list());
}
return results;
}
@Override
public Elements getElements() {
Elements elements = new Elements();
for (XElements xElements : elementsList) {
elements.addAll(xElements.getElements());
}
return elements;
}
}