com.elasticpath.persistence.impl
Class CsvFileReaderImpl

java.lang.Object
  extended by com.elasticpath.persistence.impl.CsvFileReaderImpl
All Implemented Interfaces:
CsvFileReader

public class CsvFileReaderImpl
extends java.lang.Object
implements CsvFileReader

Represent a csv file reader and writer.


Field Summary
static char DEFAULT_COL_DELIMETER
          The default column delimeter.
static char DEFAULT_TEXT_QUALIFIER
          The default text qualifier.
 
Constructor Summary
CsvFileReaderImpl()
           
 
Method Summary
 void close()
          Close the csv file.
 java.util.List getTopLines(int lines)
          Read the top lines with the give number.
 void open(java.lang.String csvFileName)
          Open a csv file.
 void open(java.lang.String csvFileName, char colDelimeter, char textQualifier)
          Open a csv file with the given column delimeter and text qualifier.
 java.lang.String[] readNext()
          Read the next line.
 void setElasticPath(ElasticPath elasticPath)
          Sets the context instance ElasticPath.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COL_DELIMETER

public static final char DEFAULT_COL_DELIMETER
The default column delimeter.

See Also:
Constant Field Values

DEFAULT_TEXT_QUALIFIER

public static final char DEFAULT_TEXT_QUALIFIER
The default text qualifier.

See Also:
Constant Field Values
Constructor Detail

CsvFileReaderImpl

public CsvFileReaderImpl()
Method Detail

close

public void close()
           throws EpPersistenceException
Close the csv file.

Specified by:
close in interface CsvFileReader
Throws:
EpPersistenceException - in case of any IO error happens

getTopLines

public java.util.List getTopLines(int lines)
                           throws EpPersistenceException
Read the top lines with the give number. Notice: the file read cursor is moved to the line right after lines read.

Specified by:
getTopLines in interface CsvFileReader
Parameters:
lines - the number of lines to read
Returns:
a list contains top lines with the give number.
Throws:
EpPersistenceException - in case of any IO error

open

public void open(java.lang.String csvFileName)
          throws EpPersistenceException
Open a csv file.

Specified by:
open in interface CsvFileReader
Parameters:
csvFileName - the csv file name
Throws:
EpPersistenceException - if the given file doesn't exist

open

public void open(java.lang.String csvFileName,
                 char colDelimeter,
                 char textQualifier)
          throws EpPersistenceException
Open a csv file with the given column delimeter and text qualifier.

Specified by:
open in interface CsvFileReader
Parameters:
csvFileName - the csv file name
colDelimeter - the column delimeter
textQualifier - the text qualifer
Throws:
EpPersistenceException - if the given file doesn't exist

readNext

public java.lang.String[] readNext()
                            throws EpPersistenceException
Read the next line.

Specified by:
readNext in interface CsvFileReader
Returns:
the next line if it's available, otherwise null at the end of file
Throws:
EpPersistenceException - in case of any IO error happens

setElasticPath

public void setElasticPath(ElasticPath elasticPath)
Sets the context instance ElasticPath.

Parameters:
elasticPath - the context instance ElasticPath.