001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * JREmptyDatasourceConnection.java
028: *
029: * Created on 4 giugno 2003, 18.15
030: *
031: */
032:
033: package it.businesslogic.ireport.connection;
034:
035: import it.businesslogic.ireport.IReportConnectionEditor;
036: import it.businesslogic.ireport.connection.gui.JREmptyDataSourceConnectionEditor;
037: import it.businesslogic.ireport.util.*;
038: import net.sf.jasperreports.engine.JREmptyDataSource;
039:
040: /**
041: *
042: * @author Administrator
043: */
044: public class JREmptyDatasourceConnection extends
045: it.businesslogic.ireport.connection.NullConnection {
046:
047: private int records = 1;
048:
049: /** Creates a new instance of JDBCConnection */
050: public JREmptyDatasourceConnection() {
051: this .setName("Empty datasource connection");
052: }
053:
054: /** This method return an instanced connection to the database.
055: * If isJDBCConnection() return false => getConnection() return null
056: *
057: */
058: public java.sql.Connection getConnection() {
059: return null;
060: }
061:
062: public boolean isJDBCConnection() {
063: return false;
064: }
065:
066: public boolean isJRDataSource() {
067: return true;
068: }
069:
070: /*
071: * This method return all properties used by this connection
072: */
073: public java.util.HashMap getProperties() {
074: java.util.HashMap map = new java.util.HashMap();
075: map.put("records", "" + this .getRecords());
076: return map;
077: }
078:
079: public void loadProperties(java.util.HashMap map) {
080: this .setRecords(Integer.parseInt(Misc.nvl((String) map
081: .get("records"), "1")));
082: }
083:
084: /**
085: * This method return an instanced JRDataDource to the database.
086: * If isJDBCConnection() return true => getJRDataSource() return false
087: */
088: public net.sf.jasperreports.engine.JRDataSource getJRDataSource() {
089: return new JREmptyDataSource(getRecords());
090: }
091:
092: public int getRecords() {
093: return records;
094: }
095:
096: public void setRecords(int records) {
097: this .records = records;
098: }
099:
100: public String getDescription() {
101: return I18n.getString("connectionType.emptyDataSource",
102: "Empty data source");
103: }
104:
105: public IReportConnectionEditor getIReportConnectionEditor() {
106: return new JREmptyDataSourceConnectionEditor();
107: }
108: }
|