001package com.identityworksllc.iiq.common.table; 002 003import org.apache.commons.lang.StringEscapeUtils; 004import sailpoint.tools.Util; 005 006import java.util.ArrayList; 007import java.util.List; 008 009/** 010 * The root class of Table, Row, and Cell, which allows common functions 011 * for style, CSS class, and other common HTML elements 012 */ 013public abstract class Element { 014 /** 015 * The list of CSS classes to append to this cell 016 */ 017 protected List<String> cssClasses; 018 /** 019 * The value of the 'style' attribute for this cell 020 */ 021 protected String style; 022 023 protected Element() { 024 this.cssClasses = new ArrayList<>(); 025 this.style = ""; 026 } 027 028 public List<String> getCssClasses() { 029 return cssClasses; 030 } 031 032 protected String getEscapedCssClassAttr() { 033 StringBuilder output = new StringBuilder(); 034 for(String cls : Util.safeIterable(this.cssClasses)) { 035 output.append(StringEscapeUtils.escapeHtml(cls.trim())); 036 output.append(" "); 037 } 038 return output.toString().trim(); 039 } 040 041 public String getStyle() { 042 return style; 043 } 044 045 protected String getEscapedStyle() { 046 if (Util.isNullOrEmpty(style)) { 047 return style; 048 } 049 return StringEscapeUtils.escapeHtml(style.trim()); 050 } 051 052 public void setCssClasses(List<String> cssClasses) { 053 this.cssClasses = cssClasses; 054 } 055 056 public void setStyle(String style) { 057 this.style = style; 058 } 059}