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 com.isenshi.util.functor.BinaryFunction;
19  
20  public class ExtraRowDataTable extends DataTableWrapper {
21  
22  	private BinaryFunction function;
23  	
24  	public ExtraRowDataTable(DataTable dataTable, BinaryFunction function) {
25  		super(dataTable);
26  		this.function = function;
27  	}
28  	
29  	public int getRowSize() {
30  		return super.getRowSize() + 1;
31  	}
32  	
33  	public Object getData() {
34  		return getData(getCurrentColumn(), getCurrentRow());
35  	}
36  	
37  	public Object getData(int row, int column) {
38  		if(super.hasNextRow()){
39  			return super.getData(row, column);
40  		}else{
41  			initCurrentRow();
42  			next();
43  			Object obj = super.getData(column);
44  			while(hasNext()){
45  				next();
46  				if(lastRow()){
47  					break;
48  				}
49  				obj = function.evaluate(obj, super.getData(column));
50  			}
51  			return obj;
52  		}
53  	}
54  }