Search in sources :

Example 1 with CSVImportFileHandler

use of com.cubrid.common.ui.cubrid.table.importhandler.handler.CSVImportFileHandler in project cubrid-manager by CUBRID.

the class ImportFileHandlerFactory method getHandler.

/**
	 * Get the a import handler instance by file's extended name. xls,xlsx,csv
	 * supported.
	 * 
	 * @param fileName of the import file
	 * @param fileCharset String
	 * @return ImportFileHandler
	 */
public static ImportFileHandler getHandler(String fileName, ImportConfig importConfig) {
    String lowerCase = fileName.toLowerCase(Locale.getDefault());
    int importType = importConfig.getImportType();
    if (importType == ImportConfig.IMPORT_FROM_EXCEL) {
        //			} else 
        if (lowerCase.endsWith(".xls")) {
            return new XLSImportFileHandler(fileName, importConfig.getFilesCharset());
        } else if (lowerCase.endsWith(".csv")) {
            return new CSVImportFileHandler(fileName, importConfig.getFilesCharset());
        }
    } else if (importType == ImportConfig.IMPORT_FROM_TXT) {
        return new TxtImportFileHandler(fileName, importConfig.getFilesCharset(), importConfig.getColumnDelimiter(), importConfig.getRowDelimiter());
    } else if (importType == ImportConfig.IMPORT_FROM_SQL) {
    }
    throw new RuntimeException("Not supported file type.");
}
Also used : TxtImportFileHandler(com.cubrid.common.ui.cubrid.table.importhandler.handler.TxtImportFileHandler) CSVImportFileHandler(com.cubrid.common.ui.cubrid.table.importhandler.handler.CSVImportFileHandler) XLSImportFileHandler(com.cubrid.common.ui.cubrid.table.importhandler.handler.XLSImportFileHandler)

Aggregations

CSVImportFileHandler (com.cubrid.common.ui.cubrid.table.importhandler.handler.CSVImportFileHandler)1 TxtImportFileHandler (com.cubrid.common.ui.cubrid.table.importhandler.handler.TxtImportFileHandler)1 XLSImportFileHandler (com.cubrid.common.ui.cubrid.table.importhandler.handler.XLSImportFileHandler)1