Example usage for org.jsoup.nodes Element appendText

List of usage examples for org.jsoup.nodes Element appendText

Introduction

In this page you can find the example usage for org.jsoup.nodes Element appendText.

Prototype

public Element appendText(String text) 

Source Link

Document

Create and append a new TextNode to this element.

Usage

From source file:com.assignmentone.snippet.ShowCodeSnippet.java

private Element makeShowHtml(String file, String title, String contents) {

    // create the panel tag
    Element panel = new Element(Tag.valueOf("div"), "");
    panel.addClass("panel");
    panel.addClass("panel-default");

    Element heading = new Element(Tag.valueOf("div"), "");
    heading.addClass("panel-heading");

    Element body = new Element(Tag.valueOf("div"), "");
    body.addClass("panel-body");

    panel.appendChild(heading);/*from w  w w.j a va 2s  .c o m*/
    panel.appendChild(body);

    // write title and file path
    String headStr = StringUtils.isEmpty(title) ? "" : title + ":";
    headStr += file;
    heading.appendText(headStr);

    // create the pre tag
    Element pre = new Element(Tag.valueOf("pre"), "");
    pre.addClass("prettyprint source");
    pre.attr("style", "overflow-x:auto");
    if (contents != null) {
        pre.appendChild(new Element(Tag.valueOf("span"), "").appendText(contents));
    }
    body.appendChild(pre);
    return panel;
}