com.mockrunner.jdbc
Class FileResultSetFactory

java.lang.Object
  extended bycom.mockrunner.jdbc.FileResultSetFactory
All Implemented Interfaces:
ResultSetFactory

public class FileResultSetFactory
extends java.lang.Object
implements ResultSetFactory

Can be used to create a ResultSet based on a table specified in a CSV file. You can specify the delimiter of the columns (default is ";"). Furthermore you can specify if the first line contains the column names (default is false) and if the column entries should be trimmed (default is true). The file can be specified directly or by its name. The class tries to find the file in the absolut or relative path and (if not found) by calling getResource. Note that the file must exist in the local file system and cannot be loaded from inside a jar archive.


Constructor Summary
FileResultSetFactory(java.io.File file)
           
FileResultSetFactory(java.lang.String fileName)
           
 
Method Summary
 MockResultSet create(java.lang.String id)
           
 java.io.File getFile()
          Get the File being used to read in the ResultSet.
 void setDelimiter(java.lang.String delimiter)
          Set the delimiter.
 void setFirstLineContainsColumnNames(boolean firstLineContainsColumnNames)
          Set if the first line contains the column names.
 void setTrim(boolean trim)
          Set if the column entries should be trimmed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileResultSetFactory

public FileResultSetFactory(java.lang.String fileName)

FileResultSetFactory

public FileResultSetFactory(java.io.File file)
Method Detail

getFile

public java.io.File getFile()
Get the File being used to read in the ResultSet. Returns null if the file does not exist.

Returns:
the file

setDelimiter

public void setDelimiter(java.lang.String delimiter)
Set the delimiter. Default is ";".

Parameters:
delimiter - the delimiter

setFirstLineContainsColumnNames

public void setFirstLineContainsColumnNames(boolean firstLineContainsColumnNames)
Set if the first line contains the column names. Default is false.


setTrim

public void setTrim(boolean trim)
Set if the column entries should be trimmed. Default is true.


create

public MockResultSet create(java.lang.String id)
Specified by:
create in interface ResultSetFactory