public abstract class CSVReaderService extends Object
| Constructor and Description |
|---|
CSVReaderService() |
| Modifier and Type | Method and Description |
|---|---|
protected List<CSVMessageDescriptor> |
checkCSVFileValidity(List<String[]> listLines,
int nColumnNumber,
boolean bSkipFirstLine,
Locale locale)
Check the validity of the whole CSV file.
|
protected List<CSVMessageDescriptor> |
checkCSVLineColumnNumber(String[] strLine,
int nColumnNumber,
int nLineNumber,
Locale locale)
Check the number of columns of a line.
|
protected abstract List<CSVMessageDescriptor> |
checkLineOfCSVFile(String[] strLineDataArray,
int nLineNumber,
Locale locale)
Check the line of the CSV file.
|
Character |
getCSVEscapeCharacter()
Get the escape character used for CSV files.
|
Character |
getCSVSeparator()
Get the separator used for CSV files.
|
static Character |
getDefaultCSVEscapeCharacter()
Get the default CSV escape character to use.
|
static Character |
getDefaultCSVSeparator()
Get the default CSV separator to use.
|
protected abstract List<CSVMessageDescriptor> |
getEndOfProcessMessages(int nNbLineParses,
int nNbLinesWithoutErrors,
Locale locale)
Get messages after the process is completed.
|
List<CSVMessageDescriptor> |
readCSVFile(File file,
int nColumnNumber,
boolean bCheckFileBeforeProcessing,
boolean bExitOnError,
boolean bSkipFirstLine,
Locale locale,
String strBaseUrl)
Read a CSV file and call the method
readLineOfCSVFile for each of its lines. |
List<CSVMessageDescriptor> |
readCSVFile(org.apache.commons.fileupload.FileItem fileItem,
int nColumnNumber,
boolean bCheckFileBeforeProcessing,
boolean bExitOnError,
boolean bSkipFirstLine,
Locale locale,
String strBaseUrl)
Read a CSV file and call the method
readLineOfCSVFile for each of its lines. |
List<CSVMessageDescriptor> |
readCSVFile(PhysicalFile physicalFile,
int nColumnNumber,
boolean bCheckFileBeforeProcessing,
boolean bExitOnError,
boolean bSkipFirstLine,
Locale locale,
String strBaseUrl)
Read a CSV file and call the method
readLineOfCSVFile for each of its lines. |
protected List<CSVMessageDescriptor> |
readCSVFile(Reader reader,
au.com.bytecode.opencsv.CSVReader csvReader,
int nColumnNumber,
boolean bCheckFileBeforeProcessing,
boolean bExitOnError,
boolean bSkipFirstLine,
Locale locale,
String strBaseUrl)
Read a CSV file and call the method
readLineOfCSVFile for each of its lines. |
List<CSVMessageDescriptor> |
readCSVFile(String strPath,
int nColumnNumber,
boolean bCheckFileBeforeProcessing,
boolean bExitOnError,
boolean bSkipFirstLine,
Locale locale,
String strBaseUrl)
Read a CSV file and call the method
readLineOfCSVFile for each of its lines. |
protected abstract List<CSVMessageDescriptor> |
readLineOfCSVFile(String[] strLineDataArray,
int nLineNumber,
Locale locale,
String strBaseUrl)
Read a line of the CSV file.
|
void |
setCSVEscapeCharacter(Character strCSVEscapeCharacter)
Set the escape character to use for CSV files.
|
void |
setCSVSeparator(Character strCSVSeparator)
Set the separator to use for CSV files.
|
protected abstract List<CSVMessageDescriptor> readLineOfCSVFile(String[] strLineDataArray, int nLineNumber, Locale locale, String strBaseUrl)
strLineDataArray - The content of the line of the CSV file.nLineNumber - Number of the current linelocale - the localestrBaseUrl - The base URLprotected abstract List<CSVMessageDescriptor> checkLineOfCSVFile(String[] strLineDataArray, int nLineNumber, Locale locale)
strLineDataArray - The content of the line of the CSV file.nLineNumber - Number of the current linelocale - the localeINFO will NOT
be processed, and the global processing may stop if the ExitOnError flag has been set to true !protected abstract List<CSVMessageDescriptor> getEndOfProcessMessages(int nNbLineParses, int nNbLinesWithoutErrors, Locale locale)
nNbLineParses - The number of lines parses. If the first line was skipped, it is not counted.nNbLinesWithoutErrors - the number of lines parses whitout error.locale - The localepublic static Character getDefaultCSVSeparator()
public static Character getDefaultCSVEscapeCharacter()
public List<CSVMessageDescriptor> readCSVFile(org.apache.commons.fileupload.FileItem fileItem, int nColumnNumber, boolean bCheckFileBeforeProcessing, boolean bExitOnError, boolean bSkipFirstLine, Locale locale, String strBaseUrl)
readLineOfCSVFile for each of its lines.fileItem - FileItem to get the CSV file from. If the creation of the input stream associated to this file throws a IOException, then an error is returned
and the file is not red.nColumnNumber - Number of columns of each lines. Use 0 to skip column number check (for example if every lines don't have the same number of columns)bCheckFileBeforeProcessing - Indicates if the file should be check before processing any of its line. If it is set to true, then then no line is processed if the file has
any error.bExitOnError - Indicates if the processing of the CSV file should end on the first error, or at the end of the file.bSkipFirstLine - Indicates if the first line of the file should be skipped or not.locale - the localestrBaseUrl - The base URLCSVMessageDescriptor.compareTo(CSVMessageDescriptor) for information about sortpublic List<CSVMessageDescriptor> readCSVFile(String strPath, int nColumnNumber, boolean bCheckFileBeforeProcessing, boolean bExitOnError, boolean bSkipFirstLine, Locale locale, String strBaseUrl)
readLineOfCSVFile for each of its lines.strPath - Path if the file to read in the file system.nColumnNumber - Number of columns of each lines. Use 0 to skip column number check (for example if every lines don't have the same number of columns)bCheckFileBeforeProcessing - Indicates if the file should be check before processing any of its line. If it is set to true, then then no line is processed if the file has
any error.bExitOnError - Indicates if the processing of the CSV file should end on the first error, or at the end of the file.bSkipFirstLine - Indicates if the first line of the file should be skipped or not.locale - the localestrBaseUrl - The base URLCSVMessageDescriptor.compareTo(CSVMessageDescriptor) for information about sortpublic List<CSVMessageDescriptor> readCSVFile(File file, int nColumnNumber, boolean bCheckFileBeforeProcessing, boolean bExitOnError, boolean bSkipFirstLine, Locale locale, String strBaseUrl)
readLineOfCSVFile for each of its lines.file - File to get the values from. If the physical file of this file has no value, then it is gotten from the database.nColumnNumber - Number of columns of each lines. Use 0 to skip column number check (for example if every lines don't have the same number of columns)bCheckFileBeforeProcessing - Indicates if the file should be check before processing any of its line. If it is set to true, then then no line is processed if the file has
any error.bExitOnError - Indicates if the processing of the CSV file should end on the first error, or at the end of the file.bSkipFirstLine - Indicates if the first line of the file should be skipped or not.locale - the localestrBaseUrl - The base URLCSVMessageDescriptor.compareTo(CSVMessageDescriptor) for information about sortpublic List<CSVMessageDescriptor> readCSVFile(PhysicalFile physicalFile, int nColumnNumber, boolean bCheckFileBeforeProcessing, boolean bExitOnError, boolean bSkipFirstLine, Locale locale, String strBaseUrl)
readLineOfCSVFile for each of its lines.physicalFile - The physicalFile to get the values from. If the physical file has no value, then it is gotten from the database.nColumnNumber - Number of columns of each lines. Use 0 to skip column number check (for example if every lines don't have the same number of columns)bCheckFileBeforeProcessing - Indicates if the file should be check before processing any of its line. If it is set to true, then then no line is processed if the file has
any error.bExitOnError - Indicates if the processing of the CSV file should end on the first error, or at the end of the file.bSkipFirstLine - Indicates if the first line of the file should be skipped or not.locale - the localestrBaseUrl - The base URLCSVMessageDescriptor.compareTo(CSVMessageDescriptor) for information about sortprotected List<CSVMessageDescriptor> readCSVFile(Reader reader, au.com.bytecode.opencsv.CSVReader csvReader, int nColumnNumber, boolean bCheckFileBeforeProcessing, boolean bExitOnError, boolean bSkipFirstLine, Locale locale, String strBaseUrl)
readLineOfCSVFile for each of its lines.reader - The file reader that was used to create the CSV reader. This reader will be closed by this methodcsvReader - CSV reader to use to read the CSV filenColumnNumber - Number of columns of each lines. Use 0 to skip column number check (for example if every lines don't have the same number of columns)bCheckFileBeforeProcessing - Indicates if the file should be check before processing any of its line. If it is set to true, then then no line is processed if the file has
any error.bExitOnError - Indicates if the processing of the CSV file should end on the first error, or at the end of the file.bSkipFirstLine - Indicates if the first line of the file should be skipped or not.locale - the localestrBaseUrl - The base URLCSVMessageDescriptor.compareTo(CSVMessageDescriptor) for information about sortprotected List<CSVMessageDescriptor> checkCSVFileValidity(List<String[]> listLines, int nColumnNumber, boolean bSkipFirstLine, Locale locale)
listLines - The list of lines of the filenColumnNumber - The number of columns every line must have.bSkipFirstLine - True if the first line should be ignored, false otherwiselocale - The localeprotected List<CSVMessageDescriptor> checkCSVLineColumnNumber(String[] strLine, int nColumnNumber, int nLineNumber, Locale locale)
strLine - The line to checknColumnNumber - The number of columns the line must havenLineNumber - The number of the current linelocale - The localepublic Character getCSVSeparator()
public void setCSVSeparator(Character strCSVSeparator)
strCSVSeparator - The separator to use for CSV files.public Character getCSVEscapeCharacter()
public void setCSVEscapeCharacter(Character strCSVEscapeCharacter)
strCSVEscapeCharacter - The escape character to use for CSV files.Copyright © 2020 City of Paris. All rights reserved.