当前位置: 首页>>代码示例>>Java>>正文


Java Elements.forEach方法代码示例

本文整理汇总了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();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:25,代码来源:ClozeTestAnswer.java

示例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;
}
 
开发者ID:thundernet8,项目名称:AlipayOrdersSupervisor-GUI,代码行数:39,代码来源:ApsvTimerTask.java

示例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(", ")));
    }
  });
}
 
开发者ID:Juchar,项目名称:md-stepper,代码行数:11,代码来源:Step.java

示例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\">[&plusmn;" + precision + "]</span>");
        }
    });
    this.question = doc.body().children().toString();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:32,代码来源:ClozeTestAnswer.java

示例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;
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:16,代码来源:ClozeTestAnswer.java


注:本文中的org.jsoup.select.Elements.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。