All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blade.mvc.ui.HtmlCreator Maven / Gradle / Ivy

There is a newer version: 2.0.15.RELEASE
Show newest version
package com.blade.mvc.ui;

import com.blade.mvc.Const;

import java.util.List;

public class HtmlCreator {

    private static final String HTML_FOOTER = "

Copyright © Blade-" + Const.VERSION + "


"; private StringBuilder html = new StringBuilder(); public HtmlCreator() { html.append(""); html.append(""); html.append(""); html.append(""); } public HtmlCreator title(String title) { html.append("").append(title).append(""); return this; } public HtmlCreator h1(String heading) { html.append(""); html.append(""); html.append("

").append(heading).append("

"); return this; } public HtmlCreator h2(String heading) { html.append("

").append(heading).append("

"); return this; } public HtmlCreator paragraph(String paragraph) { html.append("

").append(paragraph).append("

"); return this; } public HtmlCreator startP() { html.append("

"); return this; } public HtmlCreator startP(String className) { html.append("

"); return this; } public HtmlCreator addBold(String text) { html.append("").append(text).append(""); return this; } public HtmlCreator endP() { html.append("

"); return this; } public HtmlCreator hr() { html.append("
"); return this; } public HtmlCreator br() { html.append("
"); return this; } public HtmlCreator addTableWithHeaders(List headers) { html.append(""); html.append(""); headers.forEach((h) -> html.append("")); html.append(""); return this; } public HtmlCreator addRowToTable(List rowElements) { html.append(""); rowElements.forEach((re) -> html.append("")); html.append(""); return this; } public HtmlCreator endTable() { html.append("
").append(h).append("
").append(re).append("
"); return this; } public HtmlCreator startStyle() { html.append(""); return this; } public HtmlCreator centerHeadings() { html.append("h1, h2 { text-align: center; }"); return this; } public HtmlCreator add(String text) { html.append(text); return this; } public HtmlCreator styleTables() { html.append("table, th, td { margin: 0 auto; border: 1px solid black; border-collapse: collapse; text-align: center; }"); return this; } public HtmlCreator center(String text) { html.append("
").append(text).append("
"); return this; } @Override public String toString() { return html.toString(); } public String html() { html.append(HTML_FOOTER); html.append(""); return html.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy