Coverage Report - net.sf.jolene.dom.GridCell
 
Classes in this File Line Coverage Branch Coverage Complexity
GridCell
88%
29/33
86%
12/14
0
 
 1  
 package net.sf.jolene.dom;
 2  
 
 3  
 import net.sf.jolene.constants.Tags;
 4  
 
 5  
 /**
 6  
  * @author Dan Howard
 7  
  * @since Oct 10, 2005 8:48:27 AM
 8  
  */
 9  0
 final class GridCell extends HTMLElement {
 10  
 
 11  150
     private boolean header = false;
 12  150
     private HTMLElement cellObject = null;
 13  
 
 14  150
     GridCell() {
 15  150
         tag = Tags.td;
 16  150
     }
 17  
 
 18  
     GridCell(GridColumn column) {
 19  27
         this();
 20  
 
 21  27
         if (column.getWidth().length() > 0) {
 22  9
             setAttribute("width", column.getWidth());
 23  
         }
 24  
 
 25  27
         if (column.getAlign().length() > 0) {
 26  0
             setAttribute("align", column.getAlign());
 27  
         }
 28  
 
 29  27
         cellObject = column.getCellObject();
 30  
 
 31  27
         setValue(column.getHeader());
 32  
 
 33  27
     }
 34  
 
 35  
     @Override
 36  
     public String toString() {
 37  143
         if (swapWith != null) {
 38  0
             return swapWith.toString();
 39  
         }
 40  
 
 41  143
         if (header) {
 42  12
             tag = Tags.th;
 43  
         }
 44  
         String renderString;
 45  
 
 46  143
         if (cellObject == null || Tags.th == tag) {
 47  139
             renderString = super.toString() + getValue() + "</" + tag + '>';
 48  
         } else {
 49  4
             renderString = super.toString() + cellObject + "</" + tag + '>';
 50  
         }
 51  
 
 52  143
         return renderString;
 53  
     }
 54  
 
 55  
     boolean isHeader() {
 56  0
         return header;
 57  
     }
 58  
 
 59  
     void setHeader(boolean header) {
 60  143
         this.header = header;
 61  143
     }
 62  
 
 63  
 
 64  
     @Override
 65  
     public void setValue(String value) {
 66  170
         super.setValue(value);
 67  
 
 68  170
         if (cellObject != null) {
 69  10
             cellObject.setValue(value);
 70  
         }
 71  170
     }
 72  
 
 73  
 
 74  
     void setCellObject(HTMLElement cellObject) {
 75  4
         this.cellObject = cellObject;
 76  4
     }
 77  
 
 78  
 
 79  
     HTMLElement getCellObject() {
 80  4
         return cellObject;
 81  
     }
 82  
 
 83  
 
 84  
     @Override
 85  
     public GridCell clone() {
 86  6
         return (GridCell) super.clone();
 87  
     }
 88  
 }