1 13 package com.tonbeller.jpivot.table; 14 15 import org.apache.log4j.Logger; 16 import org.w3c.dom.Element ; 17 18 import com.tonbeller.jpivot.olap.model.Cell; 19 import com.tonbeller.jpivot.olap.model.Property; 20 import com.tonbeller.jpivot.table.span.PropertyUtils; 21 22 27 public class CellBuilderImpl extends PartBuilderSupport implements CellBuilder { 28 29 private static final Logger logger = Logger.getLogger(CellBuilderImpl.class); 30 private static final String STYLE = "style"; 31 private static final String NBSP = "\u00a0"; 32 35 public Element build(Cell cell, boolean even) { 36 Element cellElem = table.elem("cell"); 37 String s = cell.isNull() ? NBSP : cell.getFormattedValue(); 38 s = s.trim(); 39 if (s.length() == 0) 40 s = NBSP; 41 cellElem.setAttribute("value", s); 42 if (logger.isDebugEnabled()) 43 logger.debug("building cell " + s); 44 45 PropertyUtils.addProperties(cellElem, cell.getProperties()); 46 Property style = cell.getProperty(STYLE); 47 if (style != null) { 48 String value = style.getValue(); 49 if (value != null && value.length() > 0) 50 cellElem.setAttribute(STYLE, value); 51 else 52 cellElem.setAttribute(STYLE, even ? "even" : "odd"); 53 } 54 else 55 cellElem.setAttribute(STYLE, even ? "even" : "odd"); 56 57 return cellElem; 58 } 59 60 } 61 | Popular Tags |