View Javadoc

1   package net.sf.statcvs.reportmodel;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import net.sf.statcvs.renderer.TableCellRenderer;
7   
8   public class LinkColumn extends Column {
9       private final String title;
10      private final List urls = new ArrayList();
11      private final List labels = new ArrayList();
12      private String total = null;
13  
14      public LinkColumn(final String title) {
15          this.title = title;
16      }
17  
18      public void setTotal(final String value) {
19          this.total = value;
20      }
21  
22      public void addValue(final String url, final String label) {
23          if (url == null) {
24              this.urls.add("");
25          } else {
26              this.urls.add(url);
27          }
28          this.labels.add(label);
29      }
30  
31      public int getRows() {
32          return urls.size();
33      }
34  
35      public void renderHead(final TableCellRenderer renderer) {
36          renderer.renderCell(title);
37      }
38  
39      public void renderCell(final int rowIndex, final TableCellRenderer renderer) {
40          final String url = (String) this.urls.get(rowIndex);
41          renderer.renderLinkCell(("".equals(url) ? null : url), (String) this.labels.get(rowIndex));
42      }
43  
44      public void renderTotal(final TableCellRenderer renderer) {
45          if (total == null) {
46              renderer.renderEmptyCell();
47          } else {
48              renderer.renderCell(total);
49          }
50      }
51  }