Java 类net.sf.jasperreports.engine.query.JRCsvQueryExecuterFactory 实例源码

项目:ireport-fork    文件:JRCSVDataSourceConnection.java   
/**
 * Add all the CSV parameters required to execute the report
 * in query execute mode...
 * @param map
 * @return
 * @throws net.sf.jasperreports.engine.JRException
 */
@Override
public java.util.Map getSpecialParameters(java.util.Map map) throws net.sf.jasperreports.engine.JRException
{
    if (isQeMode())
    {
        System.out.println("Setting parameters for the CSV query executer");
        map.put( JRCsvQueryExecuterFactory.CSV_FILE, new File(this.getFilename()));
        if (this.getCustomDateFormat() != null && this.getCustomDateFormat().length() > 0)
        {
            map.put( JRCsvQueryExecuterFactory.CSV_DATE_FORMAT, new SimpleDateFormat(this.getCustomDateFormat()) );
        }

        // This particular setting must be fixed in JR first
        //map.put( JRCsvQueryExecuterFactory.CSV_FIELD_DELIMITER, new java.lang.Character( getFieldDelimiter().charAt(0) ));
        map.put( JRCsvQueryExecuterFactory.CSV_RECORD_DELIMITER, getRecordDelimiter());
        map.put( JRCsvQueryExecuterFactory.CSV_USE_FIRST_ROW_AS_HEADER, new java.lang.Boolean(isUseFirstRowAsHeader()));

        if (!isUseFirstRowAsHeader())
        {
            String[] names = new String[getColumnNames().size()];
            for (int i=0; i<names.length; ++i )
            {
                names[i] = ""+getColumnNames().elementAt(i);
            }
            map.put( JRCsvQueryExecuterFactory.CSV_COLUMN_NAMES_ARRAY, names);
        }
    }
    return map;
}