1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.extremecomponents.table.model;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.extremecomponents.table.bean.Column;
27
28
29
30 /***
31 * The first pass over the table just loads up the column properties.
32 * The properties will be loaded up and held here.
33 *
34 * @author Jeff Johnston
35 */
36 public class ColumnMetaData
37 {
38 private static Log logger = LogFactory.getLog(ColumnMetaData.class);
39 private TableModel model;
40 private List columns = new ArrayList();
41 private Map lookup = new HashMap();
42 private Column firstColumn;
43 private Column lastColumn;
44
45 public ColumnMetaData(TableModel model)
46 {
47 this.model = model;
48 }
49
50 public void addColumn(Column column)
51 {
52 boolean invokeExport = model.getExportHandler().invokeExport();
53 boolean canExport = column.canExport();
54 if (invokeExport && !canExport)
55 {
56 return;
57 }
58
59 if (firstColumn == null)
60 {
61 firstColumn = column;
62 }
63 lastColumn = column;
64
65 columns.add(column);
66 lookup.put(column.getProperty(), column);
67 }
68
69 public Column getColumn(String property)
70 {
71 return (Column)lookup.get(property);
72 }
73
74 public int columnCount()
75 {
76 return columns.size();
77 }
78
79 public Iterator getColumns()
80 {
81 return columns.iterator();
82 }
83
84 public boolean hasMetatData()
85 {
86 return columnCount() > 0;
87 }
88
89 public boolean isFirstColumn(String property)
90 {
91 return firstColumn.getProperty().equals(property);
92 }
93
94 public boolean isLastColumn(String property)
95 {
96 return lastColumn.getProperty().equals(property);
97 }
98
99 public void destroy()
100 {
101 columns.clear();
102 columns = null;
103 lookup.clear();
104 lookup = null;
105 }
106 }