⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sampledataset.java

📁 杰表服务器 部分源码 杰创网络报表(简称“杰表”)是一款国产的网络报表开发工具
💻 JAVA
字号:
package userx.test;import com.jatools.core.ZDataProvider;import com.jatools.data.ZDataException;import com.jatools.data.rs.bean.ZBeanDataset;/** * @author java * * javabean 数据源扩展示例 */public class SampleDataset implements ZBeanDataset {    static String[] columnNames = new String[] { "省级行政区", "简称", "面积(万平方公里)", "人口(万)", "省会" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$    static Class[] columnClasses = new Class[] { String.class, String.class, Double.class, Double.class, String.class };    static Object[] data = new Object[] {            new Object[] { "北京市          ", "京", new Double(1.68), new Double(1143), "" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "天津市          ", "津", new Double(1.1), new Double(927), "" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "河北省          ", "冀", new Double(19), new Double(6742), "石家庄市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "山西省          ", "晋", new Double(15), new Double(3245), "太原市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "内蒙古自治区    ", "内蒙古", new Double(110), new Double(2355), "呼和浩特市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "辽宁省          ", "辽", new Double(15), new Double(4155), "沈阳市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "吉林省          ", "吉", new Double(18), new Double(2649), "长春市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "黑龙江省        ", "黑", new Double(46), new Double(3732), "哈尔滨市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "上海市          ", "沪", new Double(0.58), new Double(1334), "" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "江苏省          ", "苏", new Double(10), new Double(7127), "南京市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "浙江省          ", "浙", new Double(10), new Double(4536), "杭州市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "安徽省          ", "皖", new Double(13), new Double(6369), "安徽省" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "福建省          ", "闽", new Double(12), new Double(3332), "福州市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "江西省          ", "赣", new Double(16), new Double(4263), "南昌市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "山东省          ", "鲁", new Double(15), new Double(9069), "济南市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "河南省          ", "豫", new Double(16), new Double(9683), "郑州市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "湖北省          ", "鄂", new Double(18), new Double(5978), "武汉市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "湖南省          ", "湘", new Double(21), new Double(6564), "长沙市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "广东省          ", "粤", new Double(18), new Double(7649), "广州市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "广西壮族自治区  ", "桂", new Double(23), new Double(4791), "南宁市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "海南省          ", "琼", new Double(3.4), new Double(779), "海口市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "重庆市          ", "渝", new Double(8.23), new Double(3114), "" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "四川省          ", "川、蜀", new Double(48), new Double(8474), "成都市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "贵州省          ", "黔、贵", new Double(17), new Double(3748), "贵阳市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "云南省          ", "滇、云", new Double(38), new Double(4141), "昆明市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "西藏自治区      ", "藏", new Double(120), new Double(255), "拉萨市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "陕西省          ", "陕、秦", new Double(19), new Double(3611), "西安市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "甘肃省          ", "甘、陇", new Double(39), new Double(2568), "兰州市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "青海省          ", "青", new Double(72), new Double(487), "西宁市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "宁夏回族自治区  ", "宁", new Double(6.6), new Double(573), "银川市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "新疆维吾尔自治区", "新", new Double(160), new Double(1860), "乌鲁木齐市" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "香港特别行政区  ", "港", new Double(0.1101), new Double(681.01), "" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "澳门特别行政区  ", "澳", new Double(0.0025), new Double(44.8495), "" }, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            new Object[] { "台湾省          ", "台", new Double(3.6), new Double(2260), "" // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$            }        };    /**     * 接口方法,取得数据集的列数     *     * @return 数据集列数     *     * @throws ZDataException 出错抛出例外     */    public int getColumnCount() throws ZDataException {        return columnNames.length;    }    /**     * 接口方法,取得某一列的列名     *     * @param col 指定列号,第一列从0开始编号     *     * @return 列名     *     * @throws ZDataException 列不存在抛出例外     */    public String getColumnName(int col) throws ZDataException {        if ((col > -1) && (col < getColumnCount())) {            return columnNames[col];        } else {            throw new ZDataException("指定的列不存在 [列" + col + "].");        }    }    /**     * 接口方法,取得某列的类型     *     * @param col 指定列号,第一列从0开始编号     *     * @return 列类型     *     * @throws ZDataException 列不存在抛出例外     */    public Class getColumnClass(int col) throws ZDataException {        if ((col > -1) && (col < getColumnCount())) {            return columnClasses[col];        } else {            throw new ZDataException("指定的列不存在 [列" + col + "].");        }    }    /**     * 接口方法,取得数据集的总行数     *     * @return 总行数     *     * @throws ZDataException 出错例外     */    public int getRowCount() throws ZDataException {        return data.length;    }    /**     * 接口方法,取得某一行,某一列中的数据     *     * @param row 指定哪一行     * @param col 指定哪一列     *     * @return 指定行列中的数据     *     * @throws ZDataException 如果越界则抛出例外     */    public Object getValueAt(int row, int col) throws ZDataException {        if ((row > -1) && (row < getRowCount()) && (col > -1) && (col < getColumnCount())) {            return ((Object[]) data[row])[col];        } else {            throw new ZDataException("指定的行列不存在 [行=" + row + ",列" + col + "]."); //        }    }    /**     * 接口方法,载入数据.	 * 由于本数据源扩展,数据总是现成的(存在于多维数组data中),没有必要从其他地方载入数据,所以为空     *     * @param p DOCUMENT ME!     *     * @throws ZDataException DOCUMENT ME!     */    public void loadData(ZDataProvider p) throws ZDataException {    }    /**     * 接口方法,告诉杰表设计器,本数据源支持哪些属性     * 本扩展不支持任何属性	 *      * @return DOCUMENT ME!     */    public String getSupportedProperties() {        return null;    }	public boolean isCacheable() {		// TODO Auto-generated method stub		return false;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -