| |
|
| java.lang.Object com.mockrunner.jdbc.FileResultSetFactory
FileResultSetFactory | public class FileResultSetFactory implements ResultSetFactory(Code) | | 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 ).
With
FileResultSetFactory.setUseTemplates you can enable template replacement in the
files (default is false , i.e. templates are disabled).
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.
|
FileResultSetFactory | public FileResultSetFactory(String fileName)(Code) | | |
FileResultSetFactory | public FileResultSetFactory(File file)(Code) | | |
getFile | public File getFile()(Code) | | Get the File being used to read in the
ResultSet . Throws a RuntimeException
if the file does not exist.
the file |
setDefaultTemplateConfiguration | public void setDefaultTemplateConfiguration()(Code) | | This method sets the default template configuration. See
FileResultSetFactory.setUseTemplates for an explanation how templates work.
The default marker is $ and the default templates are:
$defaultString is replaced by an empty string
$defaultDate is replaced by 1970-01-01
$defaultInteger is replaced by 0
Please use
FileResultSetFactory.setTemplateConfiguration(String,Map) to set a
custom marker and custom templates.
|
setDelimiter | public void setDelimiter(String delimiter)(Code) | | Set the delimiter. Default is ";".
Parameters: delimiter - the delimiter |
setFirstLineContainsColumnNames | public void setFirstLineContainsColumnNames(boolean firstLineContainsColumnNames)(Code) | | Set if the first line contains the column names.
Default is false .
|
setTrim | public void setTrim(boolean trim)(Code) | | Set if the column entries should be trimmed.
Default is true .
|
setUseTemplates | public void setUseTemplates(boolean useTemplates)(Code) | | Set this to true to allow the use of templates
in data files. A template is identified by a marker followed
by a label. The template is replaced by a predefined string in
the corresponding data file. E.g. with the default configuration,
$defaultString is replaced by an empty string
in the file.
The default configuration which is automatically set uses
$ as a marker. See
FileResultSetFactory.setDefaultTemplateConfiguration for details. You can also set a custom template configuration using
FileResultSetFactory.setTemplateConfiguration(String,Map) .
Default is false , i.e. templates are disabled.
Parameters: useTemplates - set true to enable templates. |
|
|
|