Class CSVParserFactory

java.lang.Object
org.csvobjects.csv.CSVParserFactory

public final class CSVParserFactory extends Object
Singleton factory for creating the CSVParser parser objects for clients of the framework. This factory uses the csv-mapping.xml mapping configuration to create CSV parsers customized for the POJO bean to parse. This is the first interface for clients of the framework.
Since:
1.8
Author:
Anupam Sengupta
See Also:
  • Method Details

    • getSingleton

      public static CSVParserFactory getSingleton()
      Returns the singleton instance of this factory.
      Returns:
      the singleton parser factory
      Throws:
      CSVOException - thrown if the singleton cannot be created
    • getBeanMapping

      public CSVBeanMapping getBeanMapping(String beanName)
      Returns the requested bean mapping configuration.
      Parameters:
      beanName - the POJO bean for which the mapping is to be returned
      Returns:
      the CSV bean mapping, or null if not found
    • getCSVParser

      public CSVParser getCSVParser(String mappingName, String csvFileName, boolean inClassPath) throws FileNotFoundException
      Returns a new CSV file parser for the specified mapping, and the specified CSV file.
      Parameters:
      mappingName - the CSV mapping to for which the parser should be created
      csvFileName - the CSV file to be parsed
      inClassPath - indicates whether the CSV file is in the classpath
      Returns:
      the CSV Parser
      Throws:
      IllegalArgumentException - thrown if the specified CSV filename is empty, or if the specified mapping name is not found
      FileNotFoundException - thrown if the specified CSV file cannot be found
      See Also:
    • getCSVParser

      public CSVParser getCSVParser(String mappingName, Reader csvReader)
      Returns a new CSV file parser for the specified mapping and the specified CSV reader stream.
      Parameters:
      mappingName - the CSV mapping for which the parser should be returned
      csvReader - the CSV stream to parse
      Returns:
      the CSV Parser
      Throws:
      IllegalArgumentException - thrown if the specified mapping name is not found, or if the specified CSV reader is null
      See Also: