Class CakeCSVParser
- java.lang.Object
-
- de.uni_trier.wi2.procake.utils.io.CakeCSVParser
-
public class CakeCSVParser extends Object
A CSV Parser, that uses the csv package from the Apache group. It's possible, to read a csv file and create aggregate objects of the entries. For this, a suitable model has to be defined.Because the creation of the objects runs in parallel, the order of the objects in the object pool isn't deterministic.
- Author:
- Alexander Schultheis, Maximilian Hoffmann
-
-
Constructor Summary
Constructors Constructor Description CakeCSVParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<AggregateObject>createAggregateObjects(String className, boolean containsHeaders, Integer maximumExamples)Parses the CSV file and creates a list of aggregate objects.List<AggregateObject>createAggregateObjects(String className, Integer maximumExamples)Parses the CSV file and creates a list of aggregate objects.voiddisableMapping()Do not use a mapping file for processing the CSV file.chargetDelimiter()StringgetFilename()voidsetDelimiter(char delimiter)voidsetFilename(String filename)voidsetMappingFile(String filename)
-
-
-
Method Detail
-
getFilename
public String getFilename()
-
setFilename
public void setFilename(String filename)
-
createAggregateObjects
public List<AggregateObject> createAggregateObjects(String className, Integer maximumExamples)
Parses the CSV file and creates a list of aggregate objects. Thereby, the source CSV file contains a header row with the attribute names.- Parameters:
className- the name of the class every example for the CSV belongs tomaximumExamples- the maximum number to process. Ignore of null- Returns:
- the list of parsed CSV entries
- See Also:
createAggregateObjects(String, Integer)
-
createAggregateObjects
public List<AggregateObject> createAggregateObjects(String className, boolean containsHeaders, Integer maximumExamples)
Parses the CSV file and creates a list of aggregate objects. It can be set if the CSV file contains a header row with the attribute names. The choice of the parametercontainsHeadersand the value ofmappingFiledetermine the behavior of this method. IfmappingFileis not set and the file contains no headers, an exception will be thrown. In contrast, if the file contains headers then those will be used to map the values to the correct attributes. IfmappingFileis set and the file contains no headers, then the parser can only work properly if column numbers are mapped to attribute names. If the file contains header information andmappingFileis set then the parser will use the given mappings, either column number or column name mappings, during processing.- Parameters:
className- the name of the class every example for the CSV belongs tocontainsHeaders- if the CSV file to parse contains headersmaximumExamples- the maximum number to process. Ignore of null- Returns:
- the list of parsed CSV entries
-
setMappingFile
public void setMappingFile(String filename)
-
disableMapping
public void disableMapping()
Do not use a mapping file for processing the CSV file. The parser will only work in this configuration if the CSV file contains a header row and the column names in the header row are equal to the attribute names in the aggregate object.
-
getDelimiter
public char getDelimiter()
-
setDelimiter
public void setDelimiter(char delimiter)
-
-