本文整理匯總了Java中org.jsoup.select.Elements.forEach方法的典型用法代碼示例。如果您正苦於以下問題:Java Elements.forEach方法的具體用法?Java Elements.forEach怎麽用?Java Elements.forEach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jsoup.select.Elements
的用法示例。
在下文中一共展示了Elements.forEach方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setQuestion
import org.jsoup.select.Elements; //導入方法依賴的package包/類
public void setQuestion(ExamSectionQuestion esq) {
Document doc = Jsoup.parse(esq.getQuestion().getQuestion());
Elements blanks = doc.select(CLOZE_SELECTOR);
blanks.forEach(b -> {
boolean isNumeric = isNumeric(b);
Iterator<Attribute> it = b.attributes().iterator();
while (it.hasNext()) {
Attribute a = it.next();
if (!a.getKey().equals("id")) {
it.remove();
}
}
b.tagName("input");
b.text("");
b.attr("type", isNumeric ? "number" : "text");
b.attr("class", "cloze-input");
if (isNumeric) {
b.attr("step", "any");
// Should allow for using both comma and period as decimal separator
b.attr( "lang", "en-150");
}
});
this.question = doc.body().children().toString();
}
示例2: findOrders
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private ArrayList<ApsvOrder> findOrders(String html) {
//logger.info("Html: {}", html);
ArrayList<ApsvOrder> orders = new ArrayList<>();
Document doc = Jsoup.parse(html);
Element ordersForm = doc.getElementById("J-submit-form");
if (ordersForm == null) {
logger.error("Cannot find order list form, maybe cookie expires");
// 標記task status為異常
// TODO 彈窗提醒cookie異常
RunTasksModel.getInstance().MarkTaskException(task.id);
return orders;
}
Elements tableBody = doc.select("#tradeRecordsIndex>tbody");
Elements orderRows = tableBody.select("tr");
orderRows.forEach(row -> {
Elements timeNodes = row.select("td.time p");
String[] orderNoData = row.select("td.tradeNo p").text().split("\\|");
ApsvOrder order = new ApsvOrder(){
{
taskId = task.id;
time = timeNodes.get(0).text() + " " + timeNodes.get(timeNodes.size() - 1).text();
description = row.select(".memo-info").text();
memo = row.select("td.memo p").text();
tradeNo = orderNoData.length > 1 ? orderNoData[1].split(":")[1] : orderNoData[0].split(":")[1];
username = Unicode.unicodeToString(row.select("td.other p").text());
amount = Float.parseFloat(row.select("td.amount span").text().replaceAll("\\s+", ""));
status = row.select("td.status p").text();
}
};
order.sig = Order.Sign(order, task.pushSecret);
orders.add(order);
});
return orders;
}
示例3: assertOnlyAllowedChildren
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private void assertOnlyAllowedChildren(Elements elements) {
elements.forEach(element -> {
if (!ALLOWED_CHILDREN.contains(element.tagName())) {
throw new IllegalArgumentException("Illegal tag found: " + element.tagName() +
". Allowed tags: " +
ALLOWED_CHILDREN.stream()
.collect(Collectors.joining(", ")));
}
});
}
示例4: setQuestionWithResults
import org.jsoup.select.Elements; //導入方法依賴的package包/類
public void setQuestionWithResults(ExamSectionQuestion esq) {
Map<String, String> answers = asMap(new Gson());
Document doc = Jsoup.parse(esq.getQuestion().getQuestion());
Elements blanks = doc.select(CLOZE_SELECTOR);
score = new Score();
blanks.forEach(b -> {
boolean isNumeric = isNumeric(b);
boolean isCorrectAnswer = isCorrectAnswer(b, answers);
String precision = b.attr("precision");
if (isCorrectAnswer) {
score.correctAnswers++;
} else {
score.incorrectAnswers++;
}
Iterator<Attribute> it = b.attributes().iterator();
while (it.hasNext()) {
Attribute a = it.next();
if (!a.getKey().equals("id")) {
it.remove();
}
}
b.tagName("input");
b.text("");
b.attr("class", isCorrectAnswer ? "cloze-correct" : "cloze-incorrect");
b.attr("type", isNumeric ? "number" : "text");
if (isNumeric) {
b.append("<span class=\"cloze-precision\">[±" + precision + "]</span>");
}
});
this.question = doc.body().children().toString();
}
示例5: getScore
import org.jsoup.select.Elements; //導入方法依賴的package包/類
public Score getScore(ExamSectionQuestion esq) {
Map<String, String> answers = asMap(new Gson());
Document doc = Jsoup.parse(esq.getQuestion().getQuestion());
Elements blanks = doc.select(CLOZE_SELECTOR);
Score score = new Score();
blanks.forEach(b -> {
boolean isCorrectAnswer = isCorrectAnswer(b, answers);
if (isCorrectAnswer) {
score.correctAnswers++;
} else {
score.incorrectAnswers++;
}
});
return score;
}