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 abstract class AbstractDataTable extends AbstractDataTableCore {
24
25 private int currentRow = -1;
26
27 private int currentColumn = -1;
28
29 private String name;
30
31 private List systemHeaders_;
32
33 private Map displayHeaderMap_;
34
35 protected AbstractDataTable(String name, List systemHeaders, List displayHeaders){
36 this.name = name;
37 this.systemHeaders_ = systemHeaders;
38
39 displayHeaderMap_ = new HashMap();
40 if (displayHeaders != null) {
41 for (int i = 0; i < systemHeaders_.size(); i++) {
42 displayHeaderMap_.put(systemHeaders.get(i), displayHeaders.get(i));
43 }
44 }
45 }
46
47 public boolean isSpreadSheet() {
48 return this instanceof SpreadSheet;
49 }
50
51 public final void init() {
52 currentRow = -1;
53 currentColumn = -1;
54 }
55
56 public final List getHeaders() {
57 return systemHeaders_;
58 }
59
60 public final Map getDisplayHeaderMap() {
61 return displayHeaderMap_;
62 }
63
64 public final Iterator getHeaderIterator() {
65 return systemHeaders_.iterator();
66 }
67
68 public final int getColumnSize() {
69 return systemHeaders_.size();
70 }
71
72 public final String getName() {
73 return name;
74 }
75
76 public int getCurrentColumn() {
77 return currentColumn;
78 }
79
80 public int getCurrentRow() {
81 return currentRow;
82 }
83
84 public void initCurrentColumn(){
85 currentColumn = -1;
86 }
87
88 public void initCurrentRow(){
89 currentRow = -1;
90 }
91
92 public void incrementCurrentRow(){
93 currentRow ++;
94 }
95
96 public void decrementCurrentRow(){
97 currentRow --;
98 }
99
100 public void incrementCurrentColumn(){
101 currentColumn ++;
102 }
103
104 public void decrementCurrentColumn(){
105 currentColumn --;
106 }
107
108 public final Object nextColumn() {
109 incrementCurrentColumn();
110 return getData(getCurrentRow(), getCurrentColumn());
111 }
112
113 public final Object getData() {
114 return getData(getCurrentRow(), getCurrentColumn());
115 }
116
117 public final Object getData(int columnIndex) {
118 return getData(getCurrentRow(), columnIndex);
119 }
120
121 public final Object getData(int row, String columnName) {
122 int columnIndex = getColumnIndex(columnName);
123 return getData(row, columnIndex);
124 }
125
126 public final Object getData(String columnName) {
127 int columnIndex = getColumnIndex(columnName);
128 return getData(getCurrentRow(), columnIndex);
129 }
130
131 public final Object getRowObject() {
132 return getRowObject(getCurrentRow());
133 }
134
135 public void remove() {
136 remove(getCurrentRow());
137 }
138
139 public String getHeader(){
140 return getHeader(currentColumn);
141 }
142
143 public String getHeader(int index){
144 return (String)systemHeaders_.get(index);
145 }
146
147 protected abstract void remove(int rowIndex);
148
149 protected int getColumnIndex(String columnName) {
150 return systemHeaders_.indexOf(columnName);
151 }
152
153 }