创建数据源连接的demo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
1.1 KiB

package com.tptj.demo.hg.connection.data;
import com.fanruan.api.data.open.BaseDataModel;
import com.fanruan.api.err.TableDataException;
import com.tptj.demo.hg.connection.store.Data;
import com.tptj.demo.hg.connection.conn.DemoConnection;
import com.tptj.demo.hg.connection.store.Store;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021-03-31
**/
public class DemoModel extends BaseDataModel {
private Data data = Data.EMPTY;
public DemoModel( DemoConnection conn ){
data = Store.getInstance().get( conn.getKey() );
}
@Override
public int getColumnCount() throws TableDataException {
return data.getKey().length;
}
@Override
public String getColumnName(int cIdx) throws TableDataException {
return data.getKey()[cIdx];
}
@Override
public int getRowCount() throws TableDataException {
return data.getRow().length;
}
@Override
public Object getValueAt(int rIdx, int cIdx) throws TableDataException {
return data.getRow()[rIdx][cIdx];
}
@Override
public void release() throws Exception {
data = Data.EMPTY;
}
}