1 package org.tigris.scarab.util; 2 3 48 49 import java.util.List ; 51 import java.util.Date ; 52 53 54 62 public abstract class TableModel 63 { 65 private List headings; 66 private List rows; 67 68 public static boolean isDate(Object obj) 69 { 70 return obj instanceof Date ; 71 } 72 73 public static boolean isHeading(Object obj) 74 { 75 return obj instanceof Heading; 76 } 77 78 public static boolean isColumnHeading(Object obj) 79 { 80 return obj instanceof ColumnHeading; 81 } 82 83 public abstract int getColumnCount(); 84 public abstract int getRowCount(); 85 public abstract Object getValueAt(int row, int column) 86 throws Exception ; 87 88 92 public List getHeadings() 93 { 94 return headings; 95 } 96 97 101 public void setHeadings(List v) 102 { 103 this.headings = v; 104 } 105 106 110 public List getRows() 111 { 112 return rows; 113 } 114 115 119 public void setRows(List v) 120 { 121 this.rows = v; 122 } 123 124 public class ColumnHeading 125 extends Heading 126 { 127 132 public int getColspan() 133 { 134 int colspan = 1; 135 List subHeadings = getSubHeadings(); 136 if (subHeadings != null && subHeadings.size() > 0) 137 { 138 colspan = subHeadings.size(); 139 } 140 141 return colspan; 142 } 143 } 144 145 public class RowHeading 146 extends Heading 147 { 148 153 public int getRowspan() 154 { 155 int rowspan = 1; 156 List subHeadings = getSubHeadings(); 157 if (subHeadings != null && subHeadings.size() > 0) 158 { 159 rowspan = subHeadings.size(); 160 } 161 162 185 return rowspan; 186 } 187 } 188 189 public class Heading 190 { 191 private List subHeadings; 192 private Object label; 193 194 198 public int getRowspan() 199 { 200 return 1; 201 } 202 203 207 public int getColspan() 208 { 209 return 1; 210 } 211 212 216 public List getSubHeadings() 217 { 218 return subHeadings; 219 } 220 221 225 public void setSubHeadings(List v) 226 { 227 this.subHeadings = v; 228 } 229 230 234 public Object getLabel() 235 { 236 return label; 237 } 238 239 243 public void setLabel(Object v) 244 { 245 this.label = v; 246 } 247 } 248 } 249 | Popular Tags |