View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.database;
17  
18  import java.util.Collection;
19  import java.util.List;
20  import java.util.Map;
21  
22  import com.isenshi.util.TableMap;
23  
24  public class SpreadSheetImpl extends AbstractDataTable implements SpreadSheet {
25  
26  	private TableMap dataMap;
27  
28  	private List rowHeaders;
29  		
30  	private String dataLabel;
31  	
32  	private String rowLabel;
33  	
34  	private String columnLabel;
35  	
36  	public SpreadSheetImpl(String name, String dataLabel, String rowLabel, List rowHeaders, String columnLabel, List columnHeaders, TableMap dataMap) {
37  		super(name, columnHeaders, columnHeaders);
38  		this.dataMap = dataMap;
39  		this.rowHeaders = rowHeaders;
40  		this.rowLabel = rowLabel;
41  		this.columnLabel = columnLabel;
42  	}
43  		
44  	public void setFilterMap(Map filterMap) {
45  		//do nothing
46  	}
47  	
48  	public String getDataLabel() {
49  		return dataLabel;
50  	}
51  	
52  	public String getRowLabel() {
53  		return rowLabel;
54  	}
55  	
56  	public String getColumnLabel() {
57  		return columnLabel;
58  	}
59  	
60  	protected void remove(int rowIndex) {
61  	}
62  
63  	public List getColumnHeaders() {
64  		return getHeaders();
65  	}
66  
67  	public List getRowHeaders() {
68  		return rowHeaders;
69  	}
70  
71  	public String getRowHeader(){
72  		return getRowHeader(getCurrentRow());
73  	}
74  	
75  	public String getRowHeader(int index){
76  		return String.valueOf(getRowHeaders().get(index));
77  	}
78  	
79  	public String getCurrentRowHeader(){
80  		return getRowHeader(getCurrentRow());
81  	}
82  		
83  	public int getRowSize() {
84  		return rowHeaders.size();
85  	}
86  
87  	public Object getData(int row, int column) {
88  		if(row<0||column<0){
89  			return null;
90  		}
91  		String rowLabel = (String) rowHeaders.get(row);
92  		String columnLabel = (String) getHeader(column);
93  		return dataMap.get(rowLabel, columnLabel);
94  	}
95  
96  	public Collection getDataList() {
97  		throw new UnsupportedOperationException();		
98  	}
99  
100 	public Object getRowObject(int row) {
101 		throw new UnsupportedOperationException();
102 	}
103 
104 	public Map getDataMap(int row) {
105 		throw new UnsupportedOperationException();
106 	}
107 }