com.taleo.integration.client.customstep.util.csv
Class CSVReader

java.lang.Object
  extended by java.io.Reader
      extended by com.taleo.integration.client.customstep.util.csv.CSVReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class CSVReader
extends java.io.Reader

Character delimited (CSV file) reader.

Since:
3.0 SP6
Author:
bdrolet

Field Summary
static java.lang.String ERROR_INVALID_READER
          Error message format when the csv is not well form.
static java.lang.String STANDARD_ESCAPING_MODE
          Define a default quote character for the csv column (excel).
static java.lang.String TALEO_ESCAPING_MODE
          Define a default quote character for the csv column (ISS).
static java.lang.String UNEXPECTED_LINE_FORMAT
          Error message format when the csv is not well form.
static java.lang.String UNSUPPORTED_TALEO_FORMAT_FOR_STRING_RESULT
          Error message format when the csv is not well form.
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
CSVReader(java.io.Reader pReader)
          Default constructor.
CSVReader(java.io.Reader pReader, boolean pHasHeader)
          Main constructor.
CSVReader(java.io.Reader pReader, boolean pHasHeader, char pDelimiter, char pQuoteDelimiter)
          Main constructor.
CSVReader(java.io.Reader pReader, boolean pHasHeader, char pDelimiter, char pQuoteDelimiter, java.lang.String pLineFeed)
          Main constructor.
CSVReader(java.io.Reader pReader, boolean pHasHeader, char pDelimiter, char pQuoteDelimiter, java.lang.String pEscapingDelimiter, java.lang.String pEscapingCarriageReturn, java.lang.String pEscapingLineFeed)
          Main constructor.
 
Method Summary
 boolean bufferIsEmpty()
          Return true if the pre-read buffer is empty.
 void close()
          
 java.util.List getHeadingNames()
          Get the list of headers.
 java.util.Properties getProperties()
          Returns the properties.
 int read()
          
 int read(char[] pCbuf, int pOff, int pLen)
          
 boolean readLine(java.util.List pLine)
          Read a single line.
 boolean readLine(java.util.List pLine, char pDelimiter, char pQuoteCaracter, java.lang.String pLineFeed)
          Read a single line.
 boolean readLine(java.util.Map pLine)
          Read a line of the csv file and populate the values in the list argument.
 boolean readLineTaleo(java.util.List pLine, char pDelimiter, char pQuoteCaracter)
          Read a single line.
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TALEO_ESCAPING_MODE

public static final java.lang.String TALEO_ESCAPING_MODE
Define a default quote character for the csv column (ISS).

See Also:
Constant Field Values

STANDARD_ESCAPING_MODE

public static final java.lang.String STANDARD_ESCAPING_MODE
Define a default quote character for the csv column (excel).

See Also:
Constant Field Values

UNEXPECTED_LINE_FORMAT

public static final java.lang.String UNEXPECTED_LINE_FORMAT
Error message format when the csv is not well form.

See Also:
Constant Field Values

UNSUPPORTED_TALEO_FORMAT_FOR_STRING_RESULT

public static final java.lang.String UNSUPPORTED_TALEO_FORMAT_FOR_STRING_RESULT
Error message format when the csv is not well form.

See Also:
Constant Field Values

ERROR_INVALID_READER

public static final java.lang.String ERROR_INVALID_READER
Error message format when the csv is not well form.

See Also:
Constant Field Values
Constructor Detail

CSVReader

public CSVReader(java.io.Reader pReader)
Default constructor.

Parameters:
pReader - The reader

CSVReader

public CSVReader(java.io.Reader pReader,
                 boolean pHasHeader)
Main constructor.

Parameters:
pReader - The reader
pHasHeader - Flag indicating if a header line is present

CSVReader

public CSVReader(java.io.Reader pReader,
                 boolean pHasHeader,
                 char pDelimiter,
                 char pQuoteDelimiter)
Main constructor.

Parameters:
pReader - The reader
pHasHeader - Flag indicating if a header line is present
pDelimiter - The value delimiter
pQuoteDelimiter - The quoting character

CSVReader

public CSVReader(java.io.Reader pReader,
                 boolean pHasHeader,
                 char pDelimiter,
                 char pQuoteDelimiter,
                 java.lang.String pLineFeed)
Main constructor.

Parameters:
pReader - The reader
pHasHeader - Flag indicating if a header line is present
pDelimiter - The value delimiter
pQuoteDelimiter - The quoting character
pLineFeed - The line feed character

CSVReader

public CSVReader(java.io.Reader pReader,
                 boolean pHasHeader,
                 char pDelimiter,
                 char pQuoteDelimiter,
                 java.lang.String pEscapingDelimiter,
                 java.lang.String pEscapingCarriageReturn,
                 java.lang.String pEscapingLineFeed)
Main constructor.

Parameters:
pReader - The reader
pHasHeader - Flag indicating if a header line is present
pDelimiter - The value delimiter
pQuoteDelimiter - The quoting character
pEscapingDelimiter - The escaping sequence for the delimiter
pEscapingCarriageReturn - The escaping sequence for the carriage return
pEscapingLineFeed - The escaping sequence for the line feed
Method Detail

bufferIsEmpty

public boolean bufferIsEmpty()
Return true if the pre-read buffer is empty.

Returns:
true if the pre-read buffer content is empty

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException

read

public int read(char[] pCbuf,
                int pOff,
                int pLen)
         throws java.io.IOException

Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

readLine

public boolean readLine(java.util.Map pLine)
                 throws java.io.IOException,
                        InvalidCSVFileFormat
Read a line of the csv file and populate the values in the list argument.

Parameters:
pLine - The map of lines
Returns:
If the operation was successful.
Throws:
java.io.IOException
InvalidCSVFileFormat

readLine

public boolean readLine(java.util.List pLine)
                 throws java.io.IOException,
                        InvalidCSVFileFormat
Read a single line. This method will read until a line is available, an I/O error occurs, an InvalidCsvFileFormat error occurs or the end of the stream is reached. The Default delimiter are the comma.

Parameters:
pLine - The list of lines
Returns:
return true when a line has been read, or false if the end of the stream has been reached
Throws:
java.io.IOException
InvalidCSVFileFormat

readLine

public boolean readLine(java.util.List pLine,
                        char pDelimiter,
                        char pQuoteCaracter,
                        java.lang.String pLineFeed)
                 throws java.io.IOException,
                        InvalidCSVFileFormat
Read a single line. This method will read until a line is available, an I/O error occurs, an InvalidCsvFileFormat error occurs or the end of the stream is reached.

Parameters:
pLine - The list of lines
pDelimiter - The delimiter
pQuoteCaracter - The quoting character
pLineFeed - The line feed character
Returns:
return true, or false if the end of the stream has been reached
Throws:
InvalidCSVFileFormat
java.io.IOException - - If an I/O error occurs

readLineTaleo

public boolean readLineTaleo(java.util.List pLine,
                             char pDelimiter,
                             char pQuoteCaracter)
                      throws java.io.IOException,
                             InvalidCSVFileFormat
Read a single line. This method will read until a line is available, an I/O error occurs, an InvalidCsvFileFormat error occurs or the end of the stream is reached.

Parameters:
pLine - The list of lines
pDelimiter - The delimiter
pQuoteCaracter - The quoting character
Returns:
return true, or false if the end of the stream has been reached
Throws:
InvalidCSVFileFormat
java.io.IOException - - If an I/O error occurs

getProperties

public java.util.Properties getProperties()
Returns the properties.

Returns:
the properties.

getHeadingNames

public java.util.List getHeadingNames()
                               throws java.io.IOException,
                                      InvalidCSVFileFormat
Get the list of headers.

Returns:
The list of headers
Throws:
java.io.IOException
InvalidCSVFileFormat

read

public int read()
         throws java.io.IOException

Overrides:
read in class java.io.Reader
Throws:
java.io.IOException