1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.database;
17
18 import java.util.HashMap;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.Map;
22
23 public class SelectedColumnDataTableImpl extends DataTableWrapper{
24
25 private List selectedColumnHeaders_;
26
27 private Map displayHeaderMap_ = new HashMap();
28
29 private int[] orinalIndex_;
30
31 public SelectedColumnDataTableImpl(DataTable dataTable, List headers){
32 super(dataTable);
33 this.selectedColumnHeaders_ = headers;
34
35 orinalIndex_ = new int[headers.size()];
36 for(int i=0; i<orinalIndex_.length; i++){
37 String header = (String)headers.get(i);
38 int index = super.getHeaders().indexOf(header);
39 orinalIndex_[i] = index;
40 }
41
42 Map orgDisplayMap = dataTable.getDisplayHeaderMap();
43 Iterator itr = orgDisplayMap.keySet().iterator();
44
45 while(itr.hasNext()){
46 String header = (String)itr.next();
47 if(selectedColumnHeaders_.contains(header)){
48 displayHeaderMap_.put(header, orgDisplayMap.get(header));
49 }
50 }
51 }
52
53 public List getHeaders() {
54 return selectedColumnHeaders_;
55 }
56
57 public Map getDisplayHeaderMap() {
58 return displayHeaderMap_;
59 }
60
61 public Iterator getHeaderIterator() {
62 return selectedColumnHeaders_.iterator();
63 }
64
65 public int getColumnSize() {
66 return selectedColumnHeaders_.size();
67 }
68
69 public Object getData(int columnIndex) {
70 return super.getData(orinalIndex_[columnIndex]);
71 }
72
73 public Object getData(String columnName) {
74 if(selectedColumnHeaders_.contains(columnName)){
75 return getData(selectedColumnHeaders_.indexOf(columnName));
76 }else{
77 return getProxyData(getCurrentRow(), columnName);
78 }
79 }
80
81 public Object getData(int row, String columnName) {
82 if(selectedColumnHeaders_.contains(columnName)){
83 int columnIndex = selectedColumnHeaders_.indexOf(columnName);
84 return getData(row, columnIndex);
85 }else{
86 return getProxyData(getCurrentRow(), columnName);
87 }
88 }
89
90 public Object getData(int row, int column) {
91 return super.getData(row, orinalIndex_[column]);
92 }
93
94 public Object getData() {
95 return super.getData(getCurrentRow(), orinalIndex_[getCurrentColumn()]);
96 }
97
98 public Object nextColumn() {
99 incrementCurrentColumn();
100 return getData(getCurrentRow(), getCurrentColumn());
101 }
102
103 public void remove() {
104
105
106 }
107
108 public Object getRowObject() {
109 return getRowObject(getCurrentRow());
110 }
111
112
113
114 private Object getProxyData(int row, String columnName){
115 if(super.getHeaders().contains(columnName)){
116 int index = super.getHeaders().indexOf(columnName);
117 return super.getData(getCurrentRow(), index);
118 }
119 return null;
120 }
121 }