package org.gcube.portlets.user.geoportaldataentry.client.ui.utils; /** * The Class HTMLUtil. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * * Jan 26, 2021 */ public class HTMLUtil { /** * The Enum HTML_TAG. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * * Jan 26, 2021 */ public static enum HTML_TAG { p, div, span } /** * Gets the HTML element. * * @param tag the tag * @param textSize the text size * @param rgb the rgb * @param fontWeight the font weight * @param text the text * @return the HTML element */ public static String getHTMLElement(HTML_TAG tag, Integer textSize, String rgb, String fontWeight, String text) { StringBuilder htmlEl = new StringBuilder(); if (textSize != null || rgb != null || fontWeight != null) { String style = ""; if (textSize != null) { style += "font-size:" + textSize + ";"; } if (rgb != null) { style += "color:#" + rgb + ";"; } if (fontWeight != null) { style += "font-weight:" + fontWeight + ";"; } htmlEl.append("<" + tag.name() + " style='" + style + "'>"); } else { htmlEl.append(tagOPEN(tag)); } if (text != null) { htmlEl.append(text); } htmlEl.append(tagCLosed(tag)); return htmlEl.toString(); } /** * Tag OPEN. * * @param tag the tag * @return the string */ public static String tagOPEN(HTML_TAG tag) { return "<" + tag.name() + ">"; } /** * Tag C losed. * * @param tag the tag * @return the string */ public static String tagCLosed(HTML_TAG tag) { return ""; } }